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.seq, combos.seq) with open("alignments.phy", "w") as handle: AlignIO.write(alignments, handle, "phylip") print(alignments)