allpy
changeset 814:4e4d53155e42
structure: fix filtering by model in save_pdb method of SequenceMixin
* add accept_model method to MySelect class
* move class code after code defining model to use closure
* use is instead of Equal-to operator for chains and models in MySelect
* create helper variables chain and model
author | boris (kodomo) <bnagaev@gmail.com> |
---|---|
date | Fri, 15 Jul 2011 02:56:28 +0400 |
parents | 5102c8443718 |
children | 2c0391cca127 |
files | allpy/structure.py |
diffstat | 1 files changed, 10 insertions(+), 10 deletions(-) [+] |
line diff
1.1 --- a/allpy/structure.py Thu Jul 14 18:15:45 2011 +0400 1.2 +++ b/allpy/structure.py Fri Jul 15 02:56:28 2011 +0400 1.3 @@ -234,21 +234,21 @@ 1.4 1.5 def save_pdb(self, out_filename, new_chain=None, new_model=None): 1.6 """ Save pdb_chain to out_file """ 1.7 - class MySelect(Select): 1.8 - def accept_chain(myselect, chain): 1.9 - if chain == self.pdb_chain: 1.10 - return 1 1.11 - else: 1.12 - return 0 1.13 - old_chain = self.pdb_chain.id 1.14 + chain = self.pdb_chain 1.15 + old_chain = chain.id 1.16 if new_chain: 1.17 - self.pdb_chain.id = new_chain # change private member 1.18 - model = self.pdb_chain.get_parent() 1.19 + chain.id = new_chain # change private member 1.20 + model = chain.get_parent() 1.21 old_model = model.id 1.22 if new_model: 1.23 model.id = new_model # change private member 1.24 + class MySelect(Select): 1.25 + def accept_chain(myselect, tested_chain): 1.26 + return tested_chain is chain 1.27 + def accept_model(myselect, tested_model): 1.28 + return tested_model is model 1.29 io = PDBIO() 1.30 - structure = self.pdb_chain.get_parent().get_parent() 1.31 + structure = model.get_parent() 1.32 io.set_structure(structure) 1.33 io.save(out_filename, MySelect()) 1.34 self.pdb_chain.id = old_chain