[Biopython] Bio.pairwise2

Kristian Ullrich kristian_ullrich at yahoo.de
Wed Mar 22 12:22:43 EDT 2023


Hi Vitoria,
for me this works in python3 and also will return the initial IDs:
__Note__ that their are two possible alignments generated.
```python

from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from io import StringIO
from Bio.Align import PairwiseAlignment


a = SeqRecord(Seq("GAACT"), id="a")
b = SeqRecord(Seq("GAT"), id="b")

aligner = Align.PairwiseAligner()
alignments = aligner.align(a, b)

for align_idx, align in enumerate(alignments):
    for record in SeqIO.parse(StringIO(format(align, "fasta")), "fasta"):
        print (align_idx)
        print(record)
```
Best regards
Kristian

   Am Dienstag, 21. März 2023 um 22:41:58 MEZ hat Vitoria Zanon <zanon.vih at gmail.com> Folgendes geschrieben:  
 
 Hello! I hope this email finds you well.
My name is Vitoria and I'm currently using Biopython to develop a new multiple sequence alignment tool as my PhD project, specially the Bio.pairwise2 method, which is the main reason I'm writing this email: the deprecated warning told me I should talk to you about this.
In my code, the pairwise2 method helps produce an alignment library which contains (n²-n)/2 pairwise alignments, being n the number of sequences in the input file. This library helps the COFFEE objective function (NOTREDAME et al., 1998) to evaluate the MSAs produced by the tool. I was using the Bio.Align.PairwiseAlignment method but I faced an issue with it: I couldn't get the aligned sequences from the PairwiseAlignment object as a Seq object, String or neither a SeqRecord object. The library should keep the name of the sequences, the sequences itself and the alignment score, but all I was able to do is to get the target/query sequences (unaligned) or the Align object itself, which wouldn't work for me. However with pairwise2 i was able to get the sequences and work with them as i planned to. I must admit the PairwiseAlignment has a more intuitive and useful class structure and I already thought about using it in other projects from our lab, but it doesn't work for this specific project in specific. I'm also sending a print from my code to illustrate the pairwise2 use.
Therefore, I would like you to consider adding this feature in PairwiseAlignment or as a different method since you discontinued pairwise2. By now, my main objective is to finish the whole tool and test its results so I can get data about the performance of the new algorithm I'm proposing. After that I plan to make the tool available on the internet and I want to work with the latest releases from each library involved so it can work fine in any machine and improve its execution when the libraries themselves get improved.
Thank you for reading!
Sincerely yours, Vitoria_______________________________________________
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/20230322/f173a4da/attachment.htm>


More information about the Biopython mailing list