Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4c0a3ff
add smiles file corresponding to example geometries
vtlim May 4, 2018
0e03288
add function to check valence angle from 3 xyz coordinates
vtlim May 4, 2018
7f5fae2
script and test for perturbing valence angle
vtlim May 4, 2018
8284086
add instructions for Jessica, fix typos
vtlim May 4, 2018
df6c281
update perturb_valence function to return rotation matrix
vtlim May 4, 2018
9f5727c
add more details for jessica
vtlim May 4, 2018
d979ff4
Updated get_improper_angles() to return a list of coordinates and ato…
jmaat May 4, 2018
b31a08d
Removed extra lines.
jmaat May 4, 2018
5f85cec
code for perturbing angle geometries
jmaat Jun 6, 2018
b1b759a
removing directory
jmaat Jun 7, 2018
3d775cd
updated code
jmaat Jun 21, 2018
8fa46fd
Merge branch 'master' into perturb_angle
jmaat Jun 21, 2018
c95cc9a
Changing imports on code.
jmaat Jun 21, 2018
d48b3b7
Changed calc_improper back to index, and removed rot_matrix variable …
jmaat Jun 21, 2018
91e04b3
Remove unecessary import startement
jmaat Jun 21, 2018
113a542
add translate function for changing valence move
vtlim Jun 22, 2018
373d691
Cleaned up code, output file not updated to .sdf yet
jmaat Jun 26, 2018
45481a0
Cleaning up code
jmaat Jun 26, 2018
4265e88
Cleaning up code
jmaat Jun 26, 2018
4511c55
Cleaned up code.
jmaat Jun 27, 2018
2ec366b
Upated code with .sdf file outputs
jmaat Jun 29, 2018
b2c40b1
Adding a README [WIP]
jmaat Jul 6, 2018
7e75da3
Code updated for input of .mol2 files to oemols
jmaat Jul 18, 2018
df2148f
Code updated to perturb back and forth for full range around minimize…
jmaat Jul 18, 2018
2d4ce8f
Added scripts for the Off-Nitrogens pipeline.
jmaat Sep 24, 2018
b9098a6
Adding python notebook to branch
jmaat Sep 27, 2018
0405550
update optmizer notebook
jmaat Sep 28, 2018
86eb6b8
Update readme, test
jmaat Oct 29, 2018
7517b37
Contains script that processes and stores QM and MM data. The script …
jmaat Dec 8, 2018
bced346
update
jmaat Dec 8, 2018
4d757e9
Update script
jmaat Dec 11, 2018
ae1b4d3
Update
jmaat Dec 12, 2018
01d12de
updated script
jmaat Dec 13, 2018
ccc399a
Updated datap processing code and plotting function
jmaat Jan 31, 2019
14838f6
Delete grep_energy.ssh
jmaat Jan 31, 2019
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
480 changes: 480 additions & 0 deletions ForceBalance_12mol_plots/allData/process_QMMM.py

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions mmCalc/mol2_geometric/mol6_scan_40_40/Data_Processing/calc_improper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#!/usr/bin/env python

#=============================================================================================
# MODULE DOCSTRING
#=============================================================================================

"""
calc_improper.py

Find and calculate improper dihedral angles in a given molecule.
Code loosely follows OpenMM: https://tinyurl.com/y8mhwxlv

Let's say we have j as central atom and call addTorsion(j, i, k, l).
Then we compute the following vectors:

v0 = j-i
v1 = k-i
v2 = k-l
w0 = v0 x v1
w1 = v1 x v2

The final improper angle is computed as the angle between w0 and w1.

By: Victoria Lim <limvt@uci.edu>

"""

#=============================================================================================
# GLOBAL IMPORTS
#=============================================================================================

import numpy as np
import openeye.oechem as oechem

#=============================================================================================
# PRIVATE SUBROUTINES
#=============================================================================================

def angle_between(v1, v2):
"""
Calculate the angle in degrees between vectors 'v1' and 'v2'.
Modified from: https://tinyurl.com/yb89sstz

Parameters
----------
v1 : tuple, list, or numpy array
v2 : tuple, list, or numpy array

Returns
-------
float
Angle in degrees.

"""
v1_u = v1/np.linalg.norm(v1)
v2_u = v2/np.linalg.norm(v2)
return np.degrees(np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0)))

def calc_valence_angle(atom0, atom1, atom2):
"""
Calculate the valence angle of three atoms.

Parameters
----------
atom0 : numpy array
CENTRAL atom coordinates
atom1 : numpy array
outer atom coordinates
atom2 : numpy array
outer atom coordinates

Returns
-------
float
Angle in degrees.
"""
v1 = atom1-atom0
v2 = atom2-atom0
return(angle_between(v1, v2))

def calc_improper_angle(atom0, atom1, atom2, atom3, translate=False):
"""
Calculate the improper dihedral angle of a set of given four atoms.

Parameters
----------
atom0 : numpy array
CENTRAL atom coordinates
atom1 : numpy array
outer atom coordinates
atom2 : numpy array
outer atom coordinates
atom3 : numpy array
outer atom coordinates
translate : bool
True to translate central atom to origin, False to keep as is.
This should not affect the results of the calculation.

Returns
-------
float
Angle in degrees.
"""
if translate:
atom1 = atom1 - atom0
atom2 = atom2 - atom0
atom3 = atom3 - atom0
atom0 = atom0 - atom0 # central must be moved last

# calculate vectors
v0 = atom0-atom1
v1 = atom2-atom1
v2 = atom2-atom3
w1 = np.cross(v0, v1)
w2 = np.cross(v1, v2)
angle = angle_between(w1,w2) # this angle should be in range [0,90]

# compute distance from plane to central atom
# eq 6 from http://mathworld.wolfram.com/Point-PlaneDistance.html
# here I'm using atom1 for (x,y,z), but could also use atom2 or atom3
numer = w2[0]*(atom0[0]-atom1[0]) + w2[1]*(atom0[1]-atom1[1]) + w2[2]*(atom0[2]-atom1[2])
denom = np.sqrt(w2[0]**2 + w2[1]**2 + w2[2]**2)
dist = numer/denom
# set reference so that if central atom is above plane, angle -> [90,180]
if dist > 0:
angle = 180-angle

return angle

def find_improper_angles(mol):
"""
Find the improper dihedral angles in some molecule. Currently supports
those with a central trivalent nitrogen atom.

Parameters
----------
mol : OpenEye oemol
oemol in which to look for improper angles

Returns
-------
list
Each element in the list is a 4-tuple of the coordinates for the
atoms involved in the improper. The central atom is listed first
in the tuple. Each member of the tuple is a numpy array.
list
List of strings for atoms in the improper, central atom is first.
"""

mol_coords = mol.GetCoords()
crdlist = []
Idxlist = []
for atom in mol.GetAtoms(oechem.OEIsInvertibleNitrogen()):
# central atom
aidx = atom.GetIdx()
crd0 = np.asarray(mol_coords[aidx])
# sort the neighbors
nbors = sorted(list(atom.GetAtoms()))
#check if there are 3 atoms connected to central atom in improper
if len(nbors) != 3:
return crdlist, namelist
crd1 = np.asarray(mol_coords[nbors[0].GetIdx()])
crd2 = np.asarray(mol_coords[nbors[1].GetIdx()])
crd3 = np.asarray(mol_coords[nbors[2].GetIdx()])
# store coordinates
crdlist.append([crd0, crd1, crd2, crd3])
Idxlist.append([atom.GetIdx(), nbors[0].GetIdx(), nbors[1].GetIdx(),nbors[2].GetIdx()])


return crdlist, Idxlist



Loading