[Biopython] How to only extract the best alignment without looping with Bio.Align

Peter Cock p.j.a.cock at googlemail.com
Wed Aug 14 07:36:22 EDT 2024


Hello Slowat,

Are you clear that there can be multiple equally scoring "best" alignments?
This means the details of how you sort or rank pairwise alignments is
important (i.e. how to tie-break alignments of the same score) and the
"best" alignment may differ with usage context.

Looking at the code in the old pairwise2 module, using one_alignment_only
simply returns the first alignment - it wasn't immediately obvious to me if
that would automatically be one of the  top scoring alignments or not.

As far as I could see, the new PairwiseAligner docstring doesn't explicitly
comment on how the alignments returned are sorted either:

https://github.com/biopython/biopython/blob/biopython-184/Bio/Align/__init__.py#L3759

This does need clarification, hopefully Markus or Michiel can comment.

Peter

On Wed, Aug 14, 2024 at 11:46 AM Slowat <slowat0kela at gmail.com> wrote:

> Hello -
>
> May I ask. I want to align two sequences, and return, for the optimal
> alignment only, the score, number of identities, mismatches, gaps etc.
>
> I can see that this is possible by using the 'one_alignment_only=True'
> parameter in the pairwise2 module, however when I load the pairwise2
> module, I get the message that this module is deprecated.
>
> Using Bio.Align, I can see how you can obtain the .score for the best
> alignment, but not how to obtain the other information I require about the
> best alignment.
>
> I don't want to loop through all the possible alignments, as this would be
> prohibitively time-consuming for me. Also, since the .score of the best
> alignment can be returned, it makes me think that the best alignment should
> be saved somewhere and I should be able to see it (even to calculate the
> gaps, identities and mismatches myself).
>
> Could someone explain how to go about this, without using the deprecated
> pairwise2 module?
>
> Thanks
> Slowat
> _______________________________________________
> Biopython mailing list  -  Biopython at biopython.org
> https://mailman.open-bio.org/mailman/listinfo/biopython
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20240814/e5125c61/attachment.htm>


More information about the Biopython mailing list