Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 93 additions & 27 deletions Analyze_WBO_Torsion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -113,7 +113,16 @@
" \n",
" # get dihedral indices and pass on to get_wbo function\n",
" dihedral_indices = list(tdr_object.dict()['keywords']['dihedrals'][0])\n",
" mol = chemi.smiles_to_oemol(smiles)\n",
" #mol = chemi.smiles_to_oemol(smiles)\n",
" \n",
" #debug\n",
" # create a new molecule\n",
" #mol = oechem.OEGraphMol()\n",
" mol = oechem.OEMol()\n",
" # convert the SMILES string into a molecule\n",
" oechem.OESmilesToMol(mol, smiles)\n",
" \n",
" \n",
" mol.SetData(\"TB\", max(torsion_barriers))\n",
" mol.SetData(\"TDindices\", dihedral_indices)\n",
" mol.SetData(\"TDid\", tdr_object.id)\n",
Expand Down Expand Up @@ -238,35 +247,63 @@
"\n",
" mols=[]\n",
" errors=[]\n",
" matched=0\n",
" for mol in molList:\n",
" any_match=0\n",
" charged = chemi.get_charges(mol)\n",
" for bond in charged.GetBonds():\n",
" #m1 = bond.GetBgn().GetMapIdx()\n",
" #m2 = bond.GetEnd().GetMapIdx()\n",
" m1=bond.GetBgnIdx()\n",
" m2=bond.GetEndIdx()\n",
" index=mol.GetData(\"TDindices\")\n",
" #print(m1)\n",
" #print(m2)\n",
" #print(index[1])\n",
" #print(index[2])\n",
" if m1 in [index[1], index[2]]:\n",
" if m2 in [index[1], index[2]]:\n",
" indices=[index[1], index[2]]\n",
" # DEBUGGING: ERROR IS HAPPENING HERE\n",
" # ISSUE WITH INDEX, ROWLEY DATASET IS NOT FINDING MATCH TO TORSION INDICES FOR ANY \n",
" if (m1 in indices and m2 in indices):\n",
" any_match+=1\n",
" matched+=1\n",
" #print(\"match\")\n",
" #if (m1 in map_idx or m2 in map_idx) and not bond.IsInRing():\n",
" try: \n",
" wbo = bond.GetData('WibergBondOrder')\n",
" #print(wbo)\n",
" mol.SetData(\"WBO\", wbo)\n",
" mols.append(mol)\n",
" except: \n",
" errors.append(mol)\n",
" pass\n",
" try: \n",
" wbo = bond.GetData('WibergBondOrder')\n",
" mol.SetData(\"WBO\", wbo)\n",
" mols.append(mol)\n",
" except Exception as e: \n",
" print(e)\n",
" errors.append(mol)\n",
" pass\n",
" if any_match==0:\n",
" print(\"no matches\")\n",
" oemol2mol2(mol, mol.GetData('cmiles'))\n",
" if any_match>0:\n",
" oemol2mol2(mol, \"match_\"+mol.GetData('cmiles'))\n",
" \n",
" \n",
" print(\"Out of \" +str(len(molList)) + \" molecules, \" + str(len(mols)) + \" were processed with WBO\")\n",
" print(matched)\n",
" return mols, errors\n",
" \n",
"\n",
"def oemol2mol2(mol, tag):\n",
" \"\"\"\n",
" Take mollist and create oeb file using the tag as the .oeb file name \n",
" \n",
" Parameters\n",
" ----------\n",
" molList : List of objects\n",
" List of oemols with datatags generated in genData function\n",
" tag : String\n",
" Title of the oeb file \n",
"\n",
" Returns\n",
" -------\n",
" \"\"\"\n",
" ofile = oechem.oemolostream(tag+'.mol2')\n",
" oechem.OEWriteConstMolecule(ofile, mol)\n",
" ofile.close()\n",
" return\n",
"\n",
" \n",
"\n",
"\n",
"def makeOEB(oemolList, tag):\n",
" \"\"\"\n",
Expand Down Expand Up @@ -471,17 +508,16 @@
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"scrolled": true
},
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Out of 43 molecules, 43 were processed with torsion data\n",
"Out of 43 molecules, 43 were processed with WBO\n"
"Out of 43 molecules, 43 were processed with WBO\n",
"43\n"
]
},
{
Expand Down Expand Up @@ -550,21 +586,49 @@
"source": [
"#An example of combining and comparing two datasets, let's try comparing with the phenyl dataset \n",
"genData(\"OpenFF Substituted Phenyl Set 1\", \"phenyl\")\n",
"\n",
"visualize_wbo_correlation_compare('phenyl.oeb', 'fragmentstability.oeb', \"fragmentStability_and_phenyl.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Out of 86 molecules, 86 were processed with torsion data\n",
"Out of 86 molecules, 58 were processed with WBO\n"
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"no matches\n",
"Out of 86 molecules, 58 were processed with WBO\n",
"58\n"
]
},
{
Expand Down Expand Up @@ -598,6 +662,8 @@
],
"source": [
"#Let's also add the Rowley dataset and compare \n",
"#DEBUGGING ROWLEY DATASET\n",
"\n",
"genData(\"OpenFF Rowley Biaryl v1.0\", \"rowley\")\n",
"visualize_wbo_correlation_compare('phenyl.oeb', 'rowley.oeb', \"rowley_and_phenyl.pdf\")"
]
Expand Down
Binary file added ForceFields/InitalGuessWBO_Bayly.pptx
Binary file not shown.
10 changes: 10 additions & 0 deletions ForceFields/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Force fields for proposed WBO interpolated torsion parameters

This repository contains the .offxml file format force fields for forcebalance refitting experiments.
These parameters were adapted from Chris Bayly's initial guess smarts for WBO interpolated parameters, round 0.

## Manifest
* `openff-1.2.1-biaryl.offxm` - Proposed parameters are TIG0 through TIG8
* `openff-1.2.1-phenyl.offxm` - Proposed parameters are T1i through t7i
* `openff-1.2.1-combined.offxm` - Contains both sets of parameters TIG0 through TIG8 and T1i through t7i.

Loading