Auto3D 2.2.7__tar.gz → 2.2.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Auto3D-2.2.7/src/Auto3D.egg-info → Auto3D-2.2.8}/PKG-INFO +4 -1
- {Auto3D-2.2.7 → Auto3D-2.2.8}/README.md +3 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/setup.cfg +1 -1
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/auto3D.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/auto3D.py +3 -2
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/__pycache__/batchopt.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/batchopt.py +81 -55
- {Auto3D-2.2.7 → Auto3D-2.2.8/src/Auto3D.egg-info}/PKG-INFO +4 -1
- {Auto3D-2.2.7 → Auto3D-2.2.8}/LICENSE +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/MANIFEST.in +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/pyproject.toml +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/.gitignore +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/__init__.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/__pycache__/geometry.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/__pycache__/thermo.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/geometry.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ASE/thermo.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/SPE.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__init__.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/SPE.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/isomer_engine.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/ranking.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/tautomer.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/utils.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/__pycache__/utils_file.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/ANI2xt_no_rep.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/ANI2xt_rep.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/__init__.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/__pycache__/ANI2xt_no_rep.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/batch_opt/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/isomer_engine.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/models/__init__.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/models/aimnet2_wb97m-d3_0.jpt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/models/aimnet2_wb97m_ens_f.jpt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/models/ani2xt_no_repulsion.pt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/ranking.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/tautomer.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/utils.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D/utils_file.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D.egg-info/SOURCES.txt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D.egg-info/dependency_links.txt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D.egg-info/requires.txt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/src/Auto3D.egg-info/top_level.txt +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_SPE.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_auto3D.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_isomer_engine.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_tauto.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_thermo.py +0 -0
- {Auto3D-2.2.7 → Auto3D-2.2.8}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: Auto3D
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.8
|
|
4
4
|
Summary: Generating Low-energy 3D Conformers from SMILES/SDF
|
|
5
5
|
Home-page: https://github.com/isayevlab/Auto3D_pkg
|
|
6
6
|
Author: 'Zhen Liu, Tetiana Zubatiuk, Adrian Roitberg, Olexandr Isayev'
|
|
@@ -32,6 +32,9 @@ Requires-Dist: pyyaml
|
|
|
32
32
|
|
|
33
33
|
Please check out the information at [**documentation**](https://auto3d.readthedocs.io/en/latest/index.html), including [installation](https://auto3d.readthedocs.io/en/latest/installation.html), [usage](https://auto3d.readthedocs.io/en/latest/usage.html), [API](https://auto3d.readthedocs.io/en/latest/api.html) and [citation](https://auto3d.readthedocs.io/en/latest/citation.html).
|
|
34
34
|
|
|
35
|
+
- **Jupyter notebook examples** can be found [here](https://github.com/isayevlab/Auto3D_pkg/tree/main/example)
|
|
36
|
+
- To-do list for **improvement and new features** can be found [here](https://github.com/isayevlab/Auto3D_pkg/discussions). You are welcomed to share your thoughts.
|
|
37
|
+
- Bugs go to the [issues](https://github.com/isayevlab/Auto3D_pkg/issues)
|
|
35
38
|
|
|
36
39
|
## Minimum Dependencies Installatioin
|
|
37
40
|
1. Python >= 3.7
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
Please check out the information at [**documentation**](https://auto3d.readthedocs.io/en/latest/index.html), including [installation](https://auto3d.readthedocs.io/en/latest/installation.html), [usage](https://auto3d.readthedocs.io/en/latest/usage.html), [API](https://auto3d.readthedocs.io/en/latest/api.html) and [citation](https://auto3d.readthedocs.io/en/latest/citation.html).
|
|
15
15
|
|
|
16
|
+
- **Jupyter notebook examples** can be found [here](https://github.com/isayevlab/Auto3D_pkg/tree/main/example)
|
|
17
|
+
- To-do list for **improvement and new features** can be found [here](https://github.com/isayevlab/Auto3D_pkg/discussions). You are welcomed to share your thoughts.
|
|
18
|
+
- Bugs go to the [issues](https://github.com/isayevlab/Auto3D_pkg/issues)
|
|
16
19
|
|
|
17
20
|
## Minimum Dependencies Installatioin
|
|
18
21
|
1. Python >= 3.7
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = Auto3D
|
|
3
|
-
version = 2.2.
|
|
3
|
+
version = 2.2.8
|
|
4
4
|
author = 'Zhen Liu, Tetiana Zubatiuk, Adrian Roitberg, Olexandr Isayev'
|
|
5
5
|
author_email = liu5@andrew.cmu.edu, tetiana@zubatyuk.com, roitberg@ufl.edu, olexandr@olexandrisayev.com
|
|
6
6
|
description = Generating Low-energy 3D Conformers from SMILES/SDF
|
|
Binary file
|
|
@@ -267,9 +267,9 @@ def main(args:dict):
|
|
|
267
267
|
start = time.time()
|
|
268
268
|
# job_name = datetime.now().strftime("%Y%m%d-%H%M%S-%f") #adds microsecond in the end
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
if path0 is None:
|
|
270
|
+
if args.path is None:
|
|
272
271
|
sys.exit("Please specify the input file path.")
|
|
272
|
+
path0, mapping = encode_ids(args.path)
|
|
273
273
|
input_format = os.path.splitext(path0)[1][1:]
|
|
274
274
|
if (input_format != "smi") and (input_format != "sdf"):
|
|
275
275
|
sys.exit("Input file type is not supported. Only .smi and .sdf are supported. But the input file is " + input_format + ".")
|
|
@@ -441,6 +441,7 @@ def main(args:dict):
|
|
|
441
441
|
logger.info(f'Program running time: {running_time_h} hour(s) and {remaining_minutes} minute(s)')
|
|
442
442
|
reorder_sdf(path_combined, path0)
|
|
443
443
|
path_combined = decode_ids(path_combined, mapping)
|
|
444
|
+
os.remove(path0)
|
|
444
445
|
print(f"Output path: {path_combined}", flush=True)
|
|
445
446
|
logger.info(f"Output path: {path_combined}")
|
|
446
447
|
logging_queue.put(None)
|
|
Binary file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Original source: /labspace/models/aimnet/batch_opt_script/
|
|
2
|
-
import torch
|
|
3
|
-
import logging
|
|
4
|
-
import warnings
|
|
5
2
|
import os
|
|
3
|
+
|
|
6
4
|
import numpy as np
|
|
5
|
+
import torch
|
|
6
|
+
|
|
7
7
|
try:
|
|
8
8
|
import torchani
|
|
9
9
|
except:
|
|
@@ -11,6 +11,7 @@ except:
|
|
|
11
11
|
from collections import defaultdict
|
|
12
12
|
from rdkit import Chem
|
|
13
13
|
from rdkit.Chem import rdmolops
|
|
14
|
+
|
|
14
15
|
try:
|
|
15
16
|
from .ANI2xt_no_rep import ANI2xt
|
|
16
17
|
except:
|
|
@@ -20,10 +21,13 @@ from Auto3D.utils import hartree2ev
|
|
|
20
21
|
|
|
21
22
|
torch.backends.cuda.matmul.allow_tf32 = False
|
|
22
23
|
torch.backends.cudnn.allow_tf32 = False
|
|
24
|
+
|
|
25
|
+
|
|
23
26
|
# hartree2eV = 27.211385
|
|
24
27
|
@torch.jit.script
|
|
25
28
|
class FIRE():
|
|
26
29
|
"""a general optimization program """
|
|
30
|
+
|
|
27
31
|
# For a list of documentation for different optimization programs: https://wiki.fysik.dtu.dk/ase/ase/optimize.html
|
|
28
32
|
def __init__(self, coord):
|
|
29
33
|
## default parameters
|
|
@@ -55,13 +59,17 @@ class FIRE():
|
|
|
55
59
|
a = self.a.unsqueeze(-1).unsqueeze(-1)
|
|
56
60
|
v = self.v
|
|
57
61
|
f = forces
|
|
58
|
-
self.v = (1.0 - a) * v + a * v.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(
|
|
62
|
+
self.v = (1.0 - a) * v + a * v.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(
|
|
63
|
+
-1).unsqueeze(-1) * f / f.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(-1).unsqueeze(
|
|
64
|
+
-1)
|
|
59
65
|
self.Nsteps += 1
|
|
60
66
|
elif w_vf.any():
|
|
61
67
|
a = self.a[w_vf].unsqueeze(-1).unsqueeze(-1)
|
|
62
68
|
v = self.v[w_vf]
|
|
63
69
|
f = forces[w_vf]
|
|
64
|
-
self.v[w_vf] = (1.0 - a) * v + a * v.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(
|
|
70
|
+
self.v[w_vf] = (1.0 - a) * v + a * v.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(
|
|
71
|
+
-1).unsqueeze(-1) * f / f.flatten(-2, -1).norm(p=2, dim=-1).unsqueeze(-1).unsqueeze(
|
|
72
|
+
-1)
|
|
65
73
|
|
|
66
74
|
w_N = self.Nsteps > self.Nmin
|
|
67
75
|
w_vfN = w_vf & w_N
|
|
@@ -109,7 +117,8 @@ class EnForce_ANI(torch.nn.Module):
|
|
|
109
117
|
Returns:
|
|
110
118
|
the energies and forces for the input molecules. One time calculation.
|
|
111
119
|
"""
|
|
112
|
-
|
|
120
|
+
|
|
121
|
+
def __init__(self, ani, name, batchsize_atoms=1024 * 16):
|
|
113
122
|
super().__init__()
|
|
114
123
|
self.add_module('ani', ani)
|
|
115
124
|
self.name = name
|
|
@@ -134,7 +143,8 @@ class EnForce_ANI(torch.nn.Module):
|
|
|
134
143
|
if self.name == "AIMNET":
|
|
135
144
|
# torch.set_grad_enabled(True)
|
|
136
145
|
# torch._C._set_grad_enabled(True)
|
|
137
|
-
d = self.ani(
|
|
146
|
+
d = self.ani(
|
|
147
|
+
dict(coord=coord, numbers=numbers, charge=charges)) # Output from the model
|
|
138
148
|
# e = (d['energy'] + d['disp_energy']).to(torch.double)
|
|
139
149
|
e = d['energy'].to(torch.double)
|
|
140
150
|
# g = torch.autograd.grad([e.sum()], [coord])[0] # size(100, 23, 3)
|
|
@@ -147,13 +157,13 @@ class EnForce_ANI(torch.nn.Module):
|
|
|
147
157
|
f = -g
|
|
148
158
|
elif self.name == "ANI2x":
|
|
149
159
|
e = self.ani((numbers, coord)).energies
|
|
150
|
-
e = e * hartree2ev #ANI2x (torch.models.ANI2x()) output energy unit is Hatree;
|
|
151
|
-
|
|
160
|
+
e = e * hartree2ev # ANI2x (torch.models.ANI2x()) output energy unit is Hatree;
|
|
161
|
+
# ANI ASE interface unit is eV
|
|
152
162
|
g = torch.autograd.grad([e.sum()], [coord])[0]
|
|
153
163
|
f = -g
|
|
154
164
|
return e, f
|
|
155
165
|
|
|
156
|
-
# @torch.jit.script_method
|
|
166
|
+
# @torch.jit.script_method
|
|
157
167
|
def forward_batched(self, coord, numbers, charges):
|
|
158
168
|
"""Calculate the energies and forces for input molecules.
|
|
159
169
|
|
|
@@ -171,26 +181,28 @@ class EnForce_ANI(torch.nn.Module):
|
|
|
171
181
|
e = []
|
|
172
182
|
f = []
|
|
173
183
|
idx = torch.arange(B, device=coord.device)
|
|
174
|
-
for batch in idx.split(self.batchsize_atoms // N): #How was the batchsize_atoms decided?
|
|
184
|
+
for batch in idx.split(self.batchsize_atoms // N): # How was the batchsize_atoms decided?
|
|
175
185
|
_e, _f = self(coord[batch], numbers[batch], charges[batch])
|
|
176
186
|
e.append(_e)
|
|
177
187
|
f.append(_f)
|
|
178
188
|
return torch.cat(e, dim=0), torch.cat(f, dim=0)
|
|
179
189
|
|
|
190
|
+
|
|
180
191
|
def print_stats(state, patience):
|
|
181
192
|
"""Print the optimization status"""
|
|
182
193
|
numbers = state['numbers']
|
|
183
194
|
num_total = numbers.size()[0]
|
|
184
195
|
num_converged_dropped = torch.sum(state['converged_mask']).to('cpu')
|
|
185
|
-
oscillating_count = state['oscilating_count'].to('cpu').reshape(-1,) >= patience
|
|
196
|
+
oscillating_count = state['oscilating_count'].to('cpu').reshape(-1, ) >= patience
|
|
186
197
|
num_dropped = torch.sum(oscillating_count)
|
|
187
198
|
num_converged = num_converged_dropped - num_dropped
|
|
188
199
|
num_active = num_total - num_converged_dropped
|
|
189
|
-
print("Total 3D structures: %i Converged: %i Dropped(Oscillating): %i Active: %i" %
|
|
200
|
+
print("Total 3D structures: %i Converged: %i Dropped(Oscillating): %i Active: %i" %
|
|
190
201
|
(num_total, num_converged, num_dropped, num_active), flush=True)
|
|
191
202
|
# logging.info("Total 3D structures: %i Converged: %i Dropped(Oscillating): %i Active: %i" %
|
|
192
203
|
# (num_total, num_converged, num_dropped, num_active))
|
|
193
204
|
|
|
205
|
+
|
|
194
206
|
def n_steps(state, n, opttol, patience):
|
|
195
207
|
"""Doing n steps optimization for each input. Only converged structures are
|
|
196
208
|
modified at each step. n_steps does not change input conformer order.
|
|
@@ -207,58 +219,65 @@ def n_steps(state, n, opttol, patience):
|
|
|
207
219
|
optimizer = FIRE(coord)
|
|
208
220
|
# the following two terms are used to detect oscillating conformers
|
|
209
221
|
smallest_fmax0 = torch.tensor(np.ones((len(coord), 1)) * 999,
|
|
210
|
-
|
|
222
|
+
dtype=torch.float).to(coord.device)
|
|
211
223
|
oscilating_count0 = torch.tensor(np.zeros((len(coord), 1)),
|
|
212
224
|
dtype=torch.float).to(coord.device)
|
|
213
225
|
state["oscilating_count"] = oscilating_count0
|
|
214
|
-
assert(len(coord.shape) == 3)
|
|
215
|
-
assert(len(numbers.shape) == 2)
|
|
216
|
-
assert(len(charges.shape) == 1)
|
|
217
|
-
assert(len(smallest_fmax0.shape) == 2)
|
|
218
|
-
assert(len(oscilating_count0.shape) == 2)
|
|
219
|
-
for istep in tqdm(range(1, (n+1), 1)):
|
|
220
|
-
not_converged = ~ state['converged_mask'] #Essential tracker handle, size fixed
|
|
226
|
+
assert (len(coord.shape) == 3)
|
|
227
|
+
assert (len(numbers.shape) == 2)
|
|
228
|
+
assert (len(charges.shape) == 1)
|
|
229
|
+
assert (len(smallest_fmax0.shape) == 2)
|
|
230
|
+
assert (len(oscilating_count0.shape) == 2)
|
|
231
|
+
for istep in tqdm(range(1, (n + 1), 1)):
|
|
232
|
+
not_converged = ~ state['converged_mask'] # Essential tracker handle, size fixed
|
|
221
233
|
# stop optimization if all structures converged.
|
|
222
234
|
if not not_converged.any():
|
|
223
235
|
break
|
|
224
236
|
|
|
225
|
-
coord = state['coord'][not_converged] #Subset coordinates, size=not_converged.
|
|
237
|
+
coord = state['coord'][not_converged] # Subset coordinates, size=not_converged.
|
|
226
238
|
numbers = state['numbers'][not_converged]
|
|
227
239
|
charges = state['charges'][not_converged]
|
|
228
240
|
smallest_fmax = smallest_fmax0[not_converged]
|
|
229
241
|
oscilating_count = state["oscilating_count"][not_converged]
|
|
230
242
|
|
|
231
243
|
coord.requires_grad_(True)
|
|
232
|
-
e, f = state['nn'].forward_batched(coord, numbers,
|
|
244
|
+
e, f = state['nn'].forward_batched(coord, numbers,
|
|
245
|
+
charges) # Key step to calculate all energies and forces.
|
|
233
246
|
coord.requires_grad_(False)
|
|
234
247
|
|
|
235
248
|
coord = optimizer(coord, f)
|
|
236
|
-
fmax = f.norm(dim=-1).max(dim=-1)[
|
|
237
|
-
|
|
249
|
+
fmax = f.norm(dim=-1).max(dim=-1)[
|
|
250
|
+
0] # Tensor, Norm is the length of each vector. Here it returns the maximum force length for ecah conformer. Size (100)
|
|
251
|
+
assert (len(fmax.shape) == 1)
|
|
238
252
|
not_converged_post1 = fmax > opttol
|
|
239
253
|
|
|
240
|
-
#update smallest_fmax for each molecule
|
|
254
|
+
# update smallest_fmax for each molecule
|
|
241
255
|
fmax_reduced = fmax.reshape(-1, 1) < smallest_fmax
|
|
242
|
-
fmax_reduced = fmax_reduced.reshape(-1,)
|
|
256
|
+
fmax_reduced = fmax_reduced.reshape(-1, )
|
|
243
257
|
smallest_fmax[fmax_reduced] = fmax.reshape(-1, 1)[fmax_reduced]
|
|
244
|
-
#reduce count to 0 for reducing; raise count for non-reducing
|
|
258
|
+
# reduce count to 0 for reducing; raise count for non-reducing
|
|
245
259
|
oscilating_count[fmax_reduced] = 0
|
|
246
260
|
fmax_not_reduced = ~fmax_reduced
|
|
247
261
|
oscilating_count += fmax_not_reduced.reshape(-1, 1)
|
|
248
262
|
not_oscilating = oscilating_count < patience
|
|
249
|
-
not_oscilating = not_oscilating.reshape(-1,)
|
|
263
|
+
not_oscilating = not_oscilating.reshape(-1, )
|
|
250
264
|
not_converged_post = not_converged_post1 & not_oscilating
|
|
251
265
|
|
|
252
|
-
optimizer.clean(not_converged_post) #Subset v, a in FIRE for next optimization
|
|
253
|
-
|
|
254
|
-
state['converged_mask'][
|
|
255
|
-
|
|
256
|
-
state['
|
|
257
|
-
|
|
266
|
+
optimizer.clean(not_converged_post) # Subset v, a in FIRE for next optimization
|
|
267
|
+
|
|
268
|
+
state['converged_mask'][
|
|
269
|
+
not_converged] = ~ not_converged_post # Update converged_mask, so that converged structures will not be updated in future steps.
|
|
270
|
+
state['fmax'][
|
|
271
|
+
not_converged] = fmax # Update fmax for conformers that are optimized in this iteration
|
|
272
|
+
state['energy'][
|
|
273
|
+
not_converged] = e.detach() # Update energy for conformers that are optimized in this iteration
|
|
274
|
+
state['coord'][
|
|
275
|
+
not_converged] = coord # Update coordinates for conformers that are optimized in this iteration
|
|
258
276
|
smallest_fmax0[not_converged] = smallest_fmax # update smalles_fmax for each conformer
|
|
259
|
-
state["oscilating_count"][
|
|
260
|
-
|
|
261
|
-
|
|
277
|
+
state["oscilating_count"][
|
|
278
|
+
not_converged] = oscilating_count # update counts for continuous no reduction in fmax
|
|
279
|
+
|
|
280
|
+
if (istep % (n // 10)) == 0:
|
|
262
281
|
print_stats(state, patience)
|
|
263
282
|
if istep == (n):
|
|
264
283
|
print("Reaching maximum optimization step: ", end="")
|
|
@@ -286,9 +305,10 @@ def ensemble_opt(net, coord, numbers, charges, param, model, device):
|
|
|
286
305
|
numbers = torch.tensor(numbers, dtype=torch.long, device=device)
|
|
287
306
|
charges = torch.tensor(charges, dtype=torch.long, device=device)
|
|
288
307
|
converged_mask = torch.zeros(coord.shape[0], dtype=torch.bool, device=device)
|
|
289
|
-
fmax = torch.full(coord.shape[:1], 999.0,
|
|
308
|
+
fmax = torch.full(coord.shape[:1], 999.0,
|
|
309
|
+
device=coord.device) # size=N, a tensored filled with 999.0, representing the current maximum forces at each conformer.
|
|
290
310
|
energy = torch.full(coord.shape[:1], 999.0, dtype=torch.double, device=coord.device)
|
|
291
|
-
ids = torch.arange(coord.shape[0], device=coord.device) #Returns a 1D tensor
|
|
311
|
+
ids = torch.arange(coord.shape[0], device=coord.device) # Returns a 1D tensor
|
|
292
312
|
# optimizer = FIRE(coord)
|
|
293
313
|
|
|
294
314
|
state = dict(
|
|
@@ -297,7 +317,7 @@ def ensemble_opt(net, coord, numbers, charges, param, model, device):
|
|
|
297
317
|
# optimizer=optimizer, nn=net, fmax=fmax, energy=energy,
|
|
298
318
|
nn=net, fmax=fmax, energy=energy,
|
|
299
319
|
timing=defaultdict(float), charges=charges,
|
|
300
|
-
he=list(), close=list()
|
|
320
|
+
he=list(), close=list() # !!! he and close?
|
|
301
321
|
)
|
|
302
322
|
|
|
303
323
|
n_steps(state, param['opt_steps'], param['opttol'], param['patience'])
|
|
@@ -316,9 +336,10 @@ def ensemble_opt(net, coord, numbers, charges, param, model, device):
|
|
|
316
336
|
|
|
317
337
|
def padding_coords(lists, pad_value=0.0):
|
|
318
338
|
lengths = [len(lst) for lst in lists]
|
|
319
|
-
|
|
339
|
+
max_length = max(lengths)
|
|
340
|
+
pad_length = [max_length - len(lst) for lst in lists]
|
|
320
341
|
assert (len(pad_length) == len(lists))
|
|
321
|
-
|
|
342
|
+
|
|
322
343
|
lists_padded = []
|
|
323
344
|
for i in range(len(pad_length)):
|
|
324
345
|
lst_i = lists[i]
|
|
@@ -327,11 +348,13 @@ def padding_coords(lists, pad_value=0.0):
|
|
|
327
348
|
lists_padded.append(lst_i_padded)
|
|
328
349
|
return lists_padded
|
|
329
350
|
|
|
351
|
+
|
|
330
352
|
def padding_species(lists, pad_value=-1):
|
|
331
353
|
lengths = [len(lst) for lst in lists]
|
|
332
|
-
|
|
354
|
+
max_length = max(lengths)
|
|
355
|
+
pad_length = [max_length - len(lst) for lst in lists]
|
|
333
356
|
assert (len(pad_length) == len(lists))
|
|
334
|
-
|
|
357
|
+
|
|
335
358
|
lists_padded = []
|
|
336
359
|
for i in range(len(pad_length)):
|
|
337
360
|
lst_i = lists[i]
|
|
@@ -344,13 +367,13 @@ def padding_species(lists, pad_value=-1):
|
|
|
344
367
|
def mols2lists(mols, model):
|
|
345
368
|
'''mols: rdkit mol object'''
|
|
346
369
|
species_order = ("H", 'C', 'N', 'O', 'S', 'F', 'Cl')
|
|
347
|
-
ani2xt_index = {1:0, 6:1, 7:2, 8:3, 9:4, 16:5, 17:6}
|
|
370
|
+
ani2xt_index = {1: 0, 6: 1, 7: 2, 8: 3, 9: 4, 16: 5, 17: 6}
|
|
348
371
|
# coord = [[a.coords for a in mol.atoms] for mol in mols]
|
|
349
372
|
coord = [mol.GetConformer().GetPositions().tolist() for mol in mols]
|
|
350
|
-
coord = [[tuple(xyz) for xyz in inner] for inner in coord] #to be consistent with legacy code
|
|
373
|
+
coord = [[tuple(xyz) for xyz in inner] for inner in coord] # to be consistent with legacy code
|
|
351
374
|
# charges = [mol.charge for mol in mols]
|
|
352
375
|
charges = [rdmolops.GetFormalCharge(mol) for mol in mols]
|
|
353
|
-
|
|
376
|
+
|
|
354
377
|
if model == "ANI2xt":
|
|
355
378
|
# numbers = [[ani2xt_index[a.atomicnum] for a in mol.atoms] for mol in mols]
|
|
356
379
|
numbers = [[ani2xt_index[a.GetAtomicNum()] for a in mol.GetAtoms()] for mol in mols]
|
|
@@ -370,16 +393,18 @@ class optimizing(object):
|
|
|
370
393
|
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
371
394
|
if model == "AIMNET":
|
|
372
395
|
# self.ani = torch.jit.load(os.path.join(root, "models/aimnet2nqed_pc14iall_b97m_sae.jpt"), map_location=device) # Return a ScriptModule object
|
|
373
|
-
self.ani = torch.jit.load(os.path.join(root, "models/aimnet2_wb97m_ens_f.jpt"),
|
|
396
|
+
self.ani = torch.jit.load(os.path.join(root, "models/aimnet2_wb97m_ens_f.jpt"),
|
|
397
|
+
map_location=device)
|
|
374
398
|
elif model == "ANI2xt":
|
|
375
399
|
self.ani = ANI2xt(device)
|
|
376
400
|
elif model == "ANI2x":
|
|
377
401
|
self.ani = torchani.models.ANI2x(periodic_table_index=True).to(device)
|
|
378
402
|
else:
|
|
379
403
|
raise ValueError("Model has to be ANI2x, ANI2xt or AIMNET.")
|
|
380
|
-
|
|
404
|
+
|
|
381
405
|
def run(self):
|
|
382
|
-
print("Preparing for parallel optimizing... (Max optimization steps: %i)" % self.config[
|
|
406
|
+
print("Preparing for parallel optimizing... (Max optimization steps: %i)" % self.config[
|
|
407
|
+
"opt_steps"])
|
|
383
408
|
# logging.info("Preparing for parallel optimizing... (Max optimization steps: %i)" % self.config["opt_steps"])
|
|
384
409
|
mols = list(Chem.SDMolSupplier(self.in_f, removeHs=False))
|
|
385
410
|
print(f"Total 3D conformers: {len(mols)}", flush=True)
|
|
@@ -392,13 +417,14 @@ class optimizing(object):
|
|
|
392
417
|
coord_padded = padding_coords(coord, 0)
|
|
393
418
|
numbers_padded = padding_species(numbers, -1)
|
|
394
419
|
|
|
395
|
-
for p in self.ani.parameters():
|
|
420
|
+
for p in self.ani.parameters():
|
|
396
421
|
p.requires_grad_(False)
|
|
397
|
-
ani = EnForce_ANI(self.ani, self.model, self.config[
|
|
422
|
+
ani = EnForce_ANI(self.ani, self.model, self.config[
|
|
423
|
+
"batchsize_atoms"]) # Interesting, EnForce_ANI inherites nn.module, bu can still accept a ScriptModule object as the input
|
|
398
424
|
|
|
399
425
|
with torch.jit.optimized_execution(False):
|
|
400
426
|
optdict = ensemble_opt(ani, coord_padded, numbers_padded, charges,
|
|
401
|
-
self.config, self.model, self.device) #Magic step
|
|
427
|
+
self.config, self.model, self.device) # Magic step
|
|
402
428
|
|
|
403
429
|
energies = optdict['energy']
|
|
404
430
|
fmax = optdict['fmax']
|
|
@@ -416,4 +442,4 @@ class optimizing(object):
|
|
|
416
442
|
coord = optdict['coord'][i]
|
|
417
443
|
for i, atom in enumerate(mol.GetAtoms()):
|
|
418
444
|
mol.GetConformer().SetAtomPosition(atom.GetIdx(), coord[i])
|
|
419
|
-
f.write(mol)
|
|
445
|
+
f.write(mol)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: Auto3D
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.8
|
|
4
4
|
Summary: Generating Low-energy 3D Conformers from SMILES/SDF
|
|
5
5
|
Home-page: https://github.com/isayevlab/Auto3D_pkg
|
|
6
6
|
Author: 'Zhen Liu, Tetiana Zubatiuk, Adrian Roitberg, Olexandr Isayev'
|
|
@@ -32,6 +32,9 @@ Requires-Dist: pyyaml
|
|
|
32
32
|
|
|
33
33
|
Please check out the information at [**documentation**](https://auto3d.readthedocs.io/en/latest/index.html), including [installation](https://auto3d.readthedocs.io/en/latest/installation.html), [usage](https://auto3d.readthedocs.io/en/latest/usage.html), [API](https://auto3d.readthedocs.io/en/latest/api.html) and [citation](https://auto3d.readthedocs.io/en/latest/citation.html).
|
|
34
34
|
|
|
35
|
+
- **Jupyter notebook examples** can be found [here](https://github.com/isayevlab/Auto3D_pkg/tree/main/example)
|
|
36
|
+
- To-do list for **improvement and new features** can be found [here](https://github.com/isayevlab/Auto3D_pkg/discussions). You are welcomed to share your thoughts.
|
|
37
|
+
- Bugs go to the [issues](https://github.com/isayevlab/Auto3D_pkg/issues)
|
|
35
38
|
|
|
36
39
|
## Minimum Dependencies Installatioin
|
|
37
40
|
1. Python >= 3.7
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|