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

def Bio::Align::AlignInfo::SummaryInfo::dumb_consensus (   self,
  threshold = .7,
  ambiguous = "N",
  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).

Definition at line 41 of file AlignInfo.py.

                                                                    :
        """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).
        """
        consensus = ''

        # find the length of the consensus we are creating
        con_len = self.alignment.get_alignment_length()

        # go through each seq item
        for n in range(con_len):
            # keep track of the counts of the different atoms we get
            atom_dict = {}
            num_atoms = 0

            for record in self.alignment._records:
                # make sure we haven't run past the end of any sequences
                # if they are of different lengths
                if n < len(record.seq):
                    if record.seq[n] != '-' and record.seq[n] != '.':
                        if record.seq[n] not in atom_dict.keys():
                            atom_dict[record.seq[n]] = 1
                        else:
                            atom_dict[record.seq[n]] = \
                              atom_dict[record.seq[n]] + 1

                        num_atoms = num_atoms + 1

            max_atoms = []
            max_size = 0

            for atom in atom_dict.keys():
                if atom_dict[atom] > max_size:
                    max_atoms = [atom]
                    max_size = atom_dict[atom]
                elif atom_dict[atom] == max_size:
                    max_atoms.append(atom)

            if require_multiple and num_atoms == 1:
                consensus = consensus + ambiguous
            elif (len(max_atoms) == 1) and ((float(max_size)/float(num_atoms))
                                         >= threshold):
                consensus = consensus + max_atoms[0]
            else:
                consensus = consensus + ambiguous

        # we need to guess a consensus alphabet if one isn't specified
        if consensus_alpha is None:
            consensus_alpha = self._guess_consensus_alphabet()

        return Seq(consensus, consensus_alpha)

    def gap_consensus(self, threshold = .7, ambiguous = "N",


Generated by  Doxygen 1.6.0   Back to index