In "Edit distance alignment1" we introduced the concept of an alignment of two genetic strings having differing lengths with respect to edit distance. This provided us with a way of visualizing a specific collection of symbol substitutions, insertions, and deletions that could have taken place on the evolutionary path between the two strings.
However, simply finding one optimal alignment and declaring that it represents a true evolutionary history is a dangerous idea because the actual evolutionary picture may be suboptimal. For that matter, the collection of all optimal alignments may be huge, and the characteristics of these alignments could differ widely.
In order to begin analyzing the collection of optimal alignments for a
pair of strings, the first question we will ask is simple: just how many
optimal alignments exist?
Recall from "Edit distance alignment2" that if
As a result, we obtain
Write a function optimalAlignments that takes two protein
strings
In the following interactive session, we assume the FASTA file data.faa3 to be located in the current directory.
>>> optimalAlignments('PLEASANTLY', 'MEANLY') 4 >>> from Bio import SeqIO >>> optimalAlignments(*SeqIO.parse('data.faa', 'fasta')) 4