forked from vtlim/off_psi4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocTags.py
More file actions
129 lines (97 loc) · 4.92 KB
/
Copy pathprocTags.py
File metadata and controls
129 lines (97 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python
## Description:
## Usage: import procTags as pt, then call pt.SetOptSDTags(args)
import openeye.oechem as oechem
def GetSDList(Mol, prop, Package='Psi4', Method=None, Basisset=None):
"""
Get list of specified SD tag for all confs in Mol.
Parameters
----------
Mol: OEChem molecule with all of its conformers
prop: string description of property of interest
options implemented: "QM opt energy" "MM opt energy"
Package: software package used for QM calculation. Psi4 or Turbomole.
Method: string, for specific properties. e.g. 'mp2'
Basisset: string, for specific properties. e.g. '6-31+G(d)'
Returns
-------
sdlist: A 1D N-length list for N conformers with property from SDTag.
"""
if prop=="QM opt energy":
taglabel = "QM %s Final Opt. Energy (Har) %s/%s" % (Package, Method, Basisset)
if prop=="QM spe":
taglabel = "QM %s Single Pt. Energy (Har) %s/%s" % (Package, Method, Basisset)
if prop=="MM opt energy":
taglabel = "MM Szybki Newton Energy"
if prop=="original index":
taglabel = "Original omega conformer number"
if prop=="opt runtime":
taglabel = "QM %s Opt. Runtime (sec) %s/%s" % (Package, Method, Basisset)
if prop=="spe runtime":
taglabel = "QM %s Single Pt. Runtime (sec) %s/%s" % (Package, Method, Basisset)
if prop=="opt step":
taglabel = "QM %s Opt. Steps %s/%s" % (Package, Method, Basisset)
SDList = []
for j, conf in enumerate( Mol.GetConfs() ):
for x in oechem.OEGetSDDataPairs(conf):
#dir(x) yields ['GetTag', 'GetValue', 'SetTag', 'SetValue', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', '_itr', 'this', 'thisown']
# Case: opt did not finish --> append nan
if "Note on opt." in x.GetTag() and "DID NOT FINISH" in x.GetValue():
SDList.append('nan')
break
# Case: want energy value
# Case: want original index number
#elif taglabel.lower() in x.GetTag().lower() or prop =="original index":
elif taglabel.lower() in x.GetTag().lower():
SDList.append(x.GetValue())
break
#for j, conf in enumerate( Mol.GetConfs() ):
# if "DID NOT FINISH" not in oechem.OEGetSDData(conf, "Note on opt.")\
# or prop =="original index":
# SDList.append((oechem.OEGetSDData(conf, taglabel)))
# else:
# SDList.append('nan')
return SDList
def SetOptSDTags(Conf, Props, spe=False):
"""
WORDS WORDS WORDS
Parameters
----------
Conf: Single conformer from OEChem molecule
Props: Dictionary output from ProcessOutput function.
Should contain the keys: basis, method, numSteps,
initEnergy, finalEnergy, coords, time, pkg
spe: Boolean - are the results of a single point energy calcn?
"""
# get level of theory for setting SD tags
method = Props['method']
basisset = Props['basis']
pkg = Props['package']
# check that finalEnergy is there. if not, opt probably did not finish
# make a note of that in SD tag
if not 'finalEnergy' in Props:
if not spe: oechem.OEAddSDData(Conf, "Note on opt. %s/%s" \
% (method, basisset), "JOB DID NOT FINISH")
else: oechem.OEAddSDData(Conf, "Note on SPE %s/%s"\
% (method, basisset), "JOB DID NOT FINISH")
return
# Set new SD tag for conformer's final energy
if not spe: taglabel = "QM %s Final Opt. Energy (Har) %s/%s" % (pkg, method, basisset)
else: taglabel = "QM %s Single Pt. Energy (Har) %s/%s" % (pkg, method, basisset)
oechem.OEAddSDData(Conf, taglabel, str(Props['finalEnergy']))
# Set new SD tag for wall-clock time
if not spe: taglabel = "QM %s Opt. Runtime (sec) %s/%s" % (pkg, method, basisset)
else: taglabel = "QM %s Single Pt. Runtime (sec) %s/%s" % (pkg, method, basisset)
oechem.OEAddSDData(Conf, taglabel, str(Props['time']))
if spe: return # stop here if SPE
# Set new SD tag for original conformer number
# !! Opt2 files should ALREADY have this !! Opt2 index is NOT orig index!
taglabel = "Original omega conformer number"
if not oechem.OEHasSDData(Conf, taglabel): # only add tag if not existing
oechem.OEAddSDData(Conf, taglabel, str(Conf.GetIdx()+1))
# Set new SD tag for numSteps of geom. opt.
taglabel = "QM %s Opt. Steps %s/%s" % (pkg, method, basisset)
oechem.OEAddSDData(Conf, taglabel, str(Props['numSteps']))
# Set new SD tag for conformer's initial energy
taglabel = "QM %s Initial Opt. Energy (Har) %s/%s" % (pkg, method, basisset)
oechem.OEAddSDData(Conf, taglabel, str(Props['initEnergy']))