From 1caf671dff25d449d3433cf122947c2acb26430f Mon Sep 17 00:00:00 2001 From: "John Chodera (MSKCC)" Date: Fri, 6 Feb 2015 19:45:16 -0500 Subject: [PATCH 1/2] Added test of common molecules to illustrate failures for catechol, aspirin. --- gaff2xml/tests/test_common_molecules.py | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 gaff2xml/tests/test_common_molecules.py diff --git a/gaff2xml/tests/test_common_molecules.py b/gaff2xml/tests/test_common_molecules.py new file mode 100644 index 0000000..3a24b8c --- /dev/null +++ b/gaff2xml/tests/test_common_molecules.py @@ -0,0 +1,41 @@ +""" +Test some common molecules using OpenEye tools. + +""" + +import gaff2xml.openeye +from nose.plugins.attrib import attr +from unittest import skipIf +from gaff2xml import utils +import os + +try: + oechem = utils.import_("openeye.oechem") + if not oechem.OEChemIsLicensed(): raise(ImportError("Need License for OEChem!")) + oequacpac = utils.import_("openeye.oequacpac") + if not oequacpac.OEQuacPacIsLicensed(): raise(ImportError("Need License for oequacpac!")) + oeiupac = utils.import_("openeye.oeiupac") + if not oeiupac.OEIUPACIsLicensed(): raise(ImportError("Need License for OEOmega!")) + oeomega = utils.import_("openeye.oeomega") + if not oeomega.OEOmegaIsLicensed(): raise(ImportError("Need License for OEOmega!")) + HAVE_OE = True +except: + HAVE_OE = False + +molecules = [ + 'benzene', + 'toluene', + 'phenol', + 'catechol', + 'aspirin', + ] + +@skipIf(not HAVE_OE, "Cannot run test_common_molecules() module without OpenEye tools.") +def test_common_molecules(): + import openeye.oechem + for molecule_name in molecules: + molecule = gaff2xml.openeye.iupac_to_oemol(molecule_name) + molecule = gaff2xml.openeye.get_charges(molecule) + with utils.enter_temp_directory(): + molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule) + yield utils.tag_description(lambda : utils.test_molecule(molecule_name, tripos_mol2_filename), "Testing molecule %s" % molecule_name) From d46dc7b2258413adbeff4c7fe05093d2044a7a92 Mon Sep 17 00:00:00 2001 From: "John Chodera (MSKCC)" Date: Fri, 6 Feb 2015 20:45:31 -0500 Subject: [PATCH 2/2] Fixed test by avoiding writing files named with IUPAC molecule names. --- gaff2xml/tests/test_common_molecules.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gaff2xml/tests/test_common_molecules.py b/gaff2xml/tests/test_common_molecules.py index 3a24b8c..66abc3b 100644 --- a/gaff2xml/tests/test_common_molecules.py +++ b/gaff2xml/tests/test_common_molecules.py @@ -37,5 +37,7 @@ def test_common_molecules(): molecule = gaff2xml.openeye.iupac_to_oemol(molecule_name) molecule = gaff2xml.openeye.get_charges(molecule) with utils.enter_temp_directory(): - molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule) - yield utils.tag_description(lambda : utils.test_molecule(molecule_name, tripos_mol2_filename), "Testing molecule %s" % molecule_name) + tripos_mol2_filename = 'molecule.mol2' + molecule_name, tripos_mol2_filename = utils.molecule_to_mol2(molecule, tripos_mol2_filename=tripos_mol2_filename) + yield utils.tag_description(lambda : utils.test_molecule('molecule', tripos_mol2_filename), "Testing molecule %s" % molecule_name) +