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

Peter Cock <[email protected]> Wed, 14 Aug 2024 12:36:22 +0100
Newsgroups gmane.comp.python.bio.general
Message-ID <CAKVJ-_6wRS3FHuXU_5nekpeF7bEKnBEXwAUZEdsQcaCHaR2U_w@mail.gmail.com>
--===============7678433432200539397==
Content-Type: multipart/alternative; boundary="000000000000557db8061fa32333"

--000000000000557db8061fa32333
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=E2=80=AFAM Slowat <[email protected]> wro=
te:

> 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=3DTrue'
> 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 th=
e
> best alignment.
>
> I don't want to loop through all the possible alignments, as this would b=
e
> prohibitively time-consuming for me. Also, since the .score of the best
> alignment can be returned, it makes me think that the best alignment shou=
ld
> 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  -  [email protected]
> https://mailman.open-bio.org/mailman/listinfo/biopython
>

--000000000000557db8061fa32333
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello Slowat,</div><div><br></div><div>Are you clear =
that there can be multiple equally scoring &quot;best&quot; alignments?</di=
v><div>This means the details of how you sort or rank pairwise alignments i=
s</div><div>important (i.e. how to tie-break alignments of the same score) =
and the</div><div>&quot;best&quot; alignment may differ with usage context.=
<br></div><div><br></div><div>Looking at the code in the old pairwise2 modu=
le, using one_alignment_only</div><div>simply returns the first alignment -=
 it wasn&#39;t immediately obvious to me if</div><div>that would automatica=
lly be one of the=C2=A0 top scoring alignments or not.<br></div><div><br></=
div><div>As far as I could see, the new PairwiseAligner docstring doesn&#39=
;t explicitly</div><div>comment on how the alignments returned are sorted e=
ither:<br></div><div><br></div><div><a href=3D"https://github.com/biopython=
/biopython/blob/biopython-184/Bio/Align/__init__.py#L3759">https://github.c=
om/biopython/biopython/blob/biopython-184/Bio/Align/__init__.py#L3759</a></=
div><div><br></div><div>This does need clarification, hopefully Markus or M=
ichiel can comment.<br></div><br><div>Peter<br></div></div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Aug 14, 2024=
 at 11:46=E2=80=AFAM Slowat &lt;<a href=3D"mailto:[email protected]">sl=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex"><div dir=3D"ltr">Hello -=C2=A0<div><br></div><div>May I =
ask. I want to align two sequences, and return, for the optimal alignment o=
nly, the score, number of identities, mismatches, gaps etc.</div><div><br><=
/div><div>I can see that this is possible by using the &#39;one_alignment_o=
nly=3DTrue&#39; parameter in the pairwise2 module, however when I load the =
pairwise2 module, I get the message that this module is deprecated.</div><d=
iv><br></div><div>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 requi=
re about the best alignment.</div><div><br></div><div>I don&#39;t want to l=
oop through all the possible alignments, as this would be prohibitively tim=
e-consuming for me. Also, since the .score of the best alignment can be ret=
urned, 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).</div><div><br></div><div>Could someone explain how to g=
o about this, without using the deprecated pairwise2 module?</div><div><br>=
</div><div>Thanks</div><div>Slowat</div></div>
_______________________________________________<br>
Biopython mailing list=C2=A0 -=C2=A0 <a href=3D"mailto:Biopython@biopython.=
org" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mailman.open-bio.org/mailman/listinfo/biopython" rel=3D"=
noreferrer" target=3D"_blank">https://mailman.open-bio.org/mailman/listinfo=
/biopython</a><br>
</blockquote></div>

--000000000000557db8061fa32333--

--===============7678433432200539397==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Biopython mailing list  -  [email protected]
https://mailman.open-bio.org/mailman/listinfo/biopython

--===============7678433432200539397==--