gravatar for tommaso.green

3 hours ago by

Hi,

I'm trying to make several pairwise global alignments using biopython Pairwise Aligner. I'd like to store my results in a phylip format so that I can use the output to build a phylogenetic tree using Phylip. The problem is that I can't seem to be able to write my alignments using AlignIO package, the write function probably doesn't want my PairwiseAlignment object. The error I get is "object of type 'PairwiseAlignment' has no len()". What can I do? Thank you for your time.

from Bio import SeqIO, AlignIO, Align
from itertools import combinations


cov_sequences = list(SeqIO.parse("gisaid_cov2020_sequences.fasta", "fasta"))
combos = list(combinations(cov_sequences, 2))
aligner = Align.PairwiseAligner()
alignments = aligner.align(combos[0][0].seq, combos[0][1].seq)
with open("alignments.phy", "w") as handle:
    AlignIO.write(alignments, handle, "phylip")
print(alignments)



Source link