Skip to content

Commit

Permalink
Merge pull request #263 from choderalab/iupac_fix
Browse files Browse the repository at this point in the history
Make OEIUPAC optional for normalize_molecule, cut release
  • Loading branch information
Lnaden authored Feb 16, 2018
2 parents 6578516 + 8ba1040 commit 1450505
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ script:
- conda config --add channels ${ORGNAME}
# Add omnia dev channels
- conda config --add channels https://conda.anaconda.org/omnia/label/dev
# Add the conda-forge channel
- conda config --add channels conda-forge
# Update everything
- conda update --quiet --yes --all
# Install OpenEye toolkit
- conda install --yes --quiet pip
- pip install $OPENEYE_CHANNEL openeye-toolkits && python -c "import openeye; print(openeye.__version__)"
Expand All @@ -55,12 +59,12 @@ env:
matrix:
# OpenEye production
- CONDA_PY=27 python=2.7 OPENEYE_CHANNEL="-i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=34 python=3.4 OPENEYE_CHANNEL="-i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=35 python=3.5 OPENEYE_CHANNEL="-i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=36 python=3.6 OPENEYE_CHANNEL="-i https://pypi.anaconda.org/OpenEye/simple/"
# OpenEye beta
- CONDA_PY=27 python=2.7 OPENEYE_CHANNEL="--pre -i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=34 python=3.4 OPENEYE_CHANNEL="--pre -i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=35 python=3.5 OPENEYE_CHANNEL="--pre -i https://pypi.anaconda.org/OpenEye/simple/"
- CONDA_PY=36 python=3.6 OPENEYE_CHANNEL="--pre -i https://pypi.anaconda.org/OpenEye/simple/"

global:
- ORGNAME="omnia"
Expand Down
4 changes: 2 additions & 2 deletions devtools/travis-ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ bash $MINICONDA -b -p $HOME/miniconda
PIP_ARGS="-U"

export PATH=$HOME/miniconda/bin:$PATH

conda install --yes conda-build=2.1.5 jinja2 anaconda-client pip
conda update --yes conda
conda install --yes conda-build=2.1.7 jinja2 anaconda-client pip
Binary file modified oe_license.txt.enc
Binary file not shown.
22 changes: 15 additions & 7 deletions openmoltools/openeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def get_charges(molecule, max_confs=800, strictStereo=True,


def normalize_molecule(molecule):
"""Normalize a copy of the molecule by checking aromaticity, adding explicit hydrogens, and renaming by IUPAC name.
"""
Normalize a copy of the molecule by checking aromaticity, adding explicit hydrogens, and
(if possible) renaming by IUPAC name.
Parameters
----------
Expand All @@ -119,9 +121,10 @@ def normalize_molecule(molecule):
"""
oechem = import_("openeye.oechem")
if not oechem.OEChemIsLicensed(): raise(ImportError("Need License for OEChem!"))
if not oechem.OEChemIsLicensed():
raise(ImportError("Need License for OEChem!"))
oeiupac = import_("openeye.oeiupac")
if not oeiupac.OEIUPACIsLicensed(): raise(ImportError("Need License for OEOmega!"))
has_iupac = oeiupac.OEIUPACIsLicensed()

molcopy = oechem.OEMol(molecule)

Expand All @@ -132,15 +135,17 @@ def normalize_molecule(molecule):
oechem.OEAddExplicitHydrogens(molcopy)

# Set title to IUPAC name.
name = oeiupac.OECreateIUPACName(molcopy)
molcopy.SetTitle(name)
if has_iupac:
name = oeiupac.OECreateIUPACName(molcopy)
molcopy.SetTitle(name)

# Check for any missing atom names, if found reassign all of them.
if any([atom.GetName() == '' for atom in molcopy.GetAtoms()]):
oechem.OETriposAtomNames(molcopy)

return molcopy


def iupac_to_oemol(iupac_name):
"""Create a OEMolBuilder from a iupac name.
Expand All @@ -156,9 +161,11 @@ def iupac_to_oemol(iupac_name):
"""
oechem = import_("openeye.oechem")
if not oechem.OEChemIsLicensed(): raise(ImportError("Need License for OEChem!"))
if not oechem.OEChemIsLicensed():
raise(ImportError("Need License for OEChem!"))
oeiupac = import_("openeye.oeiupac")
if not oeiupac.OEIUPACIsLicensed(): raise(ImportError("Need License for OEOmega!"))
if not oeiupac.OEIUPACIsLicensed():
raise(ImportError("Need License for OEIupac!"))

# Create an OEMol molecule from IUPAC name.
molecule = oechem.OEMol() # create a molecule
Expand All @@ -171,6 +178,7 @@ def iupac_to_oemol(iupac_name):

return molecule


def smiles_to_oemol(smiles):
"""Create a OEMolBuilder from a smiles string.
Expand Down
22 changes: 11 additions & 11 deletions openmoltools/tests/test_openeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import openmoltools.openeye
import pandas as pd
import mdtraj as md
from mdtraj.testing import raises
from numpy.testing import assert_raises

smiles_fails_with_strictStereo = "CN1CCN(CC1)CCCOc2cc3c(cc2OC)C(=[NH+]c4cc(c(cc4Cl)Cl)OC)C(=C=[N-])C=[NH+]3"

Expand Down Expand Up @@ -237,17 +237,17 @@ def test_ffxml_simulation():


@skipIf(not HAVE_OE, "Cannot test openeye module without OpenEye tools.")
@raises(RuntimeError)
def test_charge_fail1():
with utils.enter_temp_directory():
openmoltools.openeye.smiles_to_antechamber(smiles_fails_with_strictStereo, "test.mol2", "test.frcmod", strictStereo=True)
with assert_raises(RuntimeError):
with utils.enter_temp_directory():
openmoltools.openeye.smiles_to_antechamber(smiles_fails_with_strictStereo, "test.mol2", "test.frcmod", strictStereo=True)


@skipIf(not HAVE_OE, "Cannot test openeye module without OpenEye tools.")
@raises(RuntimeError)
def test_charge_fail2():
m = openmoltools.openeye.smiles_to_oemol(smiles_fails_with_strictStereo)
m = openmoltools.openeye.get_charges(m, strictStereo=True, keep_confs=1)
with assert_raises(RuntimeError):
m = openmoltools.openeye.smiles_to_oemol(smiles_fails_with_strictStereo)
m = openmoltools.openeye.get_charges(m, strictStereo=True, keep_confs=1)


@skipIf(not HAVE_OE, "Cannot test openeye module without OpenEye tools.")
Expand All @@ -262,11 +262,11 @@ def test_charge_success2():
m = openmoltools.openeye.get_charges(m, strictStereo=False)

@skipIf(not HAVE_OE, "Cannot test openeye module without OpenEye tools.")
@raises(RuntimeError)
def test_oeassigncharges_fail():
# Fail test for OEToolkits (2017.2.1) new charging function
m = openmoltools.openeye.smiles_to_oemol(smiles_fails_with_strictStereo)
m = openmoltools.openeye.get_charges(m, strictStereo=False, legacy=False)
with assert_raises(RuntimeError):
# Fail test for OEToolkits (2017.2.1) new charging function
m = openmoltools.openeye.smiles_to_oemol(smiles_fails_with_strictStereo)
m = openmoltools.openeye.get_charges(m, strictStereo=False, legacy=False)

@skipIf(not HAVE_OE, "Cannot test openeye module without OpenEye tools.")
def test_oeassigncharges_success():
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
setup_kwargs = {}
cython_extension = 'c'



##########################
VERSION = "0.8.2dev0"
ISRELEASED = False
VERSION = "0.8.2"
ISRELEASED = True
__version__ = VERSION
##########################

Expand Down

0 comments on commit 1450505

Please sign in to comment.