Compares input sq
object with either
another sq
object or character
vector.
# S3 method for sq
==(e1, e2)
[sq
]
An object this comparison is applied to.
[sq
|| character
]
An object to compare with x1
.
A logical
vector indicating on which positions these
objects are equal.
`==`
compares compatible object for equality of their respective
sequences. Objects are considered compatible, when either both have same
length or one of them is a scalar value (i.e. a vector of length 1).
Moreover, not every e1
sq type can be compared to any e2
sq
type.
To see which types are compatible, see Details of
sq-concatenate
.
`==`
returns logical vector, where each element describes whether
elements at position n
of both e1
and e2
are equal in
meaning (that is, they may be represented differently, but their biological
interpretation must be identical). If one of compared objects is a scalar,
then said logical vector describes comparison for each element of the other,
longer vector.
Functions from utility module:
get_sq_lengths()
,
is.sq()
,
sqconcatenate
,
sqextract
# Creating objects to work on:
sq_dna_1 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT"),
alphabet = "dna_bsc")
sq_dna_2 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT"),
alphabet = "dna_bsc")
sq_dna_3 <- sq(c("ACTGCTG", "CTTAGA", "GGAA"),
alphabet = "dna_bsc")
sq_dna_4 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "GTNANN"),
alphabet = "dna_ext")
sq_ami_1 <- sq(c("ACTGCTG", "NIKAAR", "CCCT", "CTGAATGT"),
alphabet = "ami_bsc")
sq_unt <- sq(c("AHSNLVSCTK$SH%&VS", "YQTVKA&#BSKJGY",
"CCCT", "AVYI#VSV&*DVGDJCFA"))
# Comparing sq object with an object of the same length:
sq_dna_1 == sq_dna_2
#> [1] TRUE TRUE TRUE TRUE
sq_dna_1 == c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT")
#> [1] TRUE TRUE TRUE TRUE
# Cannot compare sq objects of different lengths:
if (FALSE) {
sq_dna_1 == sq_dna_3
sq_dna_1 == c("AAA", "CCC")
}
# Unless comparing sq object with scalar value:
sq_dna_1 == "CTTAGA"
#> [1] FALSE TRUE FALSE FALSE
# It's possible to compare basic and extended types:
sq_dna_1 == sq_dna_4
#> [1] TRUE TRUE TRUE FALSE
# Mixing DNA, RNA and amino acid types throws an error, however:
if (FALSE) {
sq_dna_1 == sq_ami_1
}
# On the other hand, unt sq is acceptable everywhere:
sq_dna_1 == sq_unt
#> [1] FALSE FALSE TRUE FALSE
sq_dna_4 == sq_unt
#> [1] FALSE FALSE TRUE FALSE
sq_ami_1 == sq_unt
#> [1] FALSE FALSE TRUE FALSE