allpy
changeset 476:d8bc843872b8
structure: assign new chain (A,B,...) names when export
when pool of letters is out, use model 1 etc
(this action is needed to aviod chain name collision)
author | boris (netbook) <bnagaev@gmail.com> |
---|---|
date | Fri, 18 Feb 2011 13:35:29 +0300 |
parents | c30ddd85fcc5 |
children | 06c88008ecd9 |
files | allpy/structure.py |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line diff
1.1 --- a/allpy/structure.py Fri Feb 18 13:15:50 2011 +0300 1.2 +++ b/allpy/structure.py Fri Feb 18 13:35:29 2011 +0300 1.3 @@ -136,7 +136,7 @@ 1.4 self.set_pdb_chain(open(path), code, chain, model) 1.5 return True 1.6 1.7 - def save_pdb(self, out_filename): 1.8 + def save_pdb(self, out_filename, new_chain=None, new_model=None): 1.9 """ Saves pdb_chain to out_file """ 1.10 class MySelect(Select): 1.11 def accept_chain(myselect, chain): 1.12 @@ -144,6 +144,11 @@ 1.13 return 1 1.14 else: 1.15 return 0 1.16 + if new_chain: 1.17 + self.pdb_chain.id = new_chain # change private member 1.18 + if new_model: 1.19 + model = self.pdb_chain.get_parent() 1.20 + model.id = new_model # change private member 1.21 io = PDBIO() 1.22 structure = self.pdb_chain.get_parent().get_parent() 1.23 io.set_structure(structure) 1.24 @@ -245,7 +250,14 @@ 1.25 1.26 def save_pdb(self, out_file): 1.27 """ Save all sequences """ 1.28 + chains = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1.29 + chain_index = -1 1.30 + model = 0 1.31 for sequence in self.sequences: 1.32 - sequence.save_pdb(out_file) 1.33 + chain_index += 1 1.34 + if chain_index >= len(chains): 1.35 + chain_index = 0 1.36 + model += 1 1.37 + sequence.save_pdb(out_file, chains[chain_index], model) 1.38 1.39 # vim: set ts=4 sts=4 sw=4 et: