| Trees | Indices | Help |
|
|---|
|
|
This package implements pairwise sequence alignment using a dynamic
programming algorithm.
This provides functions to get global and local alignments between two
sequences. A global alignment finds the best concordance between all
characters in two sequences. A local alignment finds just the
subsequences that align the best.
When doing alignments, you can specify the match score and gap
penalties. The match score indicates the compatibility between an
alignment of two characters in the sequences. Highly compatible
characters should be given positive scores, and incompatible ones
should be given negative scores or 0. The gap penalties should be
negative.
The names of the alignment functions in this module follow the
convention
<alignment type>XX
where <alignment type> is either "global" or "local" and XX is a 2
character code indicating the parameters it takes. The first
character indicates the parameters for matches (and mismatches), and
the second indicates the parameters for gap penalties.
The match parameters are
CODE DESCRIPTION
x No parameters. Identical characters have score of 1, otherwise 0.
m A match score is the score of identical chars, otherwise mismatch score.
d A dictionary returns the score of any pair of characters.
c A callback function returns scores.
The gap penalty parameters are
CODE DESCRIPTION
x No gap penalties.
s Same open and extend gap penalties for both sequences.
d The sequences have different open and extend gap penalties.
c A callback function returns the gap penalties.
All the different alignment functions are contained in an object
"align". For example:
>>> from Bio import pairwise2
>>> alignments = pairwise2.align.globalxx("ACCGT", "ACG")
will return a list of the alignments between the two strings. The
parameters of the alignment function depends on the function called.
Some examples:
# Find the best global alignment between the two sequences.
# Identical characters are given 1 point. No points are deducted
# for mismatches or gaps.
>>> for a in pairwise2.align.globalxx("ACCGT", "ACG"):
... print format_alignment(*a)
ACCGT
|||||
AC-G-
Score=3
<BLANKLINE>
ACCGT
|||||
A-CG-
Score=3
<BLANKLINE>
# Same thing as before, but with a local alignment.
>>> for a in pairwise2.align.localxx("ACCGT", "ACG"):
... print format_alignment(*a)
ACCGT
||||
AC-G-
Score=3
<BLANKLINE>
ACCGT
||||
A-CG-
Score=3
<BLANKLINE>
# Do a global alignment. Identical characters are given 2 points,
# 1 point is deducted for each non-identical character.
>>> for a in pairwise2.align.globalmx("ACCGT", "ACG", 2, -1):
... print format_alignment(*a)
ACCGT
|||||
AC-G-
Score=6
<BLANKLINE>
ACCGT
|||||
A-CG-
Score=6
<BLANKLINE>
# Same as above, except now 0.5 points are deducted when opening a
# gap, and 0.1 points are deducted when extending it.
>>> for a in pairwise2.align.globalms("ACCGT", "ACG", 2, -1, -.5, -.1):
... print format_alignment(*a)
ACCGT
|||||
AC-G-
Score=5
<BLANKLINE>
ACCGT
|||||
A-CG-
Score=5
<BLANKLINE>
The alignment function can also use known matrices already included in
Biopython ( Bio.SubsMat -> MatrixInfo ).
>>> from Bio.SubsMat import MatrixInfo as matlist
>>> matrix = matlist.blosum62
>>> for a in pairwise2.align.globaldx("KEVLA", "EVL", matrix):
... print format_alignment(*a)
KEVLA
|||||
-EVL-
Score=13
<BLANKLINE>
To see a description of the parameters for a function, please look at
the docstring for the function via the help function, e.g.
type help(pairwise2.align.localds) at the Python prompt.
|
|||
|
identity_match identity_match([match][, mismatch]) -> match_fn |
|||
|
dictionary_match dictionary_match(score_dict[, symmetric]) -> match_fn |
|||
|
affine_penalty affine_penalty(open, extend[, penalize_extend_when_opening]) -> gap_fn |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
string |
|
||
|
|||
|
|||
MAX_ALIGNMENTS = 1000
|
|||
align = align()
|
|||
_PRECISION = 1000
|
|||
|
|||
Print out a matrix. For debugging purposes. |
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Feb 5 17:59:49 2013 | http://epydoc.sourceforge.net |