From 9ae8c88c99b17dcb6365007c04e03bec83b69853 Mon Sep 17 00:00:00 2001 From: B13nch3n <stefan.bienert@me.com> Date: Wed, 15 Jul 2020 13:43:45 +0200 Subject: [PATCH] SCHWED-4847: Export the MMCifInfoEntityBranch class to Python. --- modules/io/pymod/export_mmcif_io.cc | 13 +++++++++++++ modules/io/src/mol/mmcif_info.hh | 2 ++ modules/io/tests/test_io_mmcif.py | 15 +++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index fa63ed244..9c860b596 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -332,6 +332,19 @@ void export_mmcif_io() .add_property("first_release", &MMCifInfoRevisions::GetFirstRelease) ; + class_<MMCifInfoEntityBranch>("MMCifInfoEntityBranch", init<mol::AtomHandle, + mol::AtomHandle>()) + .def("GetAtom1", &MMCifInfoEntityBranch::GetAtom1) + .def("GetAtom2", &MMCifInfoEntityBranch::GetAtom2) + .def("ConnectBranchLink", &MMCifInfoEntityBranch::ConnectBranchLink) + .def("SetAtom1", &MMCifInfoEntityBranch::SetAtom1) + .def("SetAtom2", &MMCifInfoEntityBranch::SetAtom2) + .add_property("atom1", &MMCifInfoEntityBranch::GetAtom1, + &MMCifInfoEntityBranch::SetAtom1) + .add_property("atom2", &MMCifInfoEntityBranch::GetAtom2, + &MMCifInfoEntityBranch::SetAtom2) + ; + class_<MMCifInfo>("MMCifInfo", init<>()) .def("AddCitation", &MMCifInfo::AddCitation) .def("GetCitations", make_function(&MMCifInfo::GetCitations, diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index 8da038933..17c60b673 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -927,6 +927,8 @@ public: atom1_(atom1), atom2_(atom2) {} mol::AtomHandle GetAtom1() const { return atom1_;} mol::AtomHandle GetAtom2() const { return atom2_; } + void SetAtom1(mol::AtomHandle atom) { atom1_ = atom; } + void SetAtom2(mol::AtomHandle atom) { atom2_ = atom; } void ConnectBranchLink(mol::XCSEditor editor) { editor.Connect(atom1_, atom2_); diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index cfa10798c..bdad11392 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -263,6 +263,21 @@ class TestMMCifInfo(unittest.TestCase): self.assertEqual(len(crambin_pdb.residues), 46) self.assertEqual(len(crambin_pdb.atoms), 327) + def test_mmcifinfo_entitybranch(self): + # create dummy atoms + eh = mol.CreateEntity() + editor = eh.EditXCS(); + ch = editor.InsertChain("A"); + res1 = editor.AppendResidue(ch, "BMA"); + res2 = editor.AppendResidue(ch, "MAN"); + atom1 = editor.InsertAtom(res2, "C1", geom.Vec3()); + atom2 = editor.InsertAtom(res1, "O3", geom.Vec3()); + branch = io.MMCifInfoEntityBranch(atom1, atom2) + self.assertEqual(branch.atom1.qualified_name, "A.MAN2.C1") + + branch.ConnectBranchLink(editor) + self.assertEqual(atom2.GetBondPartners()[0].qualified_name, "A.MAN2.C1") + if __name__== '__main__': from ost import testutils testutils.RunTests() -- GitLab