Entering edit mode
3 months ago
Tom
▴
50
I am using Bio.Align to do a pairwise alignment between two sequences. I want to know the pairwise alignment percent identity and pairwise alignment percent similarity, but I can't seem to find where they are stored in the pairwise alignment object, and I can't see them nentioned on the Bio.Align page here here.
It is possible to return that information from the AlignIO object?
The code I have so far is:
global_aligner = Align.PairwiseAligner(mode='global',substitution_matrix=substitution_matrices.load('PAM30'))
aln_scores = []
for alignment in global_aligner.align(seq1,seq2):
aln_scores.append(alignment.score)
..and then here I want to calculate alignment.percent_identity/similarity
I'm not aware of a native solution for this. The is an alignment score that you can access, but that would be based on the matrix.
It would be fairly easy to code these though and solutions exist online. See for example this answer: https://stackoverflow.com/a/39146531
This link (https://upstemacademy.com/courses/biopython-fundamentals/lesson/calculation-of-sequence-similarity-and-identity/) might also help. It builds on pairwise2 which was essentially the predecessor of the current Aligner module.