Skip to content
Snippets Groups Projects
Commit 76b079d7 authored by Bienchen's avatar Bienchen
Browse files

Fixed a glitch in the PDBizer: if more than one set of tranfsormations &...

Fixed a glitch in the PDBizer: if more than one set of tranfsormations & chains exist, lingand/ water chains in the entity already exist, but are re-initialsied in a call to PDBizer.Add and added again to the entity... which does not work, of course.
parent 93000ac6
No related branches found
No related tags found
No related merge requests found
...@@ -213,6 +213,36 @@ class TestMMCifInfo(unittest.TestCase): ...@@ -213,6 +213,36 @@ class TestMMCifInfo(unittest.TestCase):
0,0,0,1), 0,0,0,1),
epsilon=0.01), True) epsilon=0.01), True)
def test_mmcifinfo_biounit_pdbize_multi_transformations(self):
# in case we have more than one set of chains & transformations,
# ligand/ water chains may mess up
ent, seqres, info = io.LoadMMCIF("testfiles/mmcif/2ast.cif.gz",
seqres=True,
info=True)
pdb_ent = info.GetBioUnits()[2].PDBize(ent, seqres=seqres)
# chains
self.assertEquals(str(pdb_ent.GetChainList()[0]), 'A')
self.assertEquals(str(pdb_ent.GetChainList()[1]), 'B')
self.assertEquals(str(pdb_ent.GetChainList()[2]), '_')
self.assertEquals(str(pdb_ent.GetChainList()[3]), '-')
self.assertEquals(str(pdb_ent.GetChainList()[4]), 'C')
self.assertEquals(str(pdb_ent.GetChainList()[5]), 'D')
self.assertEquals(str(pdb_ent.GetChainList()[6]), 'E')
self.assertEquals(str(pdb_ent.GetChainList()[7]), 'F')
self.assertEquals(str(pdb_ent.GetChainList()[8]), 'G')
self.assertEquals(str(pdb_ent.GetChainList()[9]), 'H')
# size of chains
self.assertEquals(len(pdb_ent.GetChainList()[0].GetResidueList()), 142)
self.assertEquals(len(pdb_ent.GetChainList()[1].GetResidueList()), 325)
self.assertEquals(len(pdb_ent.GetChainList()[2].GetResidueList()), 4)
self.assertEquals(len(pdb_ent.GetChainList()[3].GetResidueList()), 530)
self.assertEquals(len(pdb_ent.GetChainList()[4].GetResidueList()), 142)
self.assertEquals(len(pdb_ent.GetChainList()[5].GetResidueList()), 325)
self.assertEquals(len(pdb_ent.GetChainList()[6].GetResidueList()), 69)
self.assertEquals(len(pdb_ent.GetChainList()[7].GetResidueList()), 10)
self.assertEquals(len(pdb_ent.GetChainList()[8].GetResidueList()), 69)
self.assertEquals(len(pdb_ent.GetChainList()[9].GetResidueList()), 10)
def test_mmcifinfo_structdetails(self): def test_mmcifinfo_structdetails(self):
d = io.MMCifInfoStructDetails() d = io.MMCifInfoStructDetails()
......
File added
...@@ -70,8 +70,6 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, ...@@ -70,8 +70,6 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms,
{ {
XCSEditor edi = ent_.EditXCS(BUFFERED_EDIT); XCSEditor edi = ent_.EditXCS(BUFFERED_EDIT);
ChainHandle ligand_chain;
ChainHandle water_chain;
int last_rnum = 0; int last_rnum = 0;
for (geom::Mat4List::const_iterator i = transforms.begin(), for (geom::Mat4List::const_iterator i = transforms.begin(),
e = transforms.end(); i != e; ++i) { e = transforms.end(); i != e; ++i) {
...@@ -108,14 +106,14 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, ...@@ -108,14 +106,14 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms,
continue; continue;
} }
if (chain.GetType() == CHAINTYPE_WATER) { if (chain.GetType() == CHAINTYPE_WATER) {
if (!water_chain) { if (!water_chain_) {
water_chain = edi.InsertChain(WATER_CHAIN_NAME); water_chain_ = edi.InsertChain(WATER_CHAIN_NAME);
edi.SetChainDescription(water_chain, chain.GetDescription()); edi.SetChainDescription(water_chain_, chain.GetDescription());
edi.SetChainType(water_chain, chain.GetType()); edi.SetChainType(water_chain_, chain.GetType());
} }
for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(), for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(),
e3 = chain.GetResidueList().end(); k != e3; ++k) { e3 = chain.GetResidueList().end(); k != e3; ++k) {
ResidueHandle new_res = edi.AppendResidue(water_chain, k->GetName()); ResidueHandle new_res = edi.AppendResidue(water_chain_, k->GetName());
transfer_residue_properties(*k, new_res); transfer_residue_properties(*k, new_res);
new_res.SetStringProp("type", StringFromChainType(chain.GetType())); new_res.SetStringProp("type", StringFromChainType(chain.GetType()));
new_res.SetStringProp("description", chain.GetDescription()); new_res.SetStringProp("description", chain.GetDescription());
...@@ -125,15 +123,15 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, ...@@ -125,15 +123,15 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms,
continue; continue;
} }
// deal with ligands... // deal with ligands...
if (!ligand_chain) { if (!ligand_chain_) {
ligand_chain = edi.InsertChain(LIGAND_CHAIN_NAME); ligand_chain_ = edi.InsertChain(LIGAND_CHAIN_NAME);
last_rnum = 0; last_rnum = 0;
} }
char ins_code = chain.GetResidueCount()>1 ? 'A' : '\0'; char ins_code = chain.GetResidueCount()>1 ? 'A' : '\0';
for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(), for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(),
e3 = chain.GetResidueList().end(); k != e3; ++k) { e3 = chain.GetResidueList().end(); k != e3; ++k) {
ResidueHandle new_res = edi.AppendResidue(ligand_chain, k->GetName(), ResidueHandle new_res = edi.AppendResidue(ligand_chain_, k->GetName(),
ResNum(last_rnum+1, ins_code)); ResNum(last_rnum+1, ins_code));
transfer_residue_properties(*k, new_res); transfer_residue_properties(*k, new_res);
new_res.SetStringProp("type", StringFromChainType(chain.GetType())); new_res.SetStringProp("type", StringFromChainType(chain.GetType()));
......
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
private: private:
int min_polymer_size_; int min_polymer_size_;
EntityHandle ent_; EntityHandle ent_;
ChainHandle ligand_chain_;
ChainHandle water_chain_;
const char* curr_chain_name_; const char* curr_chain_name_;
bool needs_adjustment_; bool needs_adjustment_;
std::map<ResidueHandle,ResidueHandle> dst_to_src_map_; std::map<ResidueHandle,ResidueHandle> dst_to_src_map_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment