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

allpy

changeset 615:6e93a74d1917

allpy/structure.py: move superimpose(+fix) and save_pdb to AlignmentMixin move superimpose and save_pdb from BlockMixin to AlignmentMixin fix of superimpose: * add extra_columns parameter (allow columns with gaps or without structure) * add documentation
author boris (kodomo) <bnagaev@gmail.com>
date Fri, 29 Apr 2011 16:04:51 +0400
parents a89409bb4653
children 8cca603d44f5
files allpy/structure.py
diffstat 1 files changed, 47 insertions(+), 35 deletions(-) [+]
line diff
     1.1 --- a/allpy/structure.py	Fri Apr 29 15:43:42 2011 +0400
     1.2 +++ b/allpy/structure.py	Fri Apr 29 16:04:51 2011 +0400
     1.3 @@ -316,6 +316,53 @@
     1.4                  columns.append(column)
     1.5          return columns
     1.6  
     1.7 +    def superimpose(self, gc, extra_columns=False):
     1.8 +        """ Superimpose monomers from this block at gc positions
     1.9 +
    1.10 +         * gc -- collection of columns to use as for superimposition
    1.11 +         * extra_columns -- allow columns with gaps or without structure
    1.12 +        """
    1.13 +        gc = list(gc)
    1.14 +        if len(self.sequences) >= 1:
    1.15 +            sequences = copy(self.sequences)
    1.16 +            main_sequence = sequences.pop()
    1.17 +            for sequence in sequences:
    1.18 +                fixed_gc = []
    1.19 +                moving_gc = []
    1.20 +                for column in gc:
    1.21 +                    if main_sequence in column and sequence in column:
    1.22 +                        if hasattr(column[main_sequence], 'pdb_residue') \
    1.23 +                        and hasattr(column[sequence], 'pdb_residue'):
    1.24 +                            fixed_gc.append(column[main_sequence].pdb_residue['CA'])
    1.25 +                            moving_gc.append(column[sequence].pdb_residue['CA'])
    1.26 +                        else:
    1.27 +                            assert extra_columns
    1.28 +                    else:
    1.29 +                        assert extra_columns
    1.30 +                sup = Superimposer()
    1.31 +                sup.set_atoms(fixed_gc, moving_gc)
    1.32 +                moving = sequence.pdb_chain.get_atoms()
    1.33 +                sup.apply(moving)
    1.34 +
    1.35 +    def save_pdb(self, out_file):
    1.36 +        """ Save all sequences
    1.37 +
    1.38 +        return {sequence: (new_chain, new_model)}
    1.39 +        """
    1.40 +        map = {}
    1.41 +        chains = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    1.42 +        chain_index = -1
    1.43 +        model = 0
    1.44 +        for sequence in self.sequences:
    1.45 +            chain_index += 1
    1.46 +            if chain_index >= len(chains):
    1.47 +                chain_index = 0
    1.48 +                model += 1
    1.49 +            chain = chains[chain_index]
    1.50 +            sequence.save_pdb(out_file, chain, model)
    1.51 +            map[sequence] = (chain, model)
    1.52 +        return map
    1.53 +
    1.54  class BlockMixin(base.Block, AlignmentMixin):
    1.55      """Mixin to add 3D properties to blocks.
    1.56  
    1.57 @@ -576,39 +623,4 @@
    1.58                      result.append(column[sequence])
    1.59          return result
    1.60  
    1.61 -    def superimpose(self, gc):
    1.62 -        """ Superimpose monomers from this block at gc positions """
    1.63 -        gc = list(gc)
    1.64 -        if len(self.sequences) >= 1:
    1.65 -            sequences = copy(self.sequences)
    1.66 -            main_sequence = sequences.pop()
    1.67 -            fixed_gc = [column[main_sequence].pdb_residue['CA'] \
    1.68 -                for column in gc]
    1.69 -            for sequence in sequences:
    1.70 -                moving_gc = [column[sequence].pdb_residue['CA'] \
    1.71 -                    for column in gc]
    1.72 -                sup = Superimposer()
    1.73 -                sup.set_atoms(fixed_gc, moving_gc)
    1.74 -                moving = sequence.pdb_chain.get_atoms()
    1.75 -                sup.apply(moving)
    1.76 -
    1.77 -    def save_pdb(self, out_file):
    1.78 -        """ Save all sequences
    1.79 -
    1.80 -        return {sequence: (new_chain, new_model)}
    1.81 -        """
    1.82 -        map = {}
    1.83 -        chains = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    1.84 -        chain_index = -1
    1.85 -        model = 0
    1.86 -        for sequence in self.sequences:
    1.87 -            chain_index += 1
    1.88 -            if chain_index >= len(chains):
    1.89 -                chain_index = 0
    1.90 -                model += 1
    1.91 -            chain = chains[chain_index]
    1.92 -            sequence.save_pdb(out_file, chain, model)
    1.93 -            map[sequence] = (chain, model)
    1.94 -        return map
    1.95 -
    1.96  # vim: set ts=4 sts=4 sw=4 et: