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

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

allpy

changeset 474:d3d73a144095

pdb: export to pdb exports empty file
author boris <bnagaev@gmail.com>
date Fri, 18 Feb 2011 01:03:21 +0300
parents d3c7e08058c2
children c30ddd85fcc5
files allpy/structure.py geometrical_core/geometrical-core
diffstat 2 files changed, 25 insertions(+), 33 deletions(-) [+]
line diff
     1.1 --- a/allpy/structure.py	Thu Feb 17 18:35:59 2011 +0300
     1.2 +++ b/allpy/structure.py	Fri Feb 18 01:03:21 2011 +0300
     1.3 @@ -11,8 +11,10 @@
     1.4  import os.path
     1.5  from tempfile import NamedTemporaryFile
     1.6  import urllib2
     1.7 +from copy import copy
     1.8  
     1.9  from Bio.PDB import PDBParser
    1.10 +from Bio.PDB import Select
    1.11  from Bio.PDB import Superimposer, CaPPBuilder, PDBIO
    1.12  from Bio.PDB.DSSP import make_dssp_dict
    1.13  
    1.14 @@ -134,16 +136,16 @@
    1.15          self.set_pdb_chain(open(path), code, chain, model)
    1.16          return True
    1.17  
    1.18 -    def pdb_save(self, out_filename, pdb_chain):
    1.19 +    def save_pdb(self, out_filename):
    1.20          """ Saves pdb_chain to out_file """
    1.21          class MySelect(Select):
    1.22 -            def accept_chain(self, chain):
    1.23 -                if chain == pdb_chain:
    1.24 +            def accept_chain(myselect, residue):
    1.25 +                if residue.get_parent() == self.pdb_chain:
    1.26                      return 1
    1.27                  else:
    1.28                      return 0
    1.29          io = PDBIO()
    1.30 -        structure = chain.get_parent()
    1.31 +        structure = self.pdb_chain.get_parent()
    1.32          io.set_structure(structure)
    1.33          io.save(out_filename, MySelect())
    1.34  
    1.35 @@ -235,40 +237,25 @@
    1.36              else:
    1.37                  yield None
    1.38  
    1.39 -    def superimpose(self):
    1.40 -        """ Superimpose all pdb_chains in this block """
    1.41 +    def superimpose(self, gc):
    1.42 +        """ Superimpose monomers from this block at gc positions """
    1.43 +        gc = list(gc)
    1.44          if len(self.sequences) >= 1:
    1.45              sequences = copy(self.sequences)
    1.46 -            sup = Superimposer()
    1.47              main_sequence = sequences.pop()
    1.48 -            fixed_and_gaps = self.ca_atoms(main_sequence)
    1.49 +            fixed_gc = [main_sequence.pdb_residues[column[main_sequence]]['CA'] \
    1.50 +                for column in gc]
    1.51              for sequence in sequences:
    1.52 -                moving_and_gaps = self.ca_atoms(sequence)
    1.53 -                fixed = []
    1.54 -                moving = []
    1.55 -                for f, m in zip(fixed_atoms_gaps, moving_and_gaps):
    1.56 -                    if f and m:
    1.57 -                        fixed.append(f)
    1.58 -                        moving.append(m)
    1.59 -                sup.set_atoms(fixed, moving)
    1.60 -                # Apply rotation/translation to the moving atoms
    1.61 +                moving_gc = [sequence.pdb_residues[column[sequence]]['CA'] \
    1.62 +                    for column in gc]
    1.63 +                sup = Superimposer()
    1.64 +                sup.set_atoms(fixed_gc, moving_gc)
    1.65 +                moving = filter(None, self.ca_atoms(sequence))
    1.66                  sup.apply(moving)
    1.67  
    1.68 -    def pdb_save(self, out_file):
    1.69 -        """ Save all sequences
    1.70 -
    1.71 -        Returns {(sequence, chain): CHAIN}
    1.72 -        CHAIN is chain letter in new file
    1.73 -        """
    1.74 -        tmp_file = NamedTemporaryFile(delete=False)
    1.75 -        tmp_file.close()
    1.76 -
    1.77 -        for sequence, chain in self.sequences_chains():
    1.78 -            sequence.pdb_save(tmp_file.name, chain)
    1.79 -            # TODO: read from tmp_file.name
    1.80 -            # change CHAIN
    1.81 -            # add to out_file
    1.82 -
    1.83 -        os.unlink(tmp_file)
    1.84 +    def save_pdb(self, out_file):
    1.85 +        """ Save all sequences """
    1.86 +        for sequence in self.sequences:
    1.87 +            sequence.save_pdb(out_file)
    1.88  
    1.89  # vim: set ts=4 sts=4 sw=4 et:
     2.1 --- a/geometrical_core/geometrical-core	Thu Feb 17 18:35:59 2011 +0300
     2.2 +++ b/geometrical_core/geometrical-core	Fri Feb 18 01:03:21 2011 +0300
     2.3 @@ -170,6 +170,11 @@
     2.4              io.save_string(string, name, description)
     2.5          m.clear()
     2.6  
     2.7 +if args.p:
     2.8 +    gc = GCs[args.x]
     2.9 +    block.superimpose(gc)
    2.10 +    block.save_pdb(args.p)
    2.11 +
    2.12  if tmp_file:
    2.13      os.unlink(tmp_file.name)
    2.14