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

Поисковые слова: m 8
allpy: e0f503388c0e

allpy

changeset 559:e0f503388c0e

structure: move column2pos to separate function structure.BlockMixin is now descendant of structure.AlignmentMixin to share this method to BlocksMixin
author boris (kodomo) <bnagaev@gmail.com>
date Wed, 16 Mar 2011 21:34:06 +0300
parents c41ab8b8d4a0
children 9bec9da5982e
files allpy/structure.py blocks3d/blocks3d.py
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/allpy/structure.py	Wed Mar 16 20:09:19 2011 +0300
     1.2 +++ b/allpy/structure.py	Wed Mar 16 21:34:06 2011 +0300
     1.3 @@ -148,7 +148,6 @@
     1.4          self.pdb_chain.id = old_chain
     1.5          model.id = old_model
     1.6  
     1.7 -
     1.8  class AlignmentMixin(base.Alignment):
     1.9      """Mixin to add 3D properties to alignments.
    1.10  
    1.11 @@ -156,9 +155,15 @@
    1.12      created. This class is intended to be subclassed together with one of
    1.13      Alignment classes.
    1.14      """
    1.15 -    pass
    1.16  
    1.17 -class BlockMixin(base.Block):
    1.18 +    def column2pos(self):
    1.19 +        """ Return {column: pos_n} """
    1.20 +        c2p = {}
    1.21 +        for i, column in enumerate(self.columns):
    1.22 +            c2p[column] = i
    1.23 +        return c2p
    1.24 +
    1.25 +class BlockMixin(base.Block, base.AlignmentMixin):
    1.26      """Mixin to add 3D properties to blocks.
    1.27  
    1.28      Please note: since this is a mixin, no objects of this class should be
    1.29 @@ -238,9 +243,7 @@
    1.30  
    1.31          part is block
    1.32          """
    1.33 -        column2pos = {}
    1.34 -        for i, column in enumerate(self.columns):
    1.35 -            column2pos[column] = i
    1.36 +        column2pos = self.column2pos()
    1.37          parts = []
    1.38          for i, seq1 in enumerate(self.sequences):
    1.39              for j, seq2 in enumerate(self.sequences):
    1.40 @@ -271,9 +274,7 @@
    1.41          """
    1.42          result = []
    1.43          # for sorting
    1.44 -        column2pos = {}
    1.45 -        for i, column in enumerate(self.columns):
    1.46 -            column2pos[column] = i
    1.47 +        column2pos = self.column2pos()
    1.48          sequence2i = {}
    1.49          for i, sequence in enumerate(self.sequences):
    1.50              sequence2i[sequence] = i
    1.51 @@ -291,7 +292,8 @@
    1.52              boundaries.add(part.columns[0])
    1.53              boundaries.add(part.columns[-1])
    1.54          for part in parts:
    1.55 -            part.columns = sorted(set(part.columns) & boundaries, key=column2pos.get)
    1.56 +            part.columns = sorted(set(part.columns) & boundaries,
    1.57 +                key=column2pos.get)
    1.58              monomers = part.monomers()
    1.59              for m1 in monomers:
    1.60                  for m2 in monomers:
     2.1 --- a/blocks3d/blocks3d.py	Wed Mar 16 20:09:19 2011 +0300
     2.2 +++ b/blocks3d/blocks3d.py	Wed Mar 16 21:34:06 2011 +0300
     2.3 @@ -56,9 +56,7 @@
     2.4      timeout=args.t, timeout_2=args.T,
     2.5      min_width=args.m))
     2.6  
     2.7 -column2pos = {}
     2.8 -for i, column in enumerate(block.columns):
     2.9 -    column2pos[column] = i
    2.10 +column2pos = alignment.column2pos()
    2.11  
    2.12  if args.H:
    2.13      # html-file