Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/5639138f619a
Дата изменения: Unknown
Дата индексирования: Mon Oct 1 23:32:09 2012
Кодировка:
allpy: 5639138f619a

allpy

changeset 379:5639138f619a

Added alignment_type & block_type to both Alignment & Block These are to help in mixins to create new Alignments/Blocks of the same type. Use with care! It is in most cases better to use self.__class__ rather than these attributes. (Or you may lose mixins in the way).
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Tue, 01 Feb 2011 18:36:26 +0300
parents dd94230c6f08
children 7b6907d6d927
files allpy/base.py allpy/dna.py allpy/protein.py allpy/rna.py
diffstat 4 files changed, 31 insertions(+), 8 deletions(-) [+]
line diff
     1.1 --- a/allpy/base.py	Tue Feb 01 17:11:33 2011 +0300
     1.2 +++ b/allpy/base.py	Tue Feb 01 18:36:26 2011 +0300
     1.3 @@ -136,6 +136,14 @@
     1.4  class Alignment(object):
     1.5      """Alignment. It is a list of Columns."""
     1.6  
     1.7 +    alignment_type = None
     1.8 +    """Related Alignment class. SHOULD be redefined when subclassing."""
     1.9 +    # Actually given value at EOF, since name Alignment is not yet defined
    1.10 +
    1.11 +    block_type = None
    1.12 +    """Related Block class. SHOULD be redefined when subclassing."""
    1.13 +    # Actually given value at EOF, since name Block is not yet defined
    1.14 +
    1.15      sequence_type = Sequence
    1.16      """Type of sequences in alignment. SHOULD be redefined when subclassing."""
    1.17  
    1.18 @@ -420,4 +428,7 @@
    1.19          block.columns = columns
    1.20          return block
    1.21  
    1.22 +Alignment.alignment_type = Alignment
    1.23 +Alignment.block_type = Block
    1.24 +
    1.25  # vim: set ts=4 sts=4 sw=4 et:
     2.1 --- a/allpy/dna.py	Tue Feb 01 17:11:33 2011 +0300
     2.2 +++ b/allpy/dna.py	Tue Feb 01 18:36:26 2011 +0300
     2.3 @@ -12,10 +12,14 @@
     2.4  class Sequence(base.Sequence):
     2.5      monomer_type = Monomer
     2.6  
     2.7 -class Alignment(base.Alignment):
     2.8 -    sequence_type = Sequence
     2.9 -
    2.10  class Block(Alignment, base.Block):
    2.11      pass
    2.12  
    2.13 +class Alignment(base.Alignment):
    2.14 +    sequence_type = Sequence
    2.15 +    block_type = Block
    2.16 +    # alignment_type is defined at EOF, since name Alignment undefined yet
    2.17 +
    2.18 +Alignment.alignment_type = Alignment
    2.19 +
    2.20  # vim: set ts=4 sts=4 sw=4 et:
     3.1 --- a/allpy/protein.py	Tue Feb 01 17:11:33 2011 +0300
     3.2 +++ b/allpy/protein.py	Tue Feb 01 18:36:26 2011 +0300
     3.3 @@ -16,8 +16,13 @@
     3.4  class Sequence(base.Sequence):
     3.5      monomer_type = Monomer
     3.6  
     3.7 +class Block(Alignment, base.Block):
     3.8 +    pass
     3.9 +
    3.10  class Alignment(base.Alignment):
    3.11      sequence_type = Sequence
    3.12 +    block_type = Block
    3.13 +    # alignment_type is defined at EOF, since name Alignment undefined yet
    3.14  
    3.15      def muscle_align(self):
    3.16          """ Simple align ths alignment using sequences (muscle)
    3.17 @@ -47,7 +52,6 @@
    3.18                      self.body[sequence].append(old_monomer)
    3.19          os.unlink(tmp_file.name)
    3.20  
    3.21 -class Block(Alignment, base.Block):
    3.22 -    pass
    3.23 +Alignment.alignment_type = Alignment
    3.24  
    3.25  # vim: set ts=4 sts=4 sw=4 et:
     4.1 --- a/allpy/rna.py	Tue Feb 01 17:11:33 2011 +0300
     4.2 +++ b/allpy/rna.py	Tue Feb 01 18:36:26 2011 +0300
     4.3 @@ -12,10 +12,14 @@
     4.4  class Sequence(base.Sequence):
     4.5      monomer_type = Monomer
     4.6  
     4.7 -class Alignment(base.Alignment):
     4.8 -    sequence_type = Sequence
     4.9 -
    4.10  class Block(Alignment, base.Block):
    4.11      pass
    4.12  
    4.13 +class Alignment(base.Alignment):
    4.14 +    sequence_type = Sequence
    4.15 +    block_type = Block
    4.16 +    # alignment_type is defined at EOF, since name Alignment undefined yet
    4.17 +
    4.18 +Alignment.alignment_type = Alignment
    4.19 +
    4.20  # vim: set ts=4 sts=4 sw=4 et: