Bioconductor / Biostrings

Efficient manipulation of biological strings
https://bioconductor.org/packages/Biostrings
57 stars 16 forks source link

alignedPattern and @pattern have different returns #92

Closed Close-your-eyes closed 7 months ago

Close-your-eyes commented 1 year ago

With the alignment below alignedPattern(aln) and aln@pattern return different strings. Is that desired?

aln <- Biostrings::pairwiseAlignment("CCGGATCG", "ATCG", type = "global-local")

Global-Local PairwiseAlignmentsSingleSubject (1 of 1)
pattern:     CCGGATCG
subject: [1] ----ATCG
score: -18.07298 

as.character(Biostrings::alignedPattern(aln))
"CCGGATCG"

as.character(aln@pattern)
"ATCG"
hpages commented 7 months ago

That is how things are stored inside the object. But with S4 objects, you're not supposed to look at the content of their slots because that's ultimately internal business. So instead of doing direct slot access with @, you should always use accessor functions like alignedPattern() and alignedSubject(). This is a strong principle for all S4 object manipulation in Bioconductor.