Entering edit mode
9.5 years ago
mbk0asis
▴
700
Hello!
Would somebody tell me how to save "pairwise2" result to a file instead of being printed on screen.
>>> from Bio.pairwise2 import format_alignment
>>> for a in pairwise2.align.globalxx("ACCGT", "ACG"):
... print(format_alignment(*a))
Thank you!
Thank you!
I'm not sure it was your code or not, but I took a code from this site and your answer and put them together.
Here's the code:
and Result:
Instead of DNA sequences, something else were aligned.
Would you please look into it?
Thank you, again!
Not sure what you've done wrong here (which version of Python was it?), but you should open the file outside both the for loops. As it is, it will restart a new output file for each pair of sequences, overwriting the alignments from past pairs of sequences.
It's Python 2.7.6 on Ubuntu 14.04.
Thanks!
Oops! I saved the files as plain txt files. After I added '>seq name' at the top, it worked. Thank you, Peter!
Another problem occurred!
'local' alignment gave me 'global' alignment results.
seq.fa
andprimer.fa
areModified code is
and results are
This is not an answer to the original question - it's a revised question, or even a new question.
OK. I will ask again in a new post. Thanks.