[BioPython] Smith Waterman

Bill Barnard bill at barnard-engineering.com
Fri Sep 30 02:25:54 EDT 2005


On Thu, 2005-09-29 at 13:34 -0700, James Stroud wrote:

> But I'm not sure where the Blosum Matrix is in the biopython API. Any 
> suggestions? A code snippet would be a lot of help.

I'm just getting going on some sequence alignment code myself, exploring
what's in biopython. Anyway you'll find the matrices you're looking for
like so:

from Bio import SubsMat
from Bio.SubsMat import MatrixInfo
from Bio.pairwise2 import dictionary_match
blosum50 = dictionary_match(SubsMat.SeqMat(MatrixInfo.blosum50))

This gives you a dictionary interface to which you can pass two
characters and get back the Blosum50 score, e.g.

blosum50('A', 'P') returns: -1

Your characters need to be uppercase, and they need to part of the set
in the substitution matrix or you'll throw an exception.

There are other ways to access the Blosum matrices, but this one seemed
pretty nice to me.

Cheers,

Bill
-- 
Bill Barnard <bill at barnard-engineering.com>


More information about the BioPython mailing list