From f44796dd43d2c5949d9d498cdebf685d50d9f0ac Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 1 Sep 2011 11:49:32 -0400 Subject: [PATCH 01/10] Merge branch 'master', remote-tracking branch 'origin' From 151cbafa0be1dd3930c5c7602037e2eda2bf4a94 Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 13:33:29 +0200 Subject: [PATCH 02/10] InChI Key getter in molecule.Molecule similar to InChI getter via OpenBabel. Removes the checksum characters (last 2) --- rmgpy/molecule.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rmgpy/molecule.py b/rmgpy/molecule.py index da8e3b5bd8..2d938b9c33 100644 --- a/rmgpy/molecule.py +++ b/rmgpy/molecule.py @@ -998,6 +998,23 @@ def toInChI(self): obConversion.SetOutFormat('inchi') obConversion.SetOptions('w', openbabel.OBConversion.OUTOPTIONS) return obConversion.WriteString(obmol).strip() + + def toInChIKey(self): + """ + Convert a molecular structure to an InChI Key string. Uses + `OpenBabel `_ to perform the conversion. + + Removes check-sum dash (-) and character so that only + the 14 + 9 characters remain. + """ + import openbabel + # This version does not write a warning to stderr if stereochemistry is undefined + obmol = self.toOBMol() + obConversion = openbabel.OBConversion() + obConversion.SetOutFormat('inchi') + obConversion.SetOptions('w', openbabel.OBConversion.OUTOPTIONS) + obConversion.SetOptions('K', openbabel.OBConversion.OUTOPTIONS) + return obConversion.WriteString(obmol).strip()[:-2] def toSMILES(self): """ From b498277db3ec864938ab5f8d2174af80fcf9041c Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 14:45:55 +0200 Subject: [PATCH 03/10] Unit test for InChIKey generation. --- unittest/moleculeTest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/unittest/moleculeTest.py b/unittest/moleculeTest.py index 5da1ea8c21..6b3cd133b2 100644 --- a/unittest/moleculeTest.py +++ b/unittest/moleculeTest.py @@ -872,6 +872,14 @@ def testRadicalCH2(self): molecule = Molecule().fromSMILES('[CH2]') self.assertEqual(molecule.atoms[0].radicalElectrons, 2) self.assertEqual(molecule.atoms[0].spinMultiplicity, 3) + + def testInChIKey(self): + """ + Test that InChI Key generation is working properly. + """ + molecule = Molecule().fromInChI('InChI=1S/C7H12/c1-2-7-4-3-6(1)5-7/h6-7H,1-5H2') + key = molecule.toInChIKey() + self.assertEqual(key, 'UMRZSTCPUPJPOJ-UHFFFAOYSA') ################################################################################ class TestMoleculeSymmetry(unittest.TestCase): From cd3b077297f936d4af8f8b115c69234f8804281a Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 15:13:08 +0200 Subject: [PATCH 04/10] Augmented InChI getter in Molecule Augmented InChI adds a layer denoted by /mult at the end of the existing inchi to cope with polyradicals (>=2). The number returned in the /mult layer equals the total number of unpaired electrons + 1 --- rmgpy/molecule.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rmgpy/molecule.py b/rmgpy/molecule.py index 2d938b9c33..89951c48e8 100644 --- a/rmgpy/molecule.py +++ b/rmgpy/molecule.py @@ -999,6 +999,20 @@ def toInChI(self): obConversion.SetOptions('w', openbabel.OBConversion.OUTOPTIONS) return obConversion.WriteString(obmol).strip() + def toAugmentedInChI(self): + """ + Adds an extra layer to the InChI denoting the number of unpaired electrons in case + more than 1 ( >= 2) unpaired electrons are present in the molecule. + """ + inchi = self.toInChI() + + radicalNumber = sum([i.radicalElectrons for i in self.atoms]) + + if radicalNumber >= 2: + return inchi+'/mult'+str(radicalNumber+1) + else: + return inchi + def toInChIKey(self): """ Convert a molecular structure to an InChI Key string. Uses From 45e0689e1cfab46565c6c82fd3175a4aec766323 Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 15:14:19 +0200 Subject: [PATCH 05/10] Augmented InChIKey getter in Molecule similar to the augmented InChI the InChIKey is extended with a /mult layer --- rmgpy/molecule.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rmgpy/molecule.py b/rmgpy/molecule.py index 89951c48e8..f6a0d2d123 100644 --- a/rmgpy/molecule.py +++ b/rmgpy/molecule.py @@ -1029,7 +1029,21 @@ def toInChIKey(self): obConversion.SetOptions('w', openbabel.OBConversion.OUTOPTIONS) obConversion.SetOptions('K', openbabel.OBConversion.OUTOPTIONS) return obConversion.WriteString(obmol).strip()[:-2] - + + def toAugmentedInChIKey(self): + """ + Adds an extra layer to the InChIKey denoting the number of unpaired electrons in case + more than 1 ( >= 2) unpaired electrons are present in the molecule. + """ + key = self.toInChIKey() + + radicalNumber = sum([i.radicalElectrons for i in self.atoms]) + + if radicalNumber >= 2: + return key+'/mult'+str(radicalNumber+1) + else: + return key + def toSMILES(self): """ Convert a molecular structure to an SMILES string. Uses From e47d39a1bcd9cb907172fadb6bd72c2dbbceef07 Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 15:15:06 +0200 Subject: [PATCH 06/10] unit test for Augmented InChI --- unittest/moleculeTest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unittest/moleculeTest.py b/unittest/moleculeTest.py index 6b3cd133b2..51c128eca2 100644 --- a/unittest/moleculeTest.py +++ b/unittest/moleculeTest.py @@ -880,6 +880,18 @@ def testInChIKey(self): molecule = Molecule().fromInChI('InChI=1S/C7H12/c1-2-7-4-3-6(1)5-7/h6-7H,1-5H2') key = molecule.toInChIKey() self.assertEqual(key, 'UMRZSTCPUPJPOJ-UHFFFAOYSA') + + def testAugmentedInChI(self): + """ + Test that Augmented InChI generation is printing the /mult layer + """ + mol = Molecule().fromAdjacencyList(""" + 1 C 1 {2,S} + 2 C 1 {1,S} + """) + + self.assertEqual(mol.toAugmentedInChI(self), 'InChI=1S/C2H4/c1-2/h1-2H2/mult3') + ################################################################################ class TestMoleculeSymmetry(unittest.TestCase): From 38936b71d6b3554a759d31aa34a0fa3da42a382c Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 17 May 2012 15:15:26 +0200 Subject: [PATCH 07/10] unit test for Augmented InChIKey --- unittest/moleculeTest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/unittest/moleculeTest.py b/unittest/moleculeTest.py index 51c128eca2..d788d9d33c 100644 --- a/unittest/moleculeTest.py +++ b/unittest/moleculeTest.py @@ -892,6 +892,16 @@ def testAugmentedInChI(self): self.assertEqual(mol.toAugmentedInChI(self), 'InChI=1S/C2H4/c1-2/h1-2H2/mult3') + def testAugmentedInChIKey(self): + """ + Test that Augmented InChI Key generation is printing the /mult layer + """ + mol = Molecule().fromAdjacencyList(""" + 1 C 1 {2,S} + 2 C 1 {1,S} + """) + + self.assertEqual(mol.toAugmentedInChIKey(self), 'VGGSQFUCUMXWEO-UHFFFAOYSA/mult3') ################################################################################ class TestMoleculeSymmetry(unittest.TestCase): From b4f79725ed1ce5e326a91f54a329a770d7d722e8 Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Fri, 20 Jun 2014 14:06:23 -0400 Subject: [PATCH 08/10] add attributes in makeProfileGraph to prevent gprof2dot from crashing closes #239 --- rmgpy/rmg/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index a1109110b4..e9966fd32f 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -1138,7 +1138,7 @@ def makeProfileGraph(stats_file): `dot -Tpdf input.dot -o output.pdf`. """ try: - from gprof2dot import gprof2dot + import gprof2dot except ImportError: logging.warning('Package gprof2dot not found. Unable to create a graph of the profile statistics.') # `pip install gprof2dot` if you don't have it. @@ -1151,6 +1151,9 @@ class Options: m.options.node_thres = 0.8 m.options.edge_thres = 0.1 m.options.strip = False + m.options.show_samples = False + m.options.root = "" + #m.options.leaf = "" m.options.wrap = True m.theme = m.themes['color'] # bw color gray pink parser = gprof2dot.PstatsParser(stats_file) From 313ea14ae535b8bd4370f15a9f130ce2e0a66d48 Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Fri, 20 Jun 2014 14:21:22 -0400 Subject: [PATCH 09/10] add attributes in makeProfileGraph to prevent gprof2dot from crashing closes #239 --- rmgpy/rmg/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index a1109110b4..19ecdc0276 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -1138,7 +1138,7 @@ def makeProfileGraph(stats_file): `dot -Tpdf input.dot -o output.pdf`. """ try: - from gprof2dot import gprof2dot + import gprof2dot except ImportError: logging.warning('Package gprof2dot not found. Unable to create a graph of the profile statistics.') # `pip install gprof2dot` if you don't have it. @@ -1151,6 +1151,9 @@ class Options: m.options.node_thres = 0.8 m.options.edge_thres = 0.1 m.options.strip = False + m.options.show_samples = False + m.options.root = "" + m.options.leaf = "" m.options.wrap = True m.theme = m.themes['color'] # bw color gray pink parser = gprof2dot.PstatsParser(stats_file) From 922ba6fbb9a9a199b2e04d86edd44ac2174125bb Mon Sep 17 00:00:00 2001 From: Nick Vandewiele Date: Thu, 3 Jul 2014 10:05:01 -0400 Subject: [PATCH 10/10] add missing method argument in thermoEstimator example input file This crashed the thermoEstimator. --- examples/thermoEstimator/input.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/thermoEstimator/input.py b/examples/thermoEstimator/input.py index 6f1bb29a48..dcb3bb7275 100644 --- a/examples/thermoEstimator/input.py +++ b/examples/thermoEstimator/input.py @@ -25,6 +25,7 @@ quantumMechanics( software='mopac', + method='pm3', fileStore='QMfiles', # relative to where you run it? defaults to inside the output folder. scratchDirectory = None, # not currently used onlyCyclics = True,