1
|
|
"""
|
2
|
|
test_proc_tags.py
|
3
|
|
"""
|
4
|
0
|
import sys
|
5
|
0
|
import os
|
6
|
0
|
import pytest
|
7
|
|
|
8
|
|
# define location of input files for testing
|
9
|
0
|
mydir = os.path.dirname(os.path.abspath(__file__))
|
10
|
|
|
11
|
|
# import functions to aid testing
|
12
|
0
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers'))
|
13
|
0
|
from helper import *
|
14
|
|
|
15
|
0
|
from quanformer.proc_tags import *
|
16
|
|
|
17
|
|
# -----------------------
|
18
|
|
|
19
|
0
|
def test_define_tag():
|
20
|
0
|
tag = define_tag("QM opt energy", "Psi4", "mp2", "def2-SV(P)")
|
21
|
0
|
assert tag == "QM Psi4 Final Opt. Energy (Har) mp2/def2-SV(P)"
|
22
|
0
|
tag = define_tag("QM opt energy scs", "Psi4", "mp2", "def2-SV(P)")
|
23
|
0
|
assert tag == "QM Psi4 Final Opt. Energy (Har) SCS-mp2/def2-SV(P)"
|
24
|
0
|
tag = define_tag("QM opt energy initial", "Psi4", "mp2", "def2-SV(P)")
|
25
|
0
|
assert tag == "QM Psi4 Initial Opt. Energy (Har) mp2/def2-SV(P)"
|
26
|
0
|
tag = define_tag("QM spe", "Psi4", "mp2", "def2-SV(P)")
|
27
|
0
|
assert tag == "QM Psi4 Final Single Pt. Energy (Har) mp2/def2-SV(P)"
|
28
|
0
|
tag = define_tag("QM spe scs", "Psi4", "mp2", "def2-SV(P)")
|
29
|
0
|
assert tag == "QM Psi4 Final Single Pt. Energy (Har) SCS-mp2/def2-SV(P)"
|
30
|
0
|
tag = define_tag("MM opt energy", None, None, None)
|
31
|
0
|
assert tag == "MM Szybki SD Energy"
|
32
|
0
|
tag = define_tag("original index", None, None, None)
|
33
|
0
|
assert tag == "Original omega conformer number"
|
34
|
0
|
tag = define_tag("opt runtime", "Psi4", "mp2", "def2-SV(P)")
|
35
|
0
|
assert tag == "QM Psi4 Opt. Runtime (sec) mp2/def2-SV(P)"
|
36
|
0
|
tag = define_tag("spe runtime", "Psi4", "mp2", "def2-SV(P)")
|
37
|
0
|
assert tag == "QM Psi4 Single Pt. Runtime (sec) mp2/def2-SV(P)"
|
38
|
0
|
tag = define_tag("opt step", "Psi4", "mp2", "def2-SV(P)")
|
39
|
0
|
assert tag == "QM Psi4 Opt. Steps mp2/def2-SV(P)"
|
40
|
|
|
41
|
0
|
def test_get_sd_list():
|
42
|
0
|
mols = read_mol(os.path.join(mydir, 'data_tests', 'two_alkanes_prefilt.sdf'), True)
|
43
|
0
|
mol = next(mols)
|
44
|
0
|
data = get_sd_list(mol, "MM opt energy")
|
45
|
0
|
assert len(data) == 9
|
46
|
0
|
assert data[3] == '6.736580988585'
|
47
|
|
|
48
|
0
|
def test_get_sd_list_fail():
|
49
|
0
|
mols = read_mol(os.path.join(mydir, 'data_tests', 'two_alkanes_prefilt.sdf'), True)
|
50
|
0
|
mol = next(mols)
|
51
|
0
|
with pytest.raises(NameError):
|
52
|
0
|
data = get_sd_list(mol, "blah")
|
53
|
0
|
assert True
|
54
|
|
|
55
|
0
|
def test_set_sd_tags_hess():
|
56
|
0
|
mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
|
57
|
0
|
props = {
|
58
|
|
'method': 'test-m',
|
59
|
|
'basis': 'test-b',
|
60
|
|
'package': 'test-p',
|
61
|
|
'time': -1
|
62
|
|
}
|
63
|
0
|
set_sd_tags(mol, props, 'hess')
|
64
|
0
|
assert oechem.OEHasSDData(
|
65
|
|
mol, "QM test-p Hessian Runtime (sec) test-m/test-b") == True
|
66
|
0
|
assert oechem.OEGetSDData(
|
67
|
|
mol, "QM test-p Hessian Runtime (sec) test-m/test-b") == '-1'
|
68
|
|
|
69
|
|
|
70
|
0
|
def test_set_sd_tags_spe_notfinish():
|
71
|
0
|
mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
|
72
|
0
|
props = {
|
73
|
|
'method': 'test-m',
|
74
|
|
'basis': 'test-b',
|
75
|
|
'package': 'test-p',
|
76
|
|
'time': -1
|
77
|
|
}
|
78
|
0
|
set_sd_tags(mol, props, 'spe')
|
79
|
0
|
assert oechem.OEHasSDData(
|
80
|
|
mol, "QM test-p Single Pt. Runtime (sec) test-m/test-b") == True
|
81
|
0
|
assert oechem.OEGetSDData(
|
82
|
|
mol, "QM test-p Single Pt. Runtime (sec) test-m/test-b") == '-1'
|
83
|
0
|
assert oechem.OEHasSDData(mol, "Note on Single Pt. test-m/test-b") == True
|
84
|
0
|
assert oechem.OEGetSDData(
|
85
|
|
mol, "Note on Single Pt. test-m/test-b") == "JOB DID NOT FINISH"
|
86
|
|
|
87
|
|
|
88
|
0
|
def test_set_sd_tags_spe_didfinish():
|
89
|
0
|
mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
|
90
|
0
|
props = {
|
91
|
|
'method': 'test-m',
|
92
|
|
'basis': 'test-b',
|
93
|
|
'package': 'test-p',
|
94
|
|
'time': -1,
|
95
|
|
'finalEnergy': -2
|
96
|
|
}
|
97
|
0
|
set_sd_tags(mol, props, 'spe')
|
98
|
0
|
assert oechem.OEHasSDData(
|
99
|
|
mol, "QM test-p Single Pt. Runtime (sec) test-m/test-b") == True
|
100
|
0
|
assert oechem.OEGetSDData(
|
101
|
|
mol, "QM test-p Single Pt. Runtime (sec) test-m/test-b") == '-1'
|
102
|
0
|
assert oechem.OEHasSDData(
|
103
|
|
mol, "QM test-p Final Single Pt. Energy (Har) test-m/test-b") == True
|
104
|
0
|
assert oechem.OEGetSDData(
|
105
|
|
mol, "QM test-p Final Single Pt. Energy (Har) test-m/test-b") == '-2'
|
106
|
|
|
107
|
|
|
108
|
0
|
def test_set_sd_tags_spe_scs():
|
109
|
|
# TODO
|
110
|
0
|
pass
|
111
|
|
|
112
|
|
|
113
|
0
|
def test_set_sd_tags_opt():
|
114
|
|
# TODO
|
115
|
0
|
pass
|
116
|
|
|
117
|
|
|
118
|
0
|
def test_set_sd_tags_opt_scs():
|
119
|
|
# TODO
|
120
|
0
|
pass
|
121
|
|
|
122
|
|
|
123
|
0
|
def test_delete_tag():
|
124
|
0
|
mols = read_mol(os.path.join(mydir, 'data_tests', 'carbon-222.sdf'), True)
|
125
|
0
|
mol = next(mols)
|
126
|
0
|
conf = list(mol.GetConfs())[0]
|
127
|
0
|
taglabel = 'MM Szybki SD Energy'
|
128
|
0
|
assert oechem.OEHasSDData(conf, taglabel) == True
|
129
|
0
|
delete_tag(mol, taglabel)
|
130
|
0
|
assert oechem.OEHasSDData(conf, taglabel) == False
|
131
|
|
|
132
|
|
|
133
|
|
# test manually without pytest
|
134
|
|
if 1:
|
135
|
0
|
test_get_sd_list()
|