Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/20636c0df58c
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:15:15 2012
Кодировка:
allpy: 20636c0df58c

allpy

changeset 301:20636c0df58c

Removed controversial methods of allpy.base.Alignment: length, height, identity
author Daniil Alexeyevsky <me.dendik@gmail.com>
date Thu, 16 Dec 2010 18:56:21 +0300
parents 5d355141f37d
children b92bfa04395e
files allpy/base.py
diffstat 1 files changed, 2 insertions(+), 49 deletions(-) [+]
line diff
     1.1 --- a/allpy/base.py	Thu Dec 16 18:55:01 2010 +0300
     1.2 +++ b/allpy/base.py	Thu Dec 16 18:56:21 2010 +0300
     1.3 @@ -306,55 +306,6 @@
     1.4              columns.append(col)
     1.5          return columns
     1.6  
     1.7 -    ## Unclean code follows
     1.8 -
     1.9 -    def length(self):
    1.10 -        """Return width, ie length of each sequence with gaps."""
    1.11 -        return max([len(line) for line in self.body.values()])
    1.12 -
    1.13 -    def height(self):
    1.14 -        """ The number of sequences in alignment (it's thickness). """
    1.15 -        return len(self.body)
    1.16 -
    1.17 -    def identity(self):
    1.18 -        """ Calculate the identity of alignment positions for colouring.
    1.19 -
    1.20 -        For every (row, column) in alignment the percentage of the exactly
    1.21 -        same residue in the same column in the alignment is calculated.
    1.22 -        The data structure is just like the Alignment.body, but istead of
    1.23 -        monomers it contains float percentages.
    1.24 -        """
    1.25 -        # Oh, God, that's awful! Absolutely not understandable.
    1.26 -        # First, calculate percentages of amino acids in every column
    1.27 -        contribution = 1.0 / len(self.sequences)
    1.28 -        all_columns = []
    1.29 -        for position in range(len(self)):
    1.30 -            column_percentage = {}
    1.31 -            for seq in self.body:
    1.32 -                if self.body[seq][position] is not None:
    1.33 -                    aa = self.body[seq][position].code
    1.34 -                else:
    1.35 -                    aa = None
    1.36 -                if aa in allpy.data.amino_acids:
    1.37 -                    if aa in column_percentage.keys():
    1.38 -                        column_percentage[aa] += contribution
    1.39 -                    else:
    1.40 -                        column_percentage[aa] = contribution
    1.41 -            all_columns.append(column_percentage)
    1.42 -        # Second, map these percentages onto the alignment
    1.43 -        self.identity_percentages = {}
    1.44 -        for seq in self.sequences:
    1.45 -            self.identity_percentages[seq] = []
    1.46 -        for seq in self.identity_percentages:
    1.47 -            line = self.identity_percentages[seq]
    1.48 -            for position in range(len(self)):
    1.49 -                if self.body[seq][position] is not None:
    1.50 -                    aa = self.body[seq][position].code
    1.51 -                else:
    1.52 -                    aa = None
    1.53 -                line.append(all_columns[position].get(aa))
    1.54 -        return self.identity_percentages
    1.55 -
    1.56  class Column(dict):
    1.57      """Column of alignment.
    1.58  
    1.59 @@ -365,6 +316,8 @@
    1.60      """
    1.61      pass
    1.62  
    1.63 +    ## Unclean code follows
    1.64 +
    1.65  class Block(object):
    1.66      """ Block of alignment
    1.67