Skip to content

Commit

Permalink
Merge pull request #108 from openforcefield/bannanc
Browse files Browse the repository at this point in the history
Update ChemicalEnvironments SMIRKS parsing
  • Loading branch information
davidlmobley committed Apr 30, 2018
2 parents d0868c7 + 312ae25 commit 65f6b45
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ script:
#- pip install $OPENEYE_CHANNEL openeye-toolkits && python -c "import openeye; print(openeye.__version__)"
# Use beta version for partial bond orders
- pip install --pre -i https://pypi.anaconda.org/openeye/simple openeye-toolkits && python -c "import openeye; print(openeye.__version__)"
# Install RDKit
- conda install --yes -c rdkit rdkit
# Build the recipe
- conda build devtools/conda-recipe
# Use oeommtools for improper test
Expand All @@ -35,7 +37,6 @@ script:

env:
matrix:
- python=2.7 CONDA_PY=27
- python=3.5 CONDA_PY=35
- python=3.6 CONDA_PY=36

Expand Down
32 changes: 19 additions & 13 deletions openforcefield/tests/test_chemicalenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,30 @@ def test_parseSMIRKS(self):
('ewg2', '[#7!-1,#8,#16]') ]

smirksList = [ ["[#6](-[#1])-[#8]", None, ChemicalEnvironment],
["[#6&X4&H0:1](-[#1])-[#6&X4]", 'VdW', AtomChemicalEnvironment],
["[#6&X4&H0:1](-[#1])-[#6&X4]", 'Atom', AtomChemicalEnvironment],
[ "[#6&X4&H0:1](-[#1])-[#6&X4:2]", 'Bond', BondChemicalEnvironment],
[ "[*:1]-[*:2](-[#6&X4])-[*:3]", 'Angle', AngleChemicalEnvironment],
[ "[#6&X4&H0:1](-[#1])-[#6&X4:2]-[#6&X4&H0:3](-[#1])-[#6&X4:4]", 'Torsion', TorsionChemicalEnvironment],
[ "[#1:1]-[#6&X4:2](-[#8:3])-[#1:4]", 'Improper', ImproperChemicalEnvironment],
[ "[#6&X4&H0:1](-[#1])-[#6&X4:2]-[#6&X4&H0:3](-[#1])-[#6&X4:4]", 'ProperTorsion', TorsionChemicalEnvironment],
[ "[#1:1]-[#6&X4:2](-[#8:3])-[#1:4]", 'ImproperTorsion', ImproperChemicalEnvironment],
[ "[#1:1]-[#6&X4:2](-[#8:3])-[*:4](-[#6&H1])-[#8:5]", None, ChemicalEnvironment],
[ "[#6$(*~[#6]=[#8])$(*-,=$ewg2)]", None, ChemicalEnvironment],
[ "[#6$(*~[#6]=[#8])$(*-,=[$ewg2,#7])]", None, ChemicalEnvironment],
[ "CCC", None, ChemicalEnvironment],
[ "[#6:1]1(-;!@[#1,#6])=;@[#6]-;@[#6]1", 'VdW', ChemicalEnvironment],
[ "[#6:1]1(-;!@[#1,#6])=;@[#6]-;@[#6]1", 'Atom', ChemicalEnvironment],
[ "C(O-[#7,#8])CC=[*]", None, ChemicalEnvironment],
[ "[#6$([#6X4](~[$ewg1])(~[#8]~[#1])):1]-[#6X2H2;+0:2]-,=,:;!@;!#[$ewg2:3]-[#4:4]", 'Torsion', TorsionChemicalEnvironment],
[ "[#6$([#6X4](~[$ewg1])(~[#8]~[#1])):1]1=CCCC1", 'VdW', AtomChemicalEnvironment] ]

for [smirks, checkType, chemEnv] in smirksList:
env = chemEnv(smirks = smirks, replacements = replacements)
Type = env.getType()
self.assertEqual(Type,checkType,
"SMIRKS (%s) clasified as %s instead of %s" % (smirks, Type, checkType))
[ "[#6$([#6X4](~[$ewg1])(~[#8]~[#1])):1]-[#6X2H2;+0:2]-,=,:;!@;!#[$ewg2:3]-[#4:4]", 'ProperTorsion', TorsionChemicalEnvironment],
[ "[#6$([#6X4](~[$ewg1])(~[#8]~[#1])):1]1=CCCC1", 'Atom', AtomChemicalEnvironment],
[ "[*:1]-[#7X3:2](-[#6a$(*1ccc(-[#8-1X1])cc1):3])-[*:4]", 'ImproperTorsion', ImproperChemicalEnvironment],
[ "[#6X4:1]1~[*:2]~[*$(*~[#1]):3]1", 'Angle', AngleChemicalEnvironment],
[ "[$([#7]1~[#6]-CC1)]", None, ChemicalEnvironment],
[ "[$(c1ccccc1)]", None, ChemicalEnvironment],
]

for toolkit in ['openeye', 'rdkit']:
for [smirks, checkType, chemEnv] in smirksList:
env = chemEnv(smirks = smirks, replacements = replacements, toolkit=toolkit)
Type = env.getType()
self.assertEqual(Type,checkType,
"SMIRKS (%s) clasified as %s instead of %s using %s toolkit" % (smirks, Type, checkType, toolkit))

def test_environment_functions(self):
"""
Expand Down
Loading

0 comments on commit 65f6b45

Please sign in to comment.