allpy
changeset 582:c3bae0fb3cb1
structure.py: opportunity not to store entire pdb info, xyz only
author | boris (kodomo) <bnagaev@gmail.com> |
---|---|
date | Fri, 25 Mar 2011 23:12:21 +0300 |
parents | c535894a545b |
children | 8595d78732e7 |
files | allpy/structure.py |
diffstat | 1 files changed, 12 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/allpy/structure.py Fri Mar 25 23:09:58 2011 +0300 1.2 +++ b/allpy/structure.py Fri Mar 25 23:12:21 2011 +0300 1.3 @@ -59,13 +59,13 @@ 1.4 1.5 * pdb_chain -- Bio.PDB.Chain 1.6 1.7 - Monomers from this sequence get attribute "pdb_residue" 1.8 + Monomers from this sequence get attribute "pdb_residue", "ca_xyz" 1.9 1.10 ?TODO: global pdb_structures 1.11 """ 1.12 1.13 def set_pdb_chain(self, pdb_file, pdb_id, pdb_chain='A', pdb_model=0, 1.14 - max_mutations=config.max_mutations): 1.15 + max_mutations=config.max_mutations, xyz_only=False): 1.16 """ Read Pdb chain from file 1.17 1.18 max_mutations -- max number of monomer type mismatches 1.19 @@ -75,7 +75,8 @@ 1.20 """ 1.21 structure = get_structure(pdb_file, self.name) 1.22 chain = structure[pdb_model][pdb_chain] 1.23 - self.pdb_chain = chain 1.24 + if not xyz_only: 1.25 + self.pdb_chain = chain 1.26 pdb_sequence = self.__class__.from_pdb_chain(chain) 1.27 Alignment = self.types.Alignment 1.28 a = Alignment() 1.29 @@ -86,7 +87,9 @@ 1.30 for monomer, pdb_monomer in a.columns_as_lists(): 1.31 if monomer and hasattr(pdb_monomer, 'pdb_residue'): 1.32 if monomer == pdb_monomer: 1.33 - monomer.pdb_residue = pdb_monomer.pdb_residue 1.34 + monomer.ca_xyz = pdb_monomer.pdb_residue['CA'].get_vector() 1.35 + if not xyz_only: 1.36 + monomer.pdb_residue = pdb_monomer.pdb_residue 1.37 else: 1.38 mutations += 1 1.39 assert mutations <= max_mutations 1.40 @@ -118,7 +121,7 @@ 1.41 sequence.append(monomer) 1.42 return sequence 1.43 1.44 - def auto_pdb(self, conformity=None, pdb_getter=download_pdb): 1.45 + def auto_pdb(self, conformity=None, pdb_getter=download_pdb, xyz_only=False): 1.46 """ Add pdb information to each monomer 1.47 1.48 raise AssertionError if info has not been successfully added 1.49 @@ -131,7 +134,7 @@ 1.50 chain = match['chain'] 1.51 model = match['model'] 1.52 pdb_file = pdb_getter(code) 1.53 - self.set_pdb_chain(pdb_file, code, chain, model) 1.54 + self.set_pdb_chain(pdb_file, code, chain, model, xyz_only=xyz_only) 1.55 1.56 def save_pdb(self, out_filename, new_chain=None, new_model=None): 1.57 """ Save pdb_chain to out_file """ 1.58 @@ -306,12 +309,9 @@ 1.59 if sequence in column1 and sequence in column2: 1.60 m1 = column1[sequence] 1.61 m2 = column2[sequence] 1.62 - if hasattr(m1, 'pdb_residue') and hasattr(m2, 'pdb_residue'): 1.63 - r1 = m1.pdb_residue 1.64 - r2 = m2.pdb_residue 1.65 - ca1 = r1['CA'] 1.66 - ca2 = r2['CA'] 1.67 - d = ca1 - ca2 # Bio.PDB feature 1.68 + if hasattr(m1, 'ca_xyz') and hasattr(m2, 'ca_xyz'): 1.69 + delta_vector = m1.ca_xyz - m2.ca_xyz 1.70 + d = sum([C**2 for C in delta_vector.get_array()]) ** 0.5 1.71 distances.append(d) 1.72 if len(distances) == len(self.sequences): 1.73 delta = max(distances) - min(distances)