allpy
changeset 815:2c0391cca127
structure: fix model saving (workaround)
Biopython seems to set MODEL record always to 1.
(Maybe it is not biopython but our error.)
Instead of changing model field of biopython model,
generate MODEL and ENDMDL records manually.
Biopython's MODEL record is skipped using StringIO.
author | boris (kodomo) <bnagaev@gmail.com> |
---|---|
date | Fri, 15 Jul 2011 03:03:39 +0400 |
parents | 4e4d53155e42 |
children | d137df18a8bf |
files | allpy/structure.py |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/allpy/structure.py Fri Jul 15 02:56:28 2011 +0400 1.2 +++ b/allpy/structure.py Fri Jul 15 03:03:39 2011 +0400 1.3 @@ -239,20 +239,26 @@ 1.4 if new_chain: 1.5 chain.id = new_chain # change private member 1.6 model = chain.get_parent() 1.7 - old_model = model.id 1.8 - if new_model: 1.9 - model.id = new_model # change private member 1.10 class MySelect(Select): 1.11 def accept_chain(myselect, tested_chain): 1.12 return tested_chain is chain 1.13 def accept_model(myselect, tested_model): 1.14 return tested_model is model 1.15 + temp = StringIO() 1.16 io = PDBIO() 1.17 structure = model.get_parent() 1.18 io.set_structure(structure) 1.19 - io.save(out_filename, MySelect()) 1.20 + io.save(temp, MySelect()) 1.21 + if new_model is not None: 1.22 + out_filename.write("%-80s\n" % ("MODEL %4i" % new_model)) 1.23 + temp.seek(0) 1.24 + for line in temp: 1.25 + if not line.startswith('MODEL') and not line.startswith('ENDMDL'): 1.26 + out_filename.write(line) 1.27 + temp.close() 1.28 + if new_model is not None: 1.29 + out_filename.write("%-80s\n" % "ENDMDL") 1.30 self.pdb_chain.id = old_chain 1.31 - model.id = old_model 1.32 1.33 class AlignmentMixin(base.Alignment): 1.34 """Mixin to add 3D properties to alignments.