Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::Align::AlignInfo::SummaryInfo::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.

Definition at line 335 of file AlignInfo.py.

                                                       :
        """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.
        """
        # determine all of the letters we have to deal with
        all_letters = self.alignment._alphabet.letters

        # if we have a gap char, add it to stuff to ignore
        if isinstance(self.alignment._alphabet, Alphabet.Gapped):
            chars_to_ignore.append(self.alignment._alphabet.gap_char)
        
        for char in chars_to_ignore:
            all_letters = string.replace(all_letters, char, '')

        if axis_seq:
            left_seq = axis_seq
        else:
            left_seq = self.dumb_consensus()

        pssm_info = []
        # now start looping through all of the sequences and getting info
        for residue_num in range(len(left_seq)):
            score_dict = self._get_base_letters(all_letters)
            for record in self.alignment._records:
                try:
                    this_residue = record.seq[residue_num]
                # if we hit an index error we've run out of sequence and
                # should not add new residues
                except IndexError:
                    this_residue = None
                    
                if this_residue and this_residue not in chars_to_ignore:
                    try:
                        score_dict[this_residue] = score_dict[this_residue] + \
                          record.annotations['weight']
                        
                    # if we get a KeyError then we have an alphabet problem
                    except KeyError:
                        raise ValueError("Residue %s not found in alphabet %s"
                                     % (this_residue,
                                        self.alignment._alphabet))

            pssm_info.append((left_seq[residue_num],
                              score_dict))


        return PSSM(pssm_info)
                    
    def _get_base_letters(self, letters):


Generated by  Doxygen 1.6.0   Back to index