The pairwiseAlignment function of BioStrings claims to return a global alignment if type = "global", but nowhere in the documentation does it say that it trims off the ends of the reported alignment if their are gaps on one side, and thus returns a local alignment of the two sequences. This is a brazen contradiction of the term "global". It also wasted the past several hours of my life trying to track down this bizarre undocumented misuse of the term "global".
algmt <- pairwiseAlignment( s1, s2 , type = "global")
pattern(algmt)
aligned(pattern(algmt))
Neither pattern(algmt) nor aligned(pattern(algmt)) return the global alignment of the two sequences if there are gaps on either/both ends.
This glaring issue has been raised and acknowledged in several previous posts:
obtaining a complete global alignment via pairwiseAlignment
unexpected behaviour of pairwiseAlignment() in Biostrings
unexpected behaviour of pairwiseAlignment() in Biostrings
https://stat.ethz.ch/pipermail/bioconductor/2012-February/043577.html
Why is there not a fix yet? Why is there not a special function or flag that simply returns the true global alignment? Why is this surprise behavior not even mentioned in the documentation over 6 years after it was first reported?
Printing to file with "writePairwiseAlignments" is not helpful if you need these sequences in R, i.e. you want to do further work with these alignments.