diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index 3c1a0ec23399f210b61a038ef7e98cb16545cde2..a11811f5958d3a54168cc2eaab1ec0ef57649ee7 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -213,6 +213,36 @@ class TestMMCifInfo(unittest.TestCase): 0,0,0,1), 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): d = io.MMCifInfoStructDetails() diff --git a/modules/io/tests/testfiles/mmcif/2ast.cif.gz b/modules/io/tests/testfiles/mmcif/2ast.cif.gz new file mode 100644 index 0000000000000000000000000000000000000000..5ed06c4312b953772f95a5f1fbdaaa3da5e98366 Binary files /dev/null and b/modules/io/tests/testfiles/mmcif/2ast.cif.gz differ diff --git a/modules/mol/alg/src/pdbize.cc b/modules/mol/alg/src/pdbize.cc index 21cd4b4129f7f85fe603159a11ec8ea271eff085..4b6fd0d57123dca54bfa6b61baad8250e7ed065e 100644 --- a/modules/mol/alg/src/pdbize.cc +++ b/modules/mol/alg/src/pdbize.cc @@ -70,8 +70,6 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, { XCSEditor edi = ent_.EditXCS(BUFFERED_EDIT); - ChainHandle ligand_chain; - ChainHandle water_chain; int last_rnum = 0; for (geom::Mat4List::const_iterator i = transforms.begin(), e = transforms.end(); i != e; ++i) { @@ -108,14 +106,14 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, continue; } if (chain.GetType() == CHAINTYPE_WATER) { - if (!water_chain) { - water_chain = edi.InsertChain(WATER_CHAIN_NAME); - edi.SetChainDescription(water_chain, chain.GetDescription()); - edi.SetChainType(water_chain, chain.GetType()); + if (!water_chain_) { + water_chain_ = edi.InsertChain(WATER_CHAIN_NAME); + edi.SetChainDescription(water_chain_, chain.GetDescription()); + edi.SetChainType(water_chain_, chain.GetType()); } for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(), 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); new_res.SetStringProp("type", StringFromChainType(chain.GetType())); new_res.SetStringProp("description", chain.GetDescription()); @@ -125,15 +123,15 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, continue; } // deal with ligands... - if (!ligand_chain) { - ligand_chain = edi.InsertChain(LIGAND_CHAIN_NAME); + if (!ligand_chain_) { + ligand_chain_ = edi.InsertChain(LIGAND_CHAIN_NAME); last_rnum = 0; } char ins_code = chain.GetResidueCount()>1 ? 'A' : '\0'; for (ResidueViewList::const_iterator k = chain.GetResidueList().begin(), 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)); transfer_residue_properties(*k, new_res); new_res.SetStringProp("type", StringFromChainType(chain.GetType())); diff --git a/modules/mol/alg/src/pdbize.hh b/modules/mol/alg/src/pdbize.hh index 92c5cbfc4408899df4c830849a94ba2f618b3afb..00534a4cf11e8c0506747ae866382c140d417b6f 100644 --- a/modules/mol/alg/src/pdbize.hh +++ b/modules/mol/alg/src/pdbize.hh @@ -46,6 +46,8 @@ public: private: int min_polymer_size_; EntityHandle ent_; + ChainHandle ligand_chain_; + ChainHandle water_chain_; const char* curr_chain_name_; bool needs_adjustment_; std::map<ResidueHandle,ResidueHandle> dst_to_src_map_;