From f950e5a76bd08ed427628ef1c1d567160b7a4f17 Mon Sep 17 00:00:00 2001 From: Stefan Bienert <stefan.bienert@unibas.ch> Date: Fri, 26 Feb 2016 17:20:06 +0100 Subject: [PATCH] Exported InChI from compoundslib to Python --- modules/conop/pymod/export_compound.cc | 8 +++++++- modules/conop/tests/test_compound.py | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/conop/pymod/export_compound.cc b/modules/conop/pymod/export_compound.cc index 3a9e4e611..661fa9db1 100644 --- a/modules/conop/pymod/export_compound.cc +++ b/modules/conop/pymod/export_compound.cc @@ -106,7 +106,7 @@ void export_Compound() { .def("GetAtomSpecs", &Compound::GetAtomSpecs, return_value_policy<copy_const_reference>()) .add_property("bond_specs", make_function(&Compound::GetBondSpecs, - return_value_policy<copy_const_reference>())) + return_value_policy<copy_const_reference>())) .add_property("atom_specs", make_function(&Compound::GetAtomSpecs, return_value_policy<copy_const_reference>())) .def("AddAtom", &Compound::AddAtom) @@ -120,6 +120,12 @@ void export_Compound() { &Compound::SetFormula) .add_property("dialect", &Compound::GetDialectAsString, &set_dialect) + .add_property("inchi", + make_function(&Compound::GetInchi, + return_value_policy<copy_const_reference>())) + .add_property("inchi_key", + make_function(&Compound::GetInchiKey, + return_value_policy<copy_const_reference>())) ; class_<AtomSpec>("AtomSpec", no_init) diff --git a/modules/conop/tests/test_compound.py b/modules/conop/tests/test_compound.py index 80e9ac8b6..fd480a54b 100644 --- a/modules/conop/tests/test_compound.py +++ b/modules/conop/tests/test_compound.py @@ -29,6 +29,9 @@ class TestCompound(unittest.TestCase): self.assertEqual(compound.dialect, 'PDB') self.assertEqual(compound.formula, 'C3 H7 N O2') self.assertEqual(compound.chem_class, mol.L_PEPTIDE_LINKING) + self.assertEqual(compound.inchi, + "1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1") + self.assertEqual(compound.inchi_key, "QNAYBMKLOCPYGJ-REOHCLBHSA-N") if __name__=='__main__': -- GitLab