allpy
changeset 477:06c88008ecd9
structure: save_pdb() recovers old chain and model values
* when pdb is saved, chain and model values can be changed to avoid collisions
then save_pdb shoul recover in-memory values to old values
* save_pdb returns a dict with new chain and model values
it will be usefull for make spt (or pml) scripts
author | boris (netbook) <bnagaev@gmail.com> |
---|---|
date | Fri, 18 Feb 2011 13:50:12 +0300 |
parents | d8bc843872b8 |
children | 6f6b9fa83e14 |
files | allpy/structure.py |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/allpy/structure.py Fri Feb 18 13:35:29 2011 +0300 1.2 +++ b/allpy/structure.py Fri Feb 18 13:50:12 2011 +0300 1.3 @@ -144,15 +144,19 @@ 1.4 return 1 1.5 else: 1.6 return 0 1.7 + old_chain = self.pdb_chain.id 1.8 if new_chain: 1.9 self.pdb_chain.id = new_chain # change private member 1.10 + model = self.pdb_chain.get_parent() 1.11 + old_model = model.id 1.12 if new_model: 1.13 - model = self.pdb_chain.get_parent() 1.14 model.id = new_model # change private member 1.15 io = PDBIO() 1.16 structure = self.pdb_chain.get_parent().get_parent() 1.17 io.set_structure(structure) 1.18 io.save(out_filename, MySelect()) 1.19 + self.pdb_chain.id = old_chain 1.20 + model.id = old_model 1.21 1.22 class AlignmentMixin(base.Alignment): 1.23 """Mixin to add 3D properties to alignments. 1.24 @@ -249,7 +253,11 @@ 1.25 sup.apply(moving) 1.26 1.27 def save_pdb(self, out_file): 1.28 - """ Save all sequences """ 1.29 + """ Save all sequences 1.30 + 1.31 + returns {sequence: (new_chain, new_model)} 1.32 + """ 1.33 + map = {} 1.34 chains = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1.35 chain_index = -1 1.36 model = 0 1.37 @@ -258,6 +266,9 @@ 1.38 if chain_index >= len(chains): 1.39 chain_index = 0 1.40 model += 1 1.41 - sequence.save_pdb(out_file, chains[chain_index], model) 1.42 + chain = chains[chain_index] 1.43 + sequence.save_pdb(out_file, chain, model) 1.44 + map[sequence] = (chain, model) 1.45 + return map 1.46 1.47 # vim: set ts=4 sts=4 sw=4 et: