Package Bio :: Module pairwise2
[show private | hide private]
[frames | no frames]

Module Bio.pairwise2

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:
>>> pairwise2.align.globalxx("ACCGT", "ACG")
# Find the best global alignment between the two sequences.
    # Identical characters are given 1 point.  No points are deducted
    # for mismatches or gaps.
>>> pairwise2.align.localxx("ACCGT", "ACG")
# Same thing as before, but with a local alignment.
>>> pairwise2.align.globalmx("ACCGT", "ACG", 2, -1)
# Do a global alignment.  Identical characters are given 2 points,
    # 1 point is deducted for each non-identical character.
>>> pairwise2.align.globalms("ACCGT", "ACG", 2, -1, -.5, -.1)
# Same as above, except now 0.5 points are deducted when opening a
    # gap, and 0.1 points are deducted when extending it.
To see a description of the parameters for a function, please look at the docstring for the function.
>>> print newalign.align.localds.__doc__
localds(sequenceA, sequenceB, match_dict, open, extend) -> alignments

Classes
affine_penalty affine_penalty(open, extend[, penalize_extend_when_opening]) -> gap_fn
dictionary_match dictionary_match(score_dict[, symmetric]) -> match_fn
identity_match identity_match([match][, mismatch]) -> match_fn

Function Summary
  calc_affine_penalty(length, open, extend, penalize_extend_when_opening)
  format_alignment(align1, align2, score, begin, end)
format_alignment(align1, align2, score, begin, end) -> string
  print_matrix(matrix)
print_matrix(matrix)
  rint(x, precision)

Variable Summary
align align = <Bio.pairwise2.align instance at 0x2aaaae701290>

Function Details

format_alignment(align1, align2, score, begin, end)

format_alignment(align1, align2, score, begin, end) -> string

Format the alignment prettily into a string.

print_matrix(matrix)

print_matrix(matrix)

Print out a matrix. For debugging purposes.

Variable Details

align

Type:
align
Value:
<Bio.pairwise2.align instance at 0x2aaaae701290>                       

Generated by Epydoc 2.1 on Thu Jun 30 22:06:10 2005 http://epydoc.sf.net