Auto3D 2.2.10__tar.gz → 2.3.0__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.10/src/Auto3D.egg-info → auto3d-2.3.0}/PKG-INFO +2 -19
- {Auto3D-2.2.10 → auto3d-2.3.0}/README.md +1 -18
- {Auto3D-2.2.10 → auto3d-2.3.0}/setup.cfg +5 -1
- auto3d-2.3.0/src/Auto3D/ASE/__pycache__/geometry.cpython-39.pyc +0 -0
- auto3d-2.3.0/src/Auto3D/ASE/__pycache__/thermo.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/ASE/geometry.py +13 -8
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/ASE/thermo.py +27 -13
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/SPE.py +28 -9
- auto3d-2.3.0/src/Auto3D/__pycache__/SPE.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/auto3D.cpython-39.pyc +0 -0
- auto3d-2.3.0/src/Auto3D/__pycache__/auto3Dcli.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/isomer_engine.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/ranking.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/tautomer.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/utils.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/utils_file.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/auto3D.py +9 -2
- auto3d-2.3.0/src/Auto3D/auto3Dcli.py +170 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/__pycache__/batchopt.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/batchopt.py +42 -40
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/ranking.py +1 -17
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/tautomer.py +2 -4
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/utils.py +10 -5
- {Auto3D-2.2.10 → auto3d-2.3.0/src/Auto3D.egg-info}/PKG-INFO +2 -19
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D.egg-info/SOURCES.txt +3 -0
- auto3d-2.3.0/src/Auto3D.egg-info/entry_points.txt +2 -0
- auto3d-2.3.0/tests/test_SPE.py +190 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/tests/test_auto3D.py +160 -10
- {Auto3D-2.2.10 → auto3d-2.3.0}/tests/test_isomer_engine.py +0 -13
- {Auto3D-2.2.10 → auto3d-2.3.0}/tests/test_tauto.py +5 -5
- auto3d-2.3.0/tests/test_thermo.py +299 -0
- Auto3D-2.2.10/src/Auto3D/ASE/__pycache__/geometry.cpython-39.pyc +0 -0
- Auto3D-2.2.10/src/Auto3D/ASE/__pycache__/thermo.cpython-39.pyc +0 -0
- Auto3D-2.2.10/src/Auto3D/__pycache__/SPE.cpython-39.pyc +0 -0
- Auto3D-2.2.10/tests/test_SPE.py +0 -54
- Auto3D-2.2.10/tests/test_thermo.py +0 -77
- {Auto3D-2.2.10 → auto3d-2.3.0}/LICENSE +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/MANIFEST.in +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/pyproject.toml +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/.gitignore +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/ASE/__init__.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/ASE/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__init__.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/ANI2xt_no_rep.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/ANI2xt_rep.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/__init__.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/__pycache__/ANI2xt_no_rep.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/batch_opt/__pycache__/__init__.cpython-39.pyc +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/isomer_engine.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/models/__init__.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/models/aimnet2_wb97m-d3_0.jpt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/models/aimnet2_wb97m_ens_f.jpt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/models/ani2xt_no_repulsion.pt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D/utils_file.py +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D.egg-info/dependency_links.txt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D.egg-info/requires.txt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/src/Auto3D.egg-info/top_level.txt +0 -0
- {Auto3D-2.2.10 → auto3d-2.3.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: Auto3D
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
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'
|
|
@@ -35,21 +35,4 @@ Please check out the information at [**documentation**](https://auto3d.readthedo
|
|
|
35
35
|
- **Jupyter notebook examples** can be found [here](https://github.com/isayevlab/Auto3D_pkg/tree/main/example)
|
|
36
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
37
|
- Bugs go to the [issues](https://github.com/isayevlab/Auto3D_pkg/issues)
|
|
38
|
-
|
|
39
|
-
## Minimum Dependencies Installatioin
|
|
40
|
-
1. Python >= 3.7
|
|
41
|
-
2. [RDKit](https://www.rdkit.org/docs/Install.html) >= 2022.03.1(For the isomer engine)
|
|
42
|
-
3. [PyTorch](https://pytorch.org/get-started/locally/) >= 2.1.0 (For the optimization engine)
|
|
43
|
-
|
|
44
|
-
If you have an environment with the above dependencies, Auto3D can be installed by
|
|
45
|
-
```{bash}
|
|
46
|
-
pip install Auto3D
|
|
47
|
-
```
|
|
48
|
-
Otherwise, you can create an environment and install Auto3D. In a terminal, the following code will create a environment named `auto3D` with Auto3D and its minimum dependencies installed.
|
|
49
|
-
```{bash}
|
|
50
|
-
git clone https://github.com/isayevlab/Auto3D_pkg.git
|
|
51
|
-
cd Auto3D_pkg
|
|
52
|
-
conda env create --file installation.yml --name auto3D
|
|
53
|
-
conda activate auto3D
|
|
54
|
-
pip install Auto3D
|
|
55
|
-
```
|
|
38
|
+
- **AIMNet2**: The default model in Auto3D is AIMNet2 since 2.2.1. If you specify optimizing_engine="AIMNET", it actually uses AIMNet2. The old AIMNet model has been deprecated since Auto3D 2.2.1, and every call to “AIMNET” refers to the AIMNet2 model.
|
|
@@ -16,21 +16,4 @@ Please check out the information at [**documentation**](https://auto3d.readthedo
|
|
|
16
16
|
- **Jupyter notebook examples** can be found [here](https://github.com/isayevlab/Auto3D_pkg/tree/main/example)
|
|
17
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
18
|
- Bugs go to the [issues](https://github.com/isayevlab/Auto3D_pkg/issues)
|
|
19
|
-
|
|
20
|
-
## Minimum Dependencies Installatioin
|
|
21
|
-
1. Python >= 3.7
|
|
22
|
-
2. [RDKit](https://www.rdkit.org/docs/Install.html) >= 2022.03.1(For the isomer engine)
|
|
23
|
-
3. [PyTorch](https://pytorch.org/get-started/locally/) >= 2.1.0 (For the optimization engine)
|
|
24
|
-
|
|
25
|
-
If you have an environment with the above dependencies, Auto3D can be installed by
|
|
26
|
-
```{bash}
|
|
27
|
-
pip install Auto3D
|
|
28
|
-
```
|
|
29
|
-
Otherwise, you can create an environment and install Auto3D. In a terminal, the following code will create a environment named `auto3D` with Auto3D and its minimum dependencies installed.
|
|
30
|
-
```{bash}
|
|
31
|
-
git clone https://github.com/isayevlab/Auto3D_pkg.git
|
|
32
|
-
cd Auto3D_pkg
|
|
33
|
-
conda env create --file installation.yml --name auto3D
|
|
34
|
-
conda activate auto3D
|
|
35
|
-
pip install Auto3D
|
|
36
|
-
```
|
|
19
|
+
- **AIMNet2**: The default model in Auto3D is AIMNet2 since 2.2.1. If you specify optimizing_engine="AIMNET", it actually uses AIMNet2. The old AIMNet model has been deprecated since Auto3D 2.2.1, and every call to “AIMNET” refers to the AIMNet2 model.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = Auto3D
|
|
3
|
-
version = 2.
|
|
3
|
+
version = 2.3.0
|
|
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
|
|
@@ -29,6 +29,10 @@ install_requires =
|
|
|
29
29
|
[options.packages.find]
|
|
30
30
|
where = src
|
|
31
31
|
|
|
32
|
+
[options.entry_points]
|
|
33
|
+
console_scripts =
|
|
34
|
+
auto3d = Auto3D.auto3Dcli:cli
|
|
35
|
+
|
|
32
36
|
[egg_info]
|
|
33
37
|
tag_build =
|
|
34
38
|
tag_date = 0
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
"""
|
|
3
|
-
Geometry optimization with ANI2xt, AIMNET or ANI2x
|
|
3
|
+
Geometry optimization with ANI2xt, AIMNET, userNNP or ANI2x
|
|
4
4
|
"""
|
|
5
5
|
import sys
|
|
6
6
|
import os
|
|
@@ -22,7 +22,7 @@ def opt_geometry(path: str, model_name:str, gpu_idx=0, opt_tol=0.003, opt_steps=
|
|
|
22
22
|
|
|
23
23
|
:param path: Input sdf file
|
|
24
24
|
:type path: str
|
|
25
|
-
:param model_name: ANI2x, ANI2xt or
|
|
25
|
+
:param model_name: ANI2x, ANI2xt, AIMNET or a path to userNNP model
|
|
26
26
|
:type model_name: str
|
|
27
27
|
:param gpu_idx: GPU cuda index, defaults to 0
|
|
28
28
|
:type gpu_idx: int, optional
|
|
@@ -34,7 +34,10 @@ def opt_geometry(path: str, model_name:str, gpu_idx=0, opt_tol=0.003, opt_steps=
|
|
|
34
34
|
ev2hatree = 1/hartree2ev
|
|
35
35
|
#create output path that is in the same directory as the input file
|
|
36
36
|
dir = os.path.dirname(path)
|
|
37
|
-
|
|
37
|
+
if os.path.exists(path):
|
|
38
|
+
basename = os.path.basename(path).split(".")[0] + f"_userNNP_opt.sdf"
|
|
39
|
+
else:
|
|
40
|
+
basename = os.path.basename(path).split(".")[0] + f"_{model_name}_opt.sdf"
|
|
38
41
|
outpath = os.path.join(dir, basename)
|
|
39
42
|
|
|
40
43
|
if torch.cuda.is_available():
|
|
@@ -59,9 +62,11 @@ def opt_geometry(path: str, model_name:str, gpu_idx=0, opt_tol=0.003, opt_steps=
|
|
|
59
62
|
|
|
60
63
|
if __name__ == '__main__':
|
|
61
64
|
path = '/home/jack/Auto3D_pkg/tests/files/DA.sdf'
|
|
62
|
-
out = opt_geometry(path, 'ANI2x', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
63
|
-
print(out)
|
|
64
|
-
out = opt_geometry(path, 'AIMNET', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
65
|
-
print(out)
|
|
66
|
-
out = opt_geometry(path, 'ANI2xt', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
65
|
+
# out = opt_geometry(path, 'ANI2x', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
66
|
+
# print(out)
|
|
67
|
+
# out = opt_geometry(path, 'AIMNET', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
68
|
+
# print(out)
|
|
69
|
+
# out = opt_geometry(path, 'ANI2xt', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
70
|
+
# print(out)
|
|
71
|
+
out = opt_geometry(path, '/home/jack/Auto3D_pkg/example/myNNP.pt', gpu_idx=0, opt_tol=0.003, opt_steps=5000)
|
|
67
72
|
print(out)
|
|
@@ -14,7 +14,6 @@ from ase import Atoms
|
|
|
14
14
|
from ase.optimize import BFGS
|
|
15
15
|
from rdkit import Chem
|
|
16
16
|
from rdkit.Chem import rdmolops
|
|
17
|
-
# from ase.vibrations import Vibrations
|
|
18
17
|
from ase.vibrations import VibrationsData, Vibrations
|
|
19
18
|
from ase.thermochemistry import IdealGasThermo
|
|
20
19
|
import ase.calculators.calculator
|
|
@@ -25,10 +24,12 @@ from Auto3D.batch_opt.batchopt import EnForce_ANI
|
|
|
25
24
|
from Auto3D.batch_opt.ANI2xt_no_rep import ANI2xt
|
|
26
25
|
from Auto3D.utils import hartree2ev
|
|
27
26
|
|
|
27
|
+
|
|
28
28
|
torch.backends.cuda.matmul.allow_tf32 = False
|
|
29
29
|
torch.backends.cudnn.allow_tf32 = False
|
|
30
30
|
ev2hatree = 1/hartree2ev
|
|
31
31
|
|
|
32
|
+
|
|
32
33
|
class Calculator(ase.calculators.calculator.Calculator):
|
|
33
34
|
"""ASE calculator interface for AIMNET and ANI2xt"""
|
|
34
35
|
implemented_properties = ['energy', 'forces']
|
|
@@ -102,9 +103,14 @@ def model_name2model_calculator(model_name: str, device=torch.device('cpu'), cha
|
|
|
102
103
|
elif model_name == "ANI2x":
|
|
103
104
|
ani2x = torchani.models.ANI2x(periodic_table_index=True).to(device).double()
|
|
104
105
|
model = EnForce_ANI(ani2x, model_name)
|
|
105
|
-
calculator = ani2x.ase()
|
|
106
|
+
# calculator = ani2x.ase()
|
|
107
|
+
calculator = Calculator(model, charge)
|
|
108
|
+
elif os.path.exists(model_name):
|
|
109
|
+
user_nnp = torch.jit.load(model_name, map_location=device).double()
|
|
110
|
+
model = EnForce_ANI(user_nnp, model_name)
|
|
111
|
+
calculator = Calculator(model, charge)
|
|
106
112
|
else:
|
|
107
|
-
raise ValueError("model has to be 'ANI2x', 'ANI2xt'
|
|
113
|
+
raise ValueError("model has to be 'ANI2x', 'ANI2xt', 'AIMNET' or a path to a userNNP model.")
|
|
108
114
|
return model, calculator
|
|
109
115
|
|
|
110
116
|
def mol2atoms(mol: Chem.Mol):
|
|
@@ -117,7 +123,7 @@ def mol2atoms(mol: Chem.Mol):
|
|
|
117
123
|
def vib_hessian(mol: Chem.Mol, ase_calculator, model,
|
|
118
124
|
device=torch.device('cpu'), model_name='AIMNET'):
|
|
119
125
|
'''return a VibrationsData object
|
|
120
|
-
model: ANI2xt or AIMNet2 or ANI2x that can be used to calculate Hessian'''
|
|
126
|
+
model: ANI2xt or AIMNet2 or ANI2x or userNNP that can be used to calculate Hessian'''
|
|
121
127
|
# get the ASE atoms object
|
|
122
128
|
coord = mol.GetConformer().GetPositions()
|
|
123
129
|
species = [a.GetSymbol() for a in mol.GetAtoms()]
|
|
@@ -163,7 +169,7 @@ def do_mol_thermo(mol: Chem.Mol,
|
|
|
163
169
|
device=torch.device('cpu'),
|
|
164
170
|
T=298.0, model_name='AIMNET'):
|
|
165
171
|
"""For a RDKit mol object, calculate its thermochemistry properties.
|
|
166
|
-
model: ANI2xt or AIMNet2 or ANI2x that can be used to calculate Hessian"""
|
|
172
|
+
model: ANI2xt or AIMNet2 or ANI2x or userNNP that can be used to calculate Hessian"""
|
|
167
173
|
vib = vib_hessian(mol, atoms.get_calculator(), model, device, model_name=model_name)
|
|
168
174
|
vib_e = vib.get_energies()
|
|
169
175
|
e = atoms.get_potential_energy()
|
|
@@ -208,6 +214,9 @@ def aimnet_hessian_helper(coord:torch.tensor,
|
|
|
208
214
|
elif model_name == 'ANI2x':
|
|
209
215
|
e = model((numbers, coord)).energies * hartree2ev
|
|
210
216
|
return e # energy unit: eV
|
|
217
|
+
elif os.path.exists(model_name):
|
|
218
|
+
e = model.forward(numbers, coord, charge)
|
|
219
|
+
return e # energy unit: eV
|
|
211
220
|
|
|
212
221
|
def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_tol=0.0002, opt_steps=5000):
|
|
213
222
|
"""
|
|
@@ -215,7 +224,7 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
215
224
|
|
|
216
225
|
:param path: Input sdf file
|
|
217
226
|
:type path: str
|
|
218
|
-
:param model_name: ANI2x, ANI2xt or
|
|
227
|
+
:param model_name: ANI2x, ANI2xt, AIMNET or a path to a userNNP model
|
|
219
228
|
:type model_name: str
|
|
220
229
|
:param get_mol_idx_t: A function that returns (idx, T) from a pybel mol object, by default using the 298 K temperature, defaults to None
|
|
221
230
|
:type get_mol_idx_t: function, optional
|
|
@@ -229,7 +238,10 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
229
238
|
#Prepare output name
|
|
230
239
|
out_mols, mols_failed = [], []
|
|
231
240
|
dir = os.path.dirname(path)
|
|
232
|
-
|
|
241
|
+
if os.path.exists(path):
|
|
242
|
+
basename = os.path.basename(path).split(".")[0] + "_userNNP_G.sdf"
|
|
243
|
+
else:
|
|
244
|
+
basename = os.path.basename(path).split(".")[0] + f"_{model_name}_G.sdf"
|
|
233
245
|
outpath = os.path.join(dir, basename)
|
|
234
246
|
|
|
235
247
|
if torch.cuda.is_available():
|
|
@@ -244,6 +256,8 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
244
256
|
hessian_model = ANI2xt(device).double()
|
|
245
257
|
elif model_name == 'ANI2x':
|
|
246
258
|
hessian_model = torchani.models.ANI2x(periodic_table_index=True).to(device).double()
|
|
259
|
+
elif os.path.exists(model_name):
|
|
260
|
+
hessian_model = torch.jit.load(model_name, map_location=device).double()
|
|
247
261
|
model, calculator = model_name2model_calculator(model_name, device)
|
|
248
262
|
|
|
249
263
|
mols = list(Chem.SDMolSupplier(path, removeHs=False))
|
|
@@ -253,8 +267,7 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
253
267
|
charge = rdmolops.GetFormalCharge(mol)
|
|
254
268
|
atoms = Atoms(species, coord)
|
|
255
269
|
|
|
256
|
-
|
|
257
|
-
calculator.set_charge(charge)
|
|
270
|
+
calculator.set_charge(charge)
|
|
258
271
|
atoms.set_calculator(calculator)
|
|
259
272
|
|
|
260
273
|
if get_mol_idx_t is None:
|
|
@@ -262,7 +275,6 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
262
275
|
T = 298
|
|
263
276
|
else:
|
|
264
277
|
idx, T = get_mol_idx_t(mol)
|
|
265
|
-
print(idx)
|
|
266
278
|
|
|
267
279
|
try:
|
|
268
280
|
try:
|
|
@@ -300,8 +312,10 @@ def calc_thermo(path: str, model_name: str, get_mol_idx_t=None, gpu_idx=0, opt_t
|
|
|
300
312
|
return outpath
|
|
301
313
|
|
|
302
314
|
if __name__ == "__main__":
|
|
303
|
-
|
|
315
|
+
|
|
316
|
+
|
|
304
317
|
path = '/home/jack/Auto3D_pkg/tests/files/cyclooctane.sdf'
|
|
318
|
+
model_path = '/home/jack/Auto3D_pkg/example/myNNP.pt'
|
|
319
|
+
# model = torch.load(model_path)
|
|
305
320
|
# out = calc_thermo(path, 'AIMNET', gpu_idx=1)
|
|
306
|
-
out = calc_thermo(path,
|
|
307
|
-
# out = calc_thermo(path, 'ANI2x', gpu_idx=1)
|
|
321
|
+
out = calc_thermo(path, model_path, gpu_idx=0)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
"""Calculating single point energy using ANI2xt, ANI2x or AIMNET"""
|
|
2
|
+
"""Calculating single point energy using ANI2xt, ANI2x, 'userNNP' or AIMNET"""
|
|
3
3
|
import sys
|
|
4
4
|
import os
|
|
5
5
|
root = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -33,14 +33,17 @@ def calc_spe(path: str, model_name: str, gpu_idx=0):
|
|
|
33
33
|
|
|
34
34
|
:param path: Input sdf file
|
|
35
35
|
:type path: str
|
|
36
|
-
:param model_name: AIMNET, ANI2x or ANI2xt
|
|
36
|
+
:param model_name: AIMNET, ANI2x, userNNP, or ANI2xt
|
|
37
37
|
:type model_name: str
|
|
38
38
|
:param gpu_idx: GPU cuda index, defaults to 0
|
|
39
39
|
:type gpu_idx: int, optional
|
|
40
40
|
"""
|
|
41
41
|
#Create a output path that is the in the same directory as the input
|
|
42
42
|
dir = os.path.dirname(path)
|
|
43
|
-
|
|
43
|
+
if os.path.exists(model_name):
|
|
44
|
+
basename = os.path.basename(path).split(".")[0] + f"_userNNP_E.sdf"
|
|
45
|
+
else:
|
|
46
|
+
basename = os.path.basename(path).split(".")[0] + f"_{model_name}_E.sdf"
|
|
44
47
|
outpath = os.path.join(dir, basename)
|
|
45
48
|
|
|
46
49
|
if torch.cuda.is_available():
|
|
@@ -51,24 +54,32 @@ def calc_spe(path: str, model_name: str, gpu_idx=0):
|
|
|
51
54
|
if model_name == "ANI2xt":
|
|
52
55
|
model = EnForce_ANI(ANI2xt(device), model_name)
|
|
53
56
|
elif model_name == "AIMNET":
|
|
54
|
-
# dict_path = os.path.join(root, "models/aimnet2nqed_pc14iall_b97m_sae.jpt")
|
|
55
|
-
# aimnet = torch.jit.load(dict_path, map_location=device)
|
|
56
57
|
aimnet = torch.jit.load(os.path.join(root, "models/aimnet2_wb97m_ens_f.jpt"), map_location=device)
|
|
57
58
|
model = EnForce_ANI(aimnet, model_name)
|
|
58
59
|
elif model_name == "ANI2x":
|
|
59
60
|
calculator = torchani.models.ANI2x(periodic_table_index=True).to(device)
|
|
60
61
|
model = EnForce_ANI(calculator, model_name)
|
|
62
|
+
# elif model_name == "userNNP":
|
|
63
|
+
# from userNNP import userNNP
|
|
64
|
+
elif os.path.exists(model_name):
|
|
65
|
+
calculator = torch.jit.load(model_name, map_location=device)
|
|
66
|
+
model = EnForce_ANI(calculator, model_name)
|
|
61
67
|
else:
|
|
62
|
-
raise ValueError("model has to be 'ANI2x', 'ANI2xt'
|
|
68
|
+
raise ValueError("model has to be 'ANI2x', 'ANI2xt', 'AIMNET' or a path to a userNNP model.")
|
|
63
69
|
|
|
64
70
|
mols = list(Chem.SDMolSupplier(path, removeHs=False))
|
|
65
71
|
coord, numbers, charges = mols2lists(mols, model_name)
|
|
66
72
|
if model_name == "AIMNET":
|
|
67
73
|
coord_padded = padding_coords(coord, 0)
|
|
68
74
|
numbers_padded = padding_species(numbers, 0)
|
|
69
|
-
|
|
75
|
+
elif model_name in {'ANI2xt', 'ANI2x'}:
|
|
70
76
|
coord_padded = padding_coords(coord, 0)
|
|
71
77
|
numbers_padded = padding_species(numbers, -1)
|
|
78
|
+
elif os.path.exists(model_name):
|
|
79
|
+
coord_padded = padding_coords(coord, model.ani.coord_pad)
|
|
80
|
+
numbers_padded = padding_species(numbers, model.ani.species_pad)
|
|
81
|
+
else:
|
|
82
|
+
raise ValueError("model has to be 'ANI2x', 'ANI2xt', 'AIMNET' or a path to a userNNP model.")
|
|
72
83
|
|
|
73
84
|
# if model_name != "ANI2x":
|
|
74
85
|
coord_padded = torch.tensor(coord_padded, device=device, requires_grad=True)
|
|
@@ -84,10 +95,18 @@ def calc_spe(path: str, model_name: str, gpu_idx=0):
|
|
|
84
95
|
return outpath
|
|
85
96
|
|
|
86
97
|
if __name__ == '__main__':
|
|
98
|
+
# path = '/home/jack/Auto3D_pkg/tests/files/cyclooctane.sdf'
|
|
99
|
+
# e_ref = -314.689736079491
|
|
100
|
+
# out = calc_spe(path, 'AIMNET')
|
|
101
|
+
# mol = next(Chem.SDMolSupplier(out, removeHs=False))
|
|
102
|
+
# e_out = float(mol.GetProp('E_hartree'))
|
|
103
|
+
# print(e_out)
|
|
104
|
+
# assert(abs(e_out - e_ref) <= 0.01)
|
|
105
|
+
|
|
87
106
|
path = '/home/jack/Auto3D_pkg/tests/files/cyclooctane.sdf'
|
|
88
107
|
e_ref = -314.689736079491
|
|
89
|
-
out = calc_spe(path, '
|
|
108
|
+
out = calc_spe(path, '/home/jack/Auto3D_pkg/example/myNNP.pt')
|
|
90
109
|
mol = next(Chem.SDMolSupplier(out, removeHs=False))
|
|
91
110
|
e_out = float(mol.GetProp('E_hartree'))
|
|
92
111
|
print(e_out)
|
|
93
|
-
assert(abs(e_out - e_ref) <= 0.01)
|
|
112
|
+
# assert(abs(e_out - e_ref) <= 0.01)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -10,6 +10,7 @@ import sys
|
|
|
10
10
|
import time
|
|
11
11
|
from datetime import datetime
|
|
12
12
|
import torch
|
|
13
|
+
import torch.nn as nn
|
|
13
14
|
import math
|
|
14
15
|
import psutil, tarfile
|
|
15
16
|
import glob
|
|
@@ -78,7 +79,7 @@ def isomer_wraper(chunk_info, args, queue, logging_queue):
|
|
|
78
79
|
smiles_hashed = meta["smiles_hashed"]
|
|
79
80
|
enumerated_sdf = meta["enumerated_sdf"]
|
|
80
81
|
max_confs = args.max_confs
|
|
81
|
-
duplicate_threshold =
|
|
82
|
+
duplicate_threshold = args.threshold
|
|
82
83
|
mpi_np = args.mpi_np
|
|
83
84
|
enumerate_isomer = args.enumerate_isomer
|
|
84
85
|
isomer_program = args.isomer_engine
|
|
@@ -206,7 +207,7 @@ def options(path: Optional[str]=None, k=False, window=False, verbose=False, job_
|
|
|
206
207
|
:type gpu_idx: int or list of int, optional
|
|
207
208
|
:param capacity: Number of SMILES that the model will handle for 1 G memory, defaults to 42
|
|
208
209
|
:type capacity: int, optional
|
|
209
|
-
:param optimizing_engine: Choose either 'ANI2x', 'ANI2xt',
|
|
210
|
+
:param optimizing_engine: Choose either 'ANI2x', 'ANI2xt', 'AIMNET' or a path to a custom NNP for energy calculation and geometry optimization, defaults to "AIMNET"
|
|
210
211
|
:type optimizing_engine: str, optional
|
|
211
212
|
:param patience: If the force does not decrease for a continuous patience steps, the conformer will drop out of the optimization loop, defaults to 1000
|
|
212
213
|
:type patience: int, optional
|
|
@@ -263,6 +264,12 @@ def logger_process(queue, logging_path):
|
|
|
263
264
|
|
|
264
265
|
def main(args:dict):
|
|
265
266
|
"""Take the arguments from the ``options`` function and run Auto3D."""
|
|
267
|
+
# Ensure spawn method is used
|
|
268
|
+
try:
|
|
269
|
+
mp.set_start_method('fork')
|
|
270
|
+
except RuntimeError:
|
|
271
|
+
pass
|
|
272
|
+
|
|
266
273
|
chunk_line = mp.Manager().Queue() #A queue managing two wrappers
|
|
267
274
|
start = time.time()
|
|
268
275
|
# job_name = datetime.now().strftime("%Y%m%d-%H%M%S-%f") #adds microsecond in the end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import yaml
|
|
4
|
+
import logging
|
|
5
|
+
import Auto3D
|
|
6
|
+
from Auto3D.auto3D import options, main
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def int_or_intlist(string):
|
|
10
|
+
try:
|
|
11
|
+
# Try to convert the entire string to an integer
|
|
12
|
+
return int(string)
|
|
13
|
+
except ValueError:
|
|
14
|
+
# If it fails, assume it's a comma-separated list of integers
|
|
15
|
+
return [int(item) for item in string.split(',')]
|
|
16
|
+
|
|
17
|
+
def cli():
|
|
18
|
+
if len(sys.argv) == 2:
|
|
19
|
+
# using yaml input
|
|
20
|
+
parameters_yaml = sys.argv[1]
|
|
21
|
+
parameters = yaml.load(open(parameters_yaml, "r"), Loader=yaml.FullLoader)
|
|
22
|
+
# change 'None' to None
|
|
23
|
+
for key, val in parameters.items():
|
|
24
|
+
if val == "None":
|
|
25
|
+
parameters[key] = None
|
|
26
|
+
|
|
27
|
+
path = parameters["path"]
|
|
28
|
+
k = parameters["k"]
|
|
29
|
+
window = parameters["window"]
|
|
30
|
+
memory = parameters["memory"]
|
|
31
|
+
capacity = parameters["capacity"]
|
|
32
|
+
enumerate_tautomer = parameters["enumerate_tautomer"]
|
|
33
|
+
tauto_engine = parameters["tauto_engine"]
|
|
34
|
+
pKaNorm = parameters["pKaNorm"]
|
|
35
|
+
isomer_engine = parameters["isomer_engine"]
|
|
36
|
+
max_confs = parameters["max_confs"]
|
|
37
|
+
enumerate_isomer = parameters["enumerate_isomer"]
|
|
38
|
+
mode_oe = parameters["mode_oe"]
|
|
39
|
+
mpi_np = parameters["mpi_np"]
|
|
40
|
+
optimizing_engine = parameters["optimizing_engine"]
|
|
41
|
+
use_gpu = parameters["use_gpu"]
|
|
42
|
+
gpu_idx = parameters["gpu_idx"] #YAML supports integer and lists natively
|
|
43
|
+
opt_steps = parameters["opt_steps"]
|
|
44
|
+
convergence_threshold = parameters["convergence_threshold"]
|
|
45
|
+
patience = parameters["patience"]
|
|
46
|
+
threshold = parameters["threshold"]
|
|
47
|
+
verbose = parameters["verbose"]
|
|
48
|
+
job_name = parameters["job_name"]
|
|
49
|
+
|
|
50
|
+
else:
|
|
51
|
+
# using argparse
|
|
52
|
+
parser = argparse.ArgumentParser(
|
|
53
|
+
prog="Auto3D",
|
|
54
|
+
description="Automatic generation of the low-energy 3D structures from ANI neural network potentials"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
parser.add_argument('path', type=str,
|
|
58
|
+
help='a path of smi/SDF file to store all SMILES and IDs')
|
|
59
|
+
parser.add_argument('--k', type=int, default=False,
|
|
60
|
+
help='Outputs the top-k structures for each SMILES.')
|
|
61
|
+
parser.add_argument('--window', type=float, default=False,
|
|
62
|
+
help=('Outputs the structures whose energies are within '
|
|
63
|
+
'window (kcal/mol) from the lowest energy'))
|
|
64
|
+
parser.add_argument('--memory', type=int, default=None,
|
|
65
|
+
help='The RAM size assigned to Auto3D (unit GB)')
|
|
66
|
+
parser.add_argument('--capacity', type=int, default=40,
|
|
67
|
+
help='This is the number of SMILES that each 1 GB of memory can handle')
|
|
68
|
+
parser.add_argument('--enumerate_tautomer', default=False, type=lambda x: (str(x).lower() == 'true'),
|
|
69
|
+
help="When True, enumerate tautomers for the input")
|
|
70
|
+
parser.add_argument('--tauto_engine', type=str, default='rdkit',
|
|
71
|
+
help="Programs to enumerate tautomers, either 'rdkit' or 'oechem'")
|
|
72
|
+
parser.add_argument('--pKaNorm', default=True, type=lambda x: (str(x).lower() == 'true'),
|
|
73
|
+
help="When True, the ionization state of each tautomer will be assigned to a predominant state at ~7.4 (Only works when tauto_engine='oechem')")
|
|
74
|
+
parser.add_argument('--isomer_engine', type=str, default='rdkit',
|
|
75
|
+
help=('The program for generating 3D isomers for each '
|
|
76
|
+
'SMILES. This parameter is either '
|
|
77
|
+
'rdkit or omega'))
|
|
78
|
+
parser.add_argument('--max_confs', type=int, default=None,
|
|
79
|
+
help=("Maximum number of isomers for each configuration of the SMILES.",
|
|
80
|
+
"Default is None, and Auto3D will uses a dynamic conformer number for each SMILES."))
|
|
81
|
+
parser.add_argument('--enumerate_isomer', default=True, type=lambda x: (str(x).lower() == 'true'),
|
|
82
|
+
help='When True, unspecified cis/trans and r/s isomers are enumerated.')
|
|
83
|
+
parser.add_argument('--mode_oe', type=str, default='classic',
|
|
84
|
+
help=("The mode that omega program will take. It can be either 'classic', 'macrocycle', 'dense', 'pose', 'rocs' or 'fast_rocs'. By default, the 'classic' mode is used."))
|
|
85
|
+
parser.add_argument('--mpi_np', type=int, default=4,
|
|
86
|
+
help="Number of CPU cores for the isomer generation step.")
|
|
87
|
+
parser.add_argument('--optimizing_engine', type=str, default='AIMNET',
|
|
88
|
+
help=("Choose either 'ANI2x', 'ANI2xt' or 'AIMNET' for energy "
|
|
89
|
+
"calculation and geometry optimization."))
|
|
90
|
+
parser.add_argument('--use_gpu', default=True, type=lambda x: (str(x).lower() == 'true'),
|
|
91
|
+
help="If True, the program will use GPU.")
|
|
92
|
+
parser.add_argument('--gpu_idx', default=0, type=int_or_intlist,
|
|
93
|
+
help="GPU index or indices as a single value or comma-separated list (e.g., 0,1,2)")
|
|
94
|
+
parser.add_argument('--opt_steps', type=int, default=5000,
|
|
95
|
+
help="Maximum optimization steps for each structure.")
|
|
96
|
+
parser.add_argument('--convergence_threshold', type=float, default=0.003,
|
|
97
|
+
help="Optimization is considered as converged if maximum force is below this threshold. Unit eV/Angstrom.")
|
|
98
|
+
parser.add_argument('--patience', type=int, default=1000,
|
|
99
|
+
help="If the force does not decrease for a continuous patience steps, the conformer will be dropped out of the optimization loop.")
|
|
100
|
+
parser.add_argument('--threshold', type=float, default=0.3,
|
|
101
|
+
help=("If the RMSD between two conformers are within threhold, "
|
|
102
|
+
"they are considered as duplicates. One of them will be removed."))
|
|
103
|
+
parser.add_argument('--verbose', default=False, type=lambda x: (str(x).lower() == 'true'),
|
|
104
|
+
help='When True, save all meta data while running.')
|
|
105
|
+
parser.add_argument('--job_name', default="", type=str,
|
|
106
|
+
help='A folder that stores all the results. By default, the name is the current date and time.')
|
|
107
|
+
|
|
108
|
+
args = parser.parse_args()
|
|
109
|
+
|
|
110
|
+
path = args.path
|
|
111
|
+
k = args.k
|
|
112
|
+
window = args.window
|
|
113
|
+
memory = args.memory
|
|
114
|
+
capacity = args.capacity
|
|
115
|
+
enumerate_tautomer = args.enumerate_tautomer
|
|
116
|
+
tauto_engine = args.tauto_engine
|
|
117
|
+
pKaNorm = args.pKaNorm
|
|
118
|
+
isomer_engine = args.isomer_engine
|
|
119
|
+
max_confs = args.max_confs
|
|
120
|
+
enumerate_isomer = args.enumerate_isomer
|
|
121
|
+
mode_oe = args.mode_oe
|
|
122
|
+
mpi_np = args.mpi_np
|
|
123
|
+
optimizing_engine = args.optimizing_engine
|
|
124
|
+
use_gpu = args.use_gpu
|
|
125
|
+
gpu_idx = args.gpu_idx
|
|
126
|
+
opt_steps = args.opt_steps
|
|
127
|
+
convergence_threshold = args.convergence_threshold
|
|
128
|
+
patience = args.patience
|
|
129
|
+
threshold = args.threshold
|
|
130
|
+
verbose = args.verbose
|
|
131
|
+
job_name = args.job_name
|
|
132
|
+
|
|
133
|
+
arguments = options(
|
|
134
|
+
path,
|
|
135
|
+
k=k,
|
|
136
|
+
window=window,
|
|
137
|
+
verbose=verbose,
|
|
138
|
+
job_name=job_name,
|
|
139
|
+
enumerate_tautomer=enumerate_tautomer,
|
|
140
|
+
tauto_engine=tauto_engine,
|
|
141
|
+
pKaNorm=pKaNorm,
|
|
142
|
+
isomer_engine=isomer_engine,
|
|
143
|
+
enumerate_isomer=enumerate_isomer,
|
|
144
|
+
mode_oe=mode_oe,
|
|
145
|
+
mpi_np=mpi_np,
|
|
146
|
+
max_confs=max_confs,
|
|
147
|
+
use_gpu=use_gpu,
|
|
148
|
+
gpu_idx=gpu_idx,
|
|
149
|
+
capacity=capacity,
|
|
150
|
+
optimizing_engine=optimizing_engine,
|
|
151
|
+
opt_steps=opt_steps,
|
|
152
|
+
convergence_threshold=convergence_threshold,
|
|
153
|
+
patience=patience,
|
|
154
|
+
threshold=threshold,
|
|
155
|
+
memory=memory
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
print(f"""
|
|
159
|
+
_ _ _____ ____
|
|
160
|
+
/ \ _ _ | |_ ___ |___ / | _ \
|
|
161
|
+
/ _ \ | | | | | __| / _ \ |_ \ | | | |
|
|
162
|
+
/ ___ \ | |_| | | |_ | (_) | ___) | | |_| |
|
|
163
|
+
/_/ \_\ \__,_| \__| \___/ |____/ |____/ {str(Auto3D.__version__)}
|
|
164
|
+
// Automatic generation of the low-energy 3D structures
|
|
165
|
+
""")
|
|
166
|
+
out = main(arguments)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
if __name__ == "__main__":
|
|
170
|
+
cli()
|