Re: [Biopython] Write alignment int he fasta format

Markus Piotrowski <[email protected]>
Newsgroups gmane.comp.python.bio.general
Message-ID <[email protected]>
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  -  [email protected]
> 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

_______________________________________________
Biopython mailing list  -  [email protected]
https://mailman.open-bio.org/mailman/listinfo/biopython
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.