rdworks 0.49.1__tar.gz → 0.51.1__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.
- {rdworks-0.49.1 → rdworks-0.51.1}/PKG-INFO +1 -1
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/__init__.py +1 -1
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/conf.py +56 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/mol.py +42 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/xtb/wrapper.py +44 -7
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks.egg-info/PKG-INFO +1 -1
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks.egg-info/SOURCES.txt +1 -0
- rdworks-0.51.1/tests/test_qupkake.py +19 -0
- rdworks-0.51.1/tests/test_xtb.py +76 -0
- rdworks-0.49.1/tests/test_xtb.py +0 -160
- {rdworks-0.49.1 → rdworks-0.51.1}/LICENSE +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/README.md +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/pyproject.toml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/setup.cfg +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/__init__.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/autograph.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/centroid.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/dynamictreecut.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/nmrclust.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/autograph/rckmeans.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/bitqt/__init__.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/bitqt/bitqt.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/descriptor.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/display.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/ionized.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/matchedseries.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/mollibr.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/pka.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Asinex_fragment.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Astex_RO3.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010A.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010B.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/Baell2010C.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-less-than-015-hits.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-less-than-150-hits.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/PAINS-more-than-150-hits.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Baell2010_PAINS/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Brenk2008_Dundee/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/CNS.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/BMS.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/Dundee.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/Glaxo.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/Inpharmatica.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/LINT.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/MLSMR.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/PAINS.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/SureChEMBL.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ChEMBL_Walters/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999Acid.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999Base.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999ElPh.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/Hann1999NuPh.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Hann1999_Glaxo/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Kazius2005/Kazius2005.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/Kazius2005/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ZINC_druglike.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ZINC_fragment.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ZINC_leadlike.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/fragment.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ionized/simple_smarts_pattern.csv +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/ionized/smarts_pattern.csv +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/misc/makexml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/misc/reactive-part-2.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/misc/reactive-part-3.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/predefined/misc/reactive.xml +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/readin.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/rgroup.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/scaffold.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/std.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/stereoisomers.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/tautomers.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/testdata.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/torsion.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/units.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/utils.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/xml.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks/xtb/__init__.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks.egg-info/dependency_links.txt +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks.egg-info/requires.txt +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/src/rdworks.egg-info/top_level.txt +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/tests/test_basics.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/tests/test_ionized.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/tests/test_round.py +0 -0
- {rdworks-0.49.1 → rdworks-0.51.1}/tests/test_torsion.py +0 -0
@@ -270,6 +270,62 @@ class Conf:
|
|
270
270
|
return self.sync(ase_atoms.get_positions())
|
271
271
|
|
272
272
|
|
273
|
+
def protonate(self, atom_indices: list[int]) -> Self:
|
274
|
+
"""Protonate given non-hydrogen atoms.
|
275
|
+
|
276
|
+
Args:
|
277
|
+
atom_indices (list[int]): atom indices of non-hydrogen atoms to protonate.
|
278
|
+
|
279
|
+
Returns:
|
280
|
+
Self: self.
|
281
|
+
"""
|
282
|
+
for idx in atom_indices:
|
283
|
+
atom = self.rdmol.GetAtomWithIdx(idx)
|
284
|
+
h = atom.GetNumExplicitHs()
|
285
|
+
c = atom.GetFormalCharge()
|
286
|
+
atom.SetNumExplicitHs(h+1)
|
287
|
+
atom.SetFormalCharge(c+1)
|
288
|
+
Chem.SanitizeMol(self.rdmol)
|
289
|
+
self.rdmol = Chem.AddHs(self.rdmol, addCoords=True)
|
290
|
+
# The Chem.AddHs function in RDKit returns a new Mol object with hydrogens added to the molecule.
|
291
|
+
# It modifies the input molecule by adding hydrogens,
|
292
|
+
# but the original molecule remains unchanged.
|
293
|
+
|
294
|
+
return self
|
295
|
+
|
296
|
+
|
297
|
+
def deprotonate(self, atom_indices: list[int]) -> Self:
|
298
|
+
"""Deprotonate given non-hydrogen atoms.
|
299
|
+
|
300
|
+
Args:
|
301
|
+
atom_indices (list[int]): atom indices of non-hydrogen atoms to deprotonate.
|
302
|
+
|
303
|
+
Returns:
|
304
|
+
Self: self.
|
305
|
+
"""
|
306
|
+
for idx in atom_indices:
|
307
|
+
bonded_H_idx = None
|
308
|
+
atom = self.rdmol.GetAtomWithIdx(idx)
|
309
|
+
h = atom.GetNumExplicitHs()
|
310
|
+
if h-1 >= 0 :
|
311
|
+
atom.SetNumExplicitHs(h-1) # (h-1) must be unsigned int
|
312
|
+
c = atom.GetFormalCharge()
|
313
|
+
atom.SetFormalCharge(c-1)
|
314
|
+
neighbors = atom.GetNeighbors()
|
315
|
+
|
316
|
+
for neighbor in neighbors:
|
317
|
+
if neighbor.GetAtomicNum() == 1:
|
318
|
+
bonded_H_idx = neighbor.GetIdx()
|
319
|
+
break
|
320
|
+
|
321
|
+
if bonded_H_idx is not None:
|
322
|
+
edit_mol = Chem.EditableMol(self.rdmol)
|
323
|
+
edit_mol.RemoveAtom(bonded_H_idx)
|
324
|
+
self.rdmol = edit_mol.GetMol()
|
325
|
+
Chem.SanitizeMol(self.rdmol)
|
326
|
+
|
327
|
+
return self
|
328
|
+
|
273
329
|
|
274
330
|
##################################################
|
275
331
|
### Endpoint methods
|
@@ -1619,4 +1619,46 @@ class Mol:
|
|
1619
1619
|
self.props = data['props']
|
1620
1620
|
self.confs = [Conf().deserialize(_) for _ in data['confs']] # for 3D conformers (iterable)
|
1621
1621
|
|
1622
|
+
return self
|
1623
|
+
|
1624
|
+
def from_molblock(self, molblock: str) -> Self:
|
1625
|
+
"""Initialize a new Mol object from MolBlock.
|
1626
|
+
|
1627
|
+
Args:
|
1628
|
+
molblock (str): MolBlock string
|
1629
|
+
|
1630
|
+
Raises:
|
1631
|
+
ValueError: invalid MolBlock
|
1632
|
+
|
1633
|
+
Returns:
|
1634
|
+
Self: self.
|
1635
|
+
"""
|
1636
|
+
molecule = Chem.MolFromMolBlock(molblock)
|
1637
|
+
try:
|
1638
|
+
self.rdmol, _ = clean_2d(molecule, reset_isotope=True, remove_H=True)
|
1639
|
+
self.smiles = Chem.MolToSmiles(self.rdmol)
|
1640
|
+
self.confs = [Conf(x) for x in _]
|
1641
|
+
except:
|
1642
|
+
raise ValueError(f'Mol() Error: invalid MolBlock string')
|
1643
|
+
|
1644
|
+
assert self.smiles and self.rdmol, "Mol() Error: invalid molecule"
|
1645
|
+
|
1646
|
+
name = self.rdmol.GetProp('_Name')
|
1647
|
+
|
1648
|
+
rdDepictor.Compute2DCoords(self.rdmol)
|
1649
|
+
|
1650
|
+
try:
|
1651
|
+
self.name = str(name)
|
1652
|
+
except:
|
1653
|
+
self.name = 'untitled'
|
1654
|
+
|
1655
|
+
self.rdmol.SetProp('_Name', self.name) # _Name can't be None
|
1656
|
+
self.InChIKey = generate_inchi_key(self.rdmol)
|
1657
|
+
self.props.update({
|
1658
|
+
'aka' : [], # <-- to be set by MolLibr.unique()
|
1659
|
+
'atoms' : self.rdmol.GetNumAtoms(), # hydrogens not excluded?
|
1660
|
+
'charge': rdmolops.GetFormalCharge(self.rdmol),
|
1661
|
+
"nrb" : Descriptors.NumRotatableBonds(self.rdmol),
|
1662
|
+
})
|
1663
|
+
|
1622
1664
|
return self
|
@@ -59,6 +59,43 @@ class GFN2xTB:
|
|
59
59
|
return shutil.which('xtb') is not None
|
60
60
|
|
61
61
|
|
62
|
+
@staticmethod
|
63
|
+
def is_optimize_ready() -> bool:
|
64
|
+
try:
|
65
|
+
h2o = [
|
66
|
+
'$coord',
|
67
|
+
' 0.00000000000000 0.00000000000000 -0.73578586109551 o',
|
68
|
+
' 1.44183152868459 0.00000000000000 0.36789293054775 h',
|
69
|
+
'-1.44183152868459 0.00000000000000 0.36789293054775 h',
|
70
|
+
'$end',
|
71
|
+
]
|
72
|
+
|
73
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
74
|
+
test_geometry = os.path.join(temp_dir, 'coord')
|
75
|
+
with open(test_geometry, 'w') as f:
|
76
|
+
f.write('\n'.join(h2o))
|
77
|
+
proc = subprocess.run(['xtb', test_geometry, '--opt'],
|
78
|
+
capture_output=True,
|
79
|
+
text=True)
|
80
|
+
assert proc.returncode == 0
|
81
|
+
|
82
|
+
return True
|
83
|
+
|
84
|
+
except:
|
85
|
+
print("""
|
86
|
+
Conda installed xTB has the Fortran runtime error in geometry optimization.
|
87
|
+
Please install xtb using the compiled binary:
|
88
|
+
|
89
|
+
$ wget https://github.com/grimme-lab/xtb/releases/download/v6.7.1/xtb-6.7.1-linux-x86_64.tar.xz
|
90
|
+
$ tar -xf xtb-6.7.1-linux-x86_64.tar.xz
|
91
|
+
$ cp -r xtb-dist/bin/* /usr/local/bin/
|
92
|
+
$ cp -r xtb-dist/lib/* /usr/local/lib/
|
93
|
+
$ cp -r xtb-dist/include/* /usr/local/include/
|
94
|
+
$ cp -r xtb-dist/share /usr/local/ """)
|
95
|
+
|
96
|
+
return False
|
97
|
+
|
98
|
+
|
62
99
|
@staticmethod
|
63
100
|
def is_cpx_ready() -> bool:
|
64
101
|
"""Checks if the CPCM-X command-line tool, `cpx`, is accessible in the system.
|
@@ -70,7 +107,7 @@ class GFN2xTB:
|
|
70
107
|
|
71
108
|
|
72
109
|
@staticmethod
|
73
|
-
def
|
110
|
+
def is_cpcmx_ready() -> bool:
|
74
111
|
"""Checks if xtb works with the `--cpcmx` option.
|
75
112
|
|
76
113
|
xtb distributed by the conda does not include CPCM-X function (as of June 17, 2025).
|
@@ -101,7 +138,8 @@ class GFN2xTB:
|
|
101
138
|
"""
|
102
139
|
return all([GFN2xTB.is_xtb_ready(),
|
103
140
|
GFN2xTB.is_cpx_ready(),
|
104
|
-
GFN2xTB.
|
141
|
+
GFN2xTB.is_cpcmx_ready(),
|
142
|
+
GFN2xTB.is_optimize_ready()])
|
105
143
|
|
106
144
|
|
107
145
|
@staticmethod
|
@@ -115,10 +153,9 @@ class GFN2xTB:
|
|
115
153
|
cmd = ['xtb', '--version']
|
116
154
|
proc = subprocess.run(cmd, capture_output=True, text=True)
|
117
155
|
assert proc.returncode == 0, "GFN2xTB() Error: xtb not available"
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
return line
|
156
|
+
match = re.search('xtb\s+version\s+(?P<version>[\d.]+)', proc.stdout)
|
157
|
+
if match:
|
158
|
+
return match.group('version')
|
122
159
|
|
123
160
|
return None
|
124
161
|
|
@@ -362,7 +399,7 @@ class GFN2xTB:
|
|
362
399
|
elif water == 'alpb':
|
363
400
|
options += ['--alpb', 'water']
|
364
401
|
# it does not provide Gsolv contribution to the total energy
|
365
|
-
elif water == 'cpcmx' and self.
|
402
|
+
elif water == 'cpcmx' and self.is_cpcmx_ready():
|
366
403
|
options += ['--cpcmx', 'water']
|
367
404
|
|
368
405
|
if verbose:
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import rdworks
|
2
|
+
|
3
|
+
def test_readin_qupkake_output():
|
4
|
+
libr = rdworks.read_sdf('qupkake/output/qupkake_output.sdf', confs=True)
|
5
|
+
# libr contains one molecule because of confs=True
|
6
|
+
assert libr.count() == 1
|
7
|
+
for m in libr:
|
8
|
+
assert m.count() == 4
|
9
|
+
print(m.props)
|
10
|
+
print()
|
11
|
+
for c in m:
|
12
|
+
print(c.props)
|
13
|
+
print()
|
14
|
+
|
15
|
+
print(m.serialize(compressed=True))
|
16
|
+
|
17
|
+
|
18
|
+
if __name__ == '__main__':
|
19
|
+
test_readin_qupkake_output()
|
@@ -0,0 +1,76 @@
|
|
1
|
+
from rdworks import Mol
|
2
|
+
from rdworks.xtb.wrapper import GFN2xTB
|
3
|
+
from rdworks.testdata import drugs
|
4
|
+
|
5
|
+
from pathlib import Path
|
6
|
+
|
7
|
+
|
8
|
+
# In ASE, the default energy unit is eV (electron volt).
|
9
|
+
# It will be converted to kcal/mol
|
10
|
+
# CODATA 2018 energy conversion factor
|
11
|
+
hartree2ev = 27.211386245988
|
12
|
+
hartree2kcalpermol = 627.50947337481
|
13
|
+
ev2kcalpermol = 23.060547830619026
|
14
|
+
|
15
|
+
|
16
|
+
datadir = Path(__file__).parent.resolve() / "data"
|
17
|
+
workdir = Path(__file__).parent.resolve() / "outfiles"
|
18
|
+
|
19
|
+
workdir.mkdir(exist_ok=True)
|
20
|
+
|
21
|
+
name = 'Atorvastatin'
|
22
|
+
testmol = Mol(drugs[name], name).make_confs(n=50).optimize_confs()
|
23
|
+
testmol = testmol.drop_confs(similar=True, verbose=True).sort_confs()
|
24
|
+
|
25
|
+
|
26
|
+
def test_xtb_wrapper():
|
27
|
+
from rdworks.xtb.wrapper import GFN2xTB
|
28
|
+
assert GFN2xTB.is_xtb_ready() == True
|
29
|
+
assert GFN2xTB.is_cpx_ready() == True
|
30
|
+
assert GFN2xTB.is_cpcmx_ready() == True
|
31
|
+
assert GFN2xTB.is_ready() == True
|
32
|
+
assert GFN2xTB.version() is not None
|
33
|
+
|
34
|
+
|
35
|
+
def test_singlepoint():
|
36
|
+
mol = testmol.copy()
|
37
|
+
|
38
|
+
print("number of conformers=", mol.count())
|
39
|
+
print("number of atoms=", mol.confs[0].natoms)
|
40
|
+
|
41
|
+
gfn2xtb = GFN2xTB(mol.confs[0].rdmol)
|
42
|
+
|
43
|
+
print("GFN2xTB.singlepoint()")
|
44
|
+
outdict = gfn2xtb.singlepoint()
|
45
|
+
print(outdict)
|
46
|
+
print()
|
47
|
+
|
48
|
+
print("GFN2xTB.singlepoint(water='gbsa')")
|
49
|
+
outdict = gfn2xtb.singlepoint(water='gbsa')
|
50
|
+
print(outdict)
|
51
|
+
print()
|
52
|
+
|
53
|
+
print("GFN2xTB.singlepoint(water='alpb')")
|
54
|
+
outdict = gfn2xtb.singlepoint(water='alpb')
|
55
|
+
print(outdict)
|
56
|
+
print()
|
57
|
+
|
58
|
+
print("GFN2xTB.singlepoint(water='cpcmx')")
|
59
|
+
outdict = gfn2xtb.singlepoint(water='cpcmx')
|
60
|
+
print(outdict)
|
61
|
+
print()
|
62
|
+
|
63
|
+
|
64
|
+
def test_optimize():
|
65
|
+
mol = testmol.copy()
|
66
|
+
print("number of conformers=", mol.count())
|
67
|
+
print("GFN2xTB.optimize()")
|
68
|
+
outdict = GFN2xTB(mol.confs[0].rdmol).optimize(verbose=True)
|
69
|
+
print(outdict)
|
70
|
+
print()
|
71
|
+
|
72
|
+
|
73
|
+
if __name__ == '__main__':
|
74
|
+
test_xtb_wrapper()
|
75
|
+
test_singlepoint()
|
76
|
+
test_optimize()
|
rdworks-0.49.1/tests/test_xtb.py
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
from rdworks import Mol
|
2
|
-
from rdworks.xtb.wrapper import GFN2xTB
|
3
|
-
from rdworks.testdata import drugs
|
4
|
-
|
5
|
-
from pathlib import Path
|
6
|
-
|
7
|
-
|
8
|
-
# In ASE, the default energy unit is eV (electron volt).
|
9
|
-
# It will be converted to kcal/mol
|
10
|
-
# CODATA 2018 energy conversion factor
|
11
|
-
hartree2ev = 27.211386245988
|
12
|
-
hartree2kcalpermol = 627.50947337481
|
13
|
-
ev2kcalpermol = 23.060547830619026
|
14
|
-
|
15
|
-
|
16
|
-
datadir = Path(__file__).parent.resolve() / "data"
|
17
|
-
workdir = Path(__file__).parent.resolve() / "outfiles"
|
18
|
-
|
19
|
-
workdir.mkdir(exist_ok=True)
|
20
|
-
|
21
|
-
name = 'Atorvastatin'
|
22
|
-
testmol = Mol(drugs[name], name).make_confs(n=50).optimize_confs()
|
23
|
-
testmol = testmol.drop_confs(similar=True, verbose=True).sort_confs()
|
24
|
-
|
25
|
-
|
26
|
-
def test_xtb_wrapper():
|
27
|
-
from rdworks.xtb.wrapper import GFN2xTB
|
28
|
-
assert GFN2xTB.is_xtb_ready() == True
|
29
|
-
assert GFN2xTB.is_cpx_ready() == True
|
30
|
-
assert GFN2xTB.is_cpcmx_option_ready() == True
|
31
|
-
assert GFN2xTB.is_ready() == True
|
32
|
-
assert GFN2xTB.version() is not None
|
33
|
-
|
34
|
-
|
35
|
-
def test_singlepoint():
|
36
|
-
mol = testmol.copy()
|
37
|
-
|
38
|
-
print("number of conformers=", mol.count())
|
39
|
-
print("number of atoms=", mol.confs[0].natoms)
|
40
|
-
|
41
|
-
gfn2xtb = GFN2xTB(mol.confs[0].rdmol, ncores=8)
|
42
|
-
|
43
|
-
print("GFN2xTB.singlepoint()")
|
44
|
-
outdict = gfn2xtb.singlepoint()
|
45
|
-
print(outdict)
|
46
|
-
print()
|
47
|
-
|
48
|
-
print("GFN2xTB.singlepoint(water='gbsa')")
|
49
|
-
outdict = gfn2xtb.singlepoint(water='gbsa')
|
50
|
-
print(outdict)
|
51
|
-
print()
|
52
|
-
|
53
|
-
print("GFN2xTB.singlepoint(water='alpb')")
|
54
|
-
outdict = gfn2xtb.singlepoint(water='alpb')
|
55
|
-
print(outdict)
|
56
|
-
print()
|
57
|
-
|
58
|
-
print("GFN2xTB.singlepoint(water='cpcmx')")
|
59
|
-
outdict = gfn2xtb.singlepoint(water='cpcmx')
|
60
|
-
print(outdict)
|
61
|
-
print()
|
62
|
-
|
63
|
-
|
64
|
-
def test_optimize():
|
65
|
-
mol = testmol.copy()
|
66
|
-
print("number of conformers=", mol.count())
|
67
|
-
print("GFN2xTB.optimize()")
|
68
|
-
outdict = GFN2xTB(mol.confs[0].rdmol, ncores=8).optimize(verbose=True)
|
69
|
-
print(outdict)
|
70
|
-
print()
|
71
|
-
|
72
|
-
|
73
|
-
def test_state_generate():
|
74
|
-
import rdworks
|
75
|
-
import numpy as np
|
76
|
-
import os
|
77
|
-
|
78
|
-
task_queue = 'xtb'
|
79
|
-
|
80
|
-
kT = 0.001987 * 300.0 # (kcal/mol K)
|
81
|
-
|
82
|
-
smiles = 'CCCCNC(=O)[C@@H]1CCCN1[C@@H](CC)c1nnc(Cc2ccc(C)cc2)o1'
|
83
|
-
n = 50
|
84
|
-
method = 'ETKDG'
|
85
|
-
|
86
|
-
standardized = rdworks.Mol(smiles)
|
87
|
-
libr = rdworks.complete_tautomers(standardized)
|
88
|
-
|
89
|
-
PE = []
|
90
|
-
for mol in libr:
|
91
|
-
mol = mol.make_confs(n=n, method=method, verbose=True)
|
92
|
-
mol = mol.optimize_confs(calculator='MMFF94', verbose=True)
|
93
|
-
mol = mol.drop_confs(similar=True, similar_rmsd=0.3, verbose=True)
|
94
|
-
mol = mol.sort_confs(calculator='xTB', verbose=True)
|
95
|
-
mol = mol.drop_confs(k=10, window=10.0, verbose=True) # enforcing both conditions
|
96
|
-
_PE = []
|
97
|
-
for conf in mol.confs:
|
98
|
-
conf = conf.optimize(calculator='xTB', verbose=True)
|
99
|
-
# GFN2xTB requires 3D coordinates
|
100
|
-
xtb = GFN2xTB(conf.rdmol).singlepoint(water='cpcmx', verbose=True)
|
101
|
-
_PE.append(xtb.PE)
|
102
|
-
# SimpleNamespace(
|
103
|
-
# PE = datadict['total energy'] * hartree2kcalpermol,
|
104
|
-
# Gsolv = Gsolv,
|
105
|
-
# charges = datadict['partial charges'],
|
106
|
-
# wbo = Wiberg_bond_orders,
|
107
|
-
# )
|
108
|
-
PE.append(_PE)
|
109
|
-
print(_PE)
|
110
|
-
|
111
|
-
# calculate population
|
112
|
-
PE = np.array(PE)
|
113
|
-
PE = PE - np.min(PE)
|
114
|
-
Boltzmann_factors = np.exp(-PE/kT)
|
115
|
-
# partition function
|
116
|
-
Z = np.sum(Boltzmann_factors)
|
117
|
-
# population
|
118
|
-
p = np.sum(Boltzmann_factors/Z, axis=1)
|
119
|
-
|
120
|
-
sorted_indices = sorted(list(enumerate(p)), key=lambda x: x[1], reverse=True) # [(0,p0), (1,p1), ...]
|
121
|
-
|
122
|
-
molecular_states = []
|
123
|
-
for idx, population in sorted_indices:
|
124
|
-
if population < 0.05:
|
125
|
-
continue
|
126
|
-
|
127
|
-
# state.keys() = ['rdmol','smiles','charge','population','pKa', 'qikprop']
|
128
|
-
|
129
|
-
state_mol = libr[idx].rename(f'state.{idx+1}').qed(
|
130
|
-
properties=['QED', 'MolWt', 'LogP', 'TPSA', 'HBD', 'HBA'])
|
131
|
-
|
132
|
-
basic_properties = {
|
133
|
-
'QED' : round(state_mol.props['QED'], 2),
|
134
|
-
'MolWt' : round(state_mol.props['MolWt'], 2),
|
135
|
-
'LogP' : round(state_mol.props['LogP'], 2),
|
136
|
-
'TPSA' : round(state_mol.props['TPSA'], 2),
|
137
|
-
'HBD' : state_mol.props['HBD'],
|
138
|
-
'HBA' : state_mol.props['HBA'],
|
139
|
-
}
|
140
|
-
|
141
|
-
state_props = {
|
142
|
-
'method': task_queue,
|
143
|
-
'PE(kcal/mol)': state_mol.confs[0].props['E_tot(kcal/mol)'],
|
144
|
-
'population' : round(float(population), 3),
|
145
|
-
'basic_properties': basic_properties,
|
146
|
-
'rdkit_version': rdworks.__rdkit_version__,
|
147
|
-
'rdworks_version': rdworks.__version__,
|
148
|
-
}
|
149
|
-
|
150
|
-
molecular_states.append((state_mol.serialize(compressed=True), state_props))
|
151
|
-
|
152
|
-
print(molecular_states)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
if __name__ == '__main__':
|
157
|
-
# test_xtb_wrapper()
|
158
|
-
# test_singlepoint()
|
159
|
-
# test_optimize()
|
160
|
-
test_state_generate()
|
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
|
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
|