[Biopython] Write alignment int he fasta format

Markus Piotrowski Markus.Piotrowski at ruhr-uni-bochum.de
Thu Mar 21 20:32:32 UTC 2019


Dear Ahmad,

Actually I don't know if the PairwiseAligner object has an easy way to 
fetch the two aligned sequences, but you can do:

     aligned_seq1, match_line, aligned_seq2 = 
str(alignments[0])[:-1].split('\n')

And then you write aligned_seq1 and aligned_seq2 to a fasta file using 
SeqIO. Before writing them you need to make them SeqRecords.

Best, Markus


Am 21.03.2019 um 20:41 schrieb Ahmad Khalifa:
> I have :
>
> aligner = PairwiseAligner()
> alignments = aligner.align(chain1, chain2)
>
> how to write alignments[0] as a text file containing the alignment in 
> fasta format. I went through the documentation below, and I'm not 
> really sure I follow. Do I have to save the alignments as text first, 
> then, read it using AlingIO then write it using SeqIO?
>
> http://biopython.org/DIST/docs/api/Bio.AlignIO-module.html
>
> A code snippet would be most helpful.
>
> Regards.
>
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> https://mailman.open-bio.org/mailman/listinfo/biopython

-- 
_________________________________
Dr. Markus Piotrowski
Privatdozent/Akademischer Rat
Lehrstuhl für Molekulare Genetik und Physiologie der Pflanzen
ND 3/49
Universitätsstr. 150
44801 Bochum

Tel. xx49-(0)234-3224290
Fax. xx49-(0)234-3214187

http://www.ruhr-uni-bochum.de/pflaphy/Seiten_dt/PG_Piotrowski_d.html
http://homepage.ruhr-uni-bochum.de/Markus.Piotrowski/Index.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20190321/a5180780/attachment.html>


More information about the Biopython mailing list