Package Bio :: Package Align :: Module AlignInfo :: Class SummaryInfo
[show private | hide private]
[frames | no frames]

Class SummaryInfo


Calculate summary info about the alignment.

This class should be used to caclculate information summarizing the results of an alignment. This may either be straight consensus info or more complicated things.
Method Summary
  __init__(self, alignment)
Initialize with the alignment to calculate information on.
  dumb_consensus(self, threshold, ambiguous, consensus_alpha, require_multiple)
Output a fast consensus sequence of the alignment.
  gap_consensus(self, threshold, ambiguous, consensus_alpha, require_multiple)
Same as dumb_consensus(), but allows gap on the output.
  get_column(self, col)
  information_content(self, start, end, e_freq_table, log_base, chars_to_ignore)
Calculate the information content for each residue along an alignment.
  pos_specific_score_matrix(self, axis_seq, chars_to_ignore)
Create a position specific score matrix object for the alignment.
  replacement_dictionary(self, skip_chars)
Generate a replacement dictionary to plug into a substitution matrix

Method Details

__init__(self, alignment)
(Constructor)

Initialize with the alignment to calculate information on. ic_vector attribute. A dictionary. Keys: column numbers. Values:

dumb_consensus(self, threshold=0.69999999999999996, ambiguous='X', consensus_alpha=None, require_multiple=0)

Output a fast consensus sequence of the alignment.

This doesn't do anything fancy at all. It will just go through the sequence residue by residue and count up the number of each type of residue (ie. A or G or T or C for DNA) in all sequences in the alignment. If the percentage of the most common residue type is greater then the passed threshold, then we will add that residue type, otherwise an ambiguous character will be added.

This could be made a lot fancier (ie. to take a substitution matrix into account), but it just meant for a quick and dirty consensus.

Arguments: o threshold - The threshold value that is required to add a particular atom. o ambiguous - The ambiguous character to be added when the threshold is not reached. o consensus_alpha - The alphabet to return for the consensus sequence. If this is None, then we will try to guess the alphabet. o require_multiple - If set as 1, this will require that more than 1 sequence be part of an alignment to put it in the consensus (ie. not just 1 sequence and gaps).

gap_consensus(self, threshold=0.69999999999999996, ambiguous='X', consensus_alpha=None, require_multiple=0)

Same as dumb_consensus(), but allows gap on the output.

Things to do: Let the user define that with only one gap, the result character in consensus is gap. Let the user select gap character, now it takes the same is input.

information_content(self, start=0, end=None, e_freq_table=None, log_base=2, chars_to_ignore=[])

Calculate the information content for each residue along an alignment.

Arguments: o start, end - The starting an ending points to calculate the information content. These points should be relative to the first sequence in the alignment, starting at zero (ie. even if the 'real' first position in the seq is 203 in the initial sequence, for the info content, we need to use zero). This defaults to the entire length of the first sequence. o e_freq_table - A FreqTable object specifying the expected frequencies for each letter in the alphabet we are using (ie. {'G' : 0.4, 'C' : 0.4, 'T' : 0.1, 'A' : 0.1}). Gap characters should not be included, since these should not have expected frequencies. o log_base - The base of the logathrim to use in calculating the information content. This defaults to 2 so the info is in bits. o chars_to_ignore - A listing of characterw which should be ignored in calculating the info content.

Returns: o A number representing the info content for the specified region.

Please see the Biopython manual for more information on how information content is calculated.

pos_specific_score_matrix(self, axis_seq=None, chars_to_ignore=[])

Create a position specific score matrix object for the alignment.

This creates a position specific score matrix (pssm) which is an alternative method to look at a consensus sequence.

Arguments: o chars_to_ignore - A listing of all characters not to include in the pssm. By default, gap characters will be excluded. o axis_seq - An optional argument specifying the sequence to put on the axis of the PSSM. This should be a Seq object. If nothing is specified, the consensus sequence, calculated with default parameters, will be used.

Returns: o A PSSM (position specific score matrix) object.

replacement_dictionary(self, skip_chars=[])

Generate a replacement dictionary to plug into a substitution matrix

This should look at an alignment, and be able to generate the number of substitutions of different residues for each other in the aligned object.

Will then return a dictionary with this information: {('A', 'C') : 10, ('C', 'A') : 12, ('G', 'C') : 15 ....}

This also treats weighted sequences. The following example shows how we calculate the replacement dictionary. Given the following multiple sequence alignments:

GTATC 0.5 AT--C 0.8 CTGTC 1.0

For the first column we have: ('A', 'G') : 0.5 * 0.8 = 0.4 ('C', 'G') : 0.5 * 1.0 = 0.5 ('A', 'C') : 0.8 * 1.0 = 0.8

We then continue this for all of the columns in the alignment, summing the information for each substitution in each column, until we end up with the replacement dictionary.

Arguments: o skip_chars - A list of characters to skip when creating the dictionary. For instance, you might have Xs (screened stuff) or Ns, and not want to include the ambiguity characters in the dictionary.

Generated by Epydoc 2.1 on Sat Jul 16 15:48:58 2005 http://epydoc.sf.net