diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index a11811f5958d3a54168cc2eaab1ec0ef57649ee7..d5dcf651c7a7bc90a3079cbdc416b143a6e1364b 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -136,6 +136,19 @@ class TestMMCifInfo(unittest.TestCase): self.assertEquals(tr_ol[0][0], 0) self.assertEquals(tr_ol[0][1], 1) + def test_mmcifinfo_biounit_pdbize_with_multiple_transforms(self): + ent, seqres, info = io.LoadMMCIF("testfiles/mmcif/multiple_transforms.cif.gz", + seqres=True, + info=True) + pdb_ent = info.GetBioUnits()[0].PDBize(ent) + pdb_seqres_ent = info.GetBioUnits()[0].PDBize(ent, seqres) + chains = pdb_ent.chains + self.assertEquals([c.name for c in chains], + ['A', '_', '-', 'B', 'C', 'D']) + ligand_chain = chains[1] + ligand_residues = ligand_chain.residues + self.assertEquals([r.number for r in ligand_residues], + [mol.ResNum(1), mol.ResNum(2), mol.ResNum(3), mol.ResNum(4)]) def test_mmcifinfo_biounit_pdbize(self): ent, seqres, info = io.LoadMMCIF("testfiles/mmcif/3T6C.cif.gz", seqres=True, diff --git a/modules/mol/alg/src/pdbize.cc b/modules/mol/alg/src/pdbize.cc index 4b6fd0d57123dca54bfa6b61baad8250e7ed065e..9e3638358356ecbe3e817c31466b448a8cc97f1f 100644 --- a/modules/mol/alg/src/pdbize.cc +++ b/modules/mol/alg/src/pdbize.cc @@ -70,7 +70,6 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, { XCSEditor edi = ent_.EditXCS(BUFFERED_EDIT); - int last_rnum = 0; for (geom::Mat4List::const_iterator i = transforms.begin(), e = transforms.end(); i != e; ++i) { for (ChainViewList::const_iterator j = asu.GetChainList().begin(), @@ -125,14 +124,14 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, // deal with ligands... if (!ligand_chain_) { ligand_chain_ = edi.InsertChain(LIGAND_CHAIN_NAME); - last_rnum = 0; + 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(), - ResNum(last_rnum+1, ins_code)); + ResNum(last_rnum_+1, ins_code)); transfer_residue_properties(*k, new_res); new_res.SetStringProp("type", StringFromChainType(chain.GetType())); new_res.SetStringProp("description", chain.GetDescription()); @@ -144,7 +143,7 @@ void PDBize::Add(EntityView asu, const geom::Mat4List& transforms, ins_code += 1; needs_adjustment_ |= copy_atoms(*k, new_res, edi, *i); } - last_rnum+=1; + last_rnum_+=1; } } } diff --git a/modules/mol/alg/src/pdbize.hh b/modules/mol/alg/src/pdbize.hh index 00534a4cf11e8c0506747ae866382c140d417b6f..f3afec693524f12e3c691db8fe7b65ba318dc050 100644 --- a/modules/mol/alg/src/pdbize.hh +++ b/modules/mol/alg/src/pdbize.hh @@ -36,7 +36,8 @@ class DLLEXPORT_OST_MOL_ALG PDBize { public: explicit PDBize(int min_polymer_size=10): min_polymer_size_(min_polymer_size), ent_(mol::CreateEntity()), - curr_chain_name_(POLYPEPTIDE_CHAIN_NAMES), needs_adjustment_(false) + curr_chain_name_(POLYPEPTIDE_CHAIN_NAMES), needs_adjustment_(false), + last_rnum_(0) {} void Add(mol::EntityView asu, const geom::Mat4List& transforms, @@ -50,6 +51,7 @@ private: ChainHandle water_chain_; const char* curr_chain_name_; bool needs_adjustment_; + int last_rnum_; std::map<ResidueHandle,ResidueHandle> dst_to_src_map_; };