Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/diff/b92bfa04395e/allpy/base.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 20:17:10 2013
Кодировка:
allpy: allpy/base.py diff

allpy

diff allpy/base.py @ 302:b92bfa04395e

Added method column_at() to base Alignment to aid creation of new columns.
author Daniil Alexeyevsky <me.dendik@gmail.com>
date Thu, 16 Dec 2010 19:05:11 +0300
parents 20636c0df58c
children 578bc81d5e62
line diff
     1.1 --- a/allpy/base.py	Thu Dec 16 18:56:21 2010 +0300
     1.2 +++ b/allpy/base.py	Thu Dec 16 19:05:11 2010 +0300
     1.3 @@ -209,7 +209,7 @@
     1.4          """
     1.5          self.sequences.append(sequence)
     1.6          for i, monomer in enumerate(sequence):
     1.7 -            self.columns[i][sequence] = monomer
     1.8 +            self.column_at(i)[sequence] = monomer
     1.9  
    1.10      def append_gapped_line(self, line, name='', description='', source=''):
    1.11          """Add row from a line of one-letter codes and gaps."""
    1.12 @@ -218,9 +218,18 @@
    1.13          no_gaps = line.replace("-", "")
    1.14          sequence = Sequence(no_gaps, name, description, source)
    1.15          for i, (j, char) in enumerate(filter(not_gap, enumerate(line))):
    1.16 -            self.columns[j][seq] = sequence[i]
    1.17 +            self.column_at(j)[seq] = sequence[i]
    1.18          self.sequences.append(sequence)
    1.19  
    1.20 +    def column_at(self, n):
    1.21 +        """Return column by index. Create required new columns if required.
    1.22 +        
    1.23 +        Do NOT use this method, unless you are sure it is what you want.
    1.24 +        """
    1.25 +        for i in range(len(self.columns), n + 1):
    1.26 +            self.columns.append(Column())
    1.27 +        return self.columns[n]
    1.28 +
    1.29      # Alignment IO methods
    1.30      # ====================
    1.31