rdworks 0.35.1__py3-none-any.whl → 0.36.2__py3-none-any.whl
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/__init__.py +1 -1
- rdworks/conf.py +12 -2
- rdworks/mol.py +13 -7
- {rdworks-0.35.1.dist-info → rdworks-0.36.2.dist-info}/METADATA +1 -1
- {rdworks-0.35.1.dist-info → rdworks-0.36.2.dist-info}/RECORD +8 -8
- {rdworks-0.35.1.dist-info → rdworks-0.36.2.dist-info}/WHEEL +1 -1
- {rdworks-0.35.1.dist-info → rdworks-0.36.2.dist-info}/licenses/LICENSE +0 -0
- {rdworks-0.35.1.dist-info → rdworks-0.36.2.dist-info}/top_level.txt +0 -0
rdworks/__init__.py
CHANGED
rdworks/conf.py
CHANGED
@@ -11,7 +11,7 @@ from mendeleev import element
|
|
11
11
|
from ase.optimize import FIRE
|
12
12
|
|
13
13
|
from rdkit import Chem
|
14
|
-
from rdkit.Chem import rdMolTransforms, AllChem, rdMolAlign
|
14
|
+
from rdkit.Chem import rdMolTransforms, AllChem, rdMolAlign, rdmolops
|
15
15
|
from rdkit.Chem.Draw import rdMolDraw2D
|
16
16
|
from PIL import Image
|
17
17
|
|
@@ -39,6 +39,8 @@ class Conf:
|
|
39
39
|
self.rdmol = None # must contain one and only one rdkit conformer
|
40
40
|
self.name = name
|
41
41
|
self.natoms = 0
|
42
|
+
self.charge = 0 # molecular charge
|
43
|
+
self.spin = 1 # molecular spin multiplicity for ASE
|
42
44
|
self.props = {}
|
43
45
|
|
44
46
|
if molecule is None:
|
@@ -60,6 +62,7 @@ class Conf:
|
|
60
62
|
tot_atoms = self.rdmol.GetNumAtoms(onlyExplicit=False)
|
61
63
|
assert num_atoms == tot_atoms, "Conf() Error: missing hydrogens"
|
62
64
|
self.natoms = num_atoms
|
65
|
+
self.charge = rdmolops.GetFormalCharge(self.rdmol)
|
63
66
|
self.props.update({'atoms': num_atoms})
|
64
67
|
|
65
68
|
assert self.rdmol.GetConformer().Is3D(), "Conf() Error: not 3D"
|
@@ -214,6 +217,8 @@ class Conf:
|
|
214
217
|
# assuming ASE calculator
|
215
218
|
with io.StringIO() as logfile:
|
216
219
|
ase_atoms = ase.Atoms(symbols=self.symbols(), positions=self.positions())
|
220
|
+
ase_atoms.info['charge'] = self.charge
|
221
|
+
ase_atoms.info['spin'] = self.spin
|
217
222
|
ase_atoms.calc = calculator
|
218
223
|
FIRE(ase_atoms, logfile=logfile).run(fmax=fmax)
|
219
224
|
lines = [l.strip().split()[1:] for l in logfile.getvalue().split('\n') if l.startswith('FIRE')]
|
@@ -366,9 +371,14 @@ class Conf:
|
|
366
371
|
else:
|
367
372
|
try:
|
368
373
|
ase_atoms = ase.Atoms(symbols=self.symbols(), positions=self.positions())
|
374
|
+
ase_atoms.info['charge'] = self.charge
|
375
|
+
ase_atoms.info['spin'] = self.spin
|
369
376
|
ase_atoms.calc = calculator
|
370
377
|
PE = ase_atoms.get_potential_energy() # np.array
|
371
|
-
|
378
|
+
if isinstance(PE, float):
|
379
|
+
PE = ev2kcalpermol * PE
|
380
|
+
elif isinstance(PE, np.ndarray | list):
|
381
|
+
PE = ev2kcalpermol * float(PE[0]) # np.float64 to float
|
372
382
|
self.props.update({'E_tot(kcal/mol)': PE})
|
373
383
|
|
374
384
|
return PE
|
rdworks/mol.py
CHANGED
@@ -3,6 +3,7 @@ import itertools
|
|
3
3
|
import json
|
4
4
|
import logging
|
5
5
|
import tempfile
|
6
|
+
import os
|
6
7
|
|
7
8
|
from io import StringIO, BytesIO
|
8
9
|
from pathlib import Path
|
@@ -367,7 +368,7 @@ class Mol:
|
|
367
368
|
self.confs.append(conf)
|
368
369
|
|
369
370
|
elif method.upper() == 'CONFORGE':
|
370
|
-
with tempfile.NamedTemporaryFile() as tmpfile:
|
371
|
+
with tempfile.NamedTemporaryFile(suffix='.sdf', delete=False) as tmpfile:
|
371
372
|
mol = CDPL.Chem.parseSMILES(self.smiles)
|
372
373
|
# create and initialize an instance of the class ConfGen.ConformerGenerator which
|
373
374
|
# will perform the actual conformer ensemble generation work
|
@@ -390,7 +391,7 @@ class Mol:
|
|
390
391
|
CDPL.ConfGen.ReturnCode.TORSION_DRIVING_FAILED : 'torsion driving failed',
|
391
392
|
CDPL.ConfGen.ReturnCode.CONF_GEN_FAILED : 'conformer generation failed',
|
392
393
|
}
|
393
|
-
writer = CDPL.Chem.MolecularGraphWriter(
|
394
|
+
writer = CDPL.Chem.MolecularGraphWriter(tmpfile.name, "sdf" )
|
394
395
|
# SB - io.StringIO does not work with Chem.MolecularGraphWriter()
|
395
396
|
# We have to create a temporary file and re-read it for storing individual conformers.
|
396
397
|
try:
|
@@ -403,15 +404,20 @@ class Mol:
|
|
403
404
|
if status == CDPL.ConfGen.ReturnCode.SUCCESS or status == CDPL.ConfGen.ReturnCode.TOO_MUCH_SYMMETRY:
|
404
405
|
# TOO_MUCH_SYMMETRY: output ensemble may contain duplicates
|
405
406
|
conf_gen.setConformers(mol)
|
406
|
-
writer.write(mol)
|
407
|
-
with Chem.SDMolSupplier(f"{tmpfile.name}.sdf", sanitize=True, removeHs=False) as sdf:
|
408
|
-
self.confs = [ Conf(m) for m in sdf if m is not None ]
|
407
|
+
writer.write(mol)
|
409
408
|
else:
|
410
409
|
raise RuntimeError('Error: conformer generation failed: %s' % status_to_str[status])
|
411
410
|
except Exception as e:
|
412
411
|
raise RuntimeError('Error: conformer generation failed: %s' % str(e))
|
413
|
-
|
414
|
-
|
412
|
+
|
413
|
+
# tmpfile is automatically closed here
|
414
|
+
|
415
|
+
with Chem.SDMolSupplier(tmpfile.name, sanitize=True, removeHs=False) as sdf:
|
416
|
+
self.confs = [ Conf(m) for m in sdf if m is not None ]
|
417
|
+
|
418
|
+
# tmpfile is not deleted here because delete=False
|
419
|
+
# we should remove the file when it is no longer needed
|
420
|
+
os.remove(tmpfile.name)
|
415
421
|
|
416
422
|
# energy evaluations for ranking
|
417
423
|
for conf in self.confs:
|
@@ -1,10 +1,10 @@
|
|
1
|
-
rdworks/__init__.py,sha256=
|
2
|
-
rdworks/conf.py,sha256=
|
1
|
+
rdworks/__init__.py,sha256=IQYmK2AVX7BA--tFniboPkU1P1f3KlwhLFIUmnYtaUQ,1368
|
2
|
+
rdworks/conf.py,sha256=hi8qqcEhDMfiGAj10I7Pl65svVNeV-ihjM7lRKX7OaM,22284
|
3
3
|
rdworks/descriptor.py,sha256=34T_dQ6g8v3u-ym8TLKbQtxIIV5TEo-d3pdedq3o-cg,2106
|
4
4
|
rdworks/display.py,sha256=JR0gR26UpH-JCxVOaqXZCUj2MiGZSrx9Me87FncspVI,13469
|
5
5
|
rdworks/ionized.py,sha256=5oIjMRpkX792RIpEEE2Ir96icfFaN_h21mSihhfQPAw,6713
|
6
6
|
rdworks/matchedseries.py,sha256=A3ON4CUpQV159mu9VqgNiJ8uoQ9ePOry9d3ra4NCAgc,10377
|
7
|
-
rdworks/mol.py,sha256=
|
7
|
+
rdworks/mol.py,sha256=lF5b_AIueYCfHWgrrnxbcZOFtSPe6dO4oOcovJ3GWhA,71338
|
8
8
|
rdworks/mollibr.py,sha256=X4UBO6Ga-QmNS7RwUiaDYAx0Q5hnWs71yTkEpH02Qb4,37696
|
9
9
|
rdworks/pka.py,sha256=NVJVfpcNEMlX5QRyLBgUM7GIT7VMjO-llAR4LWc8J2c,1656
|
10
10
|
rdworks/readin.py,sha256=0bnVcZcAmSLqc6zu1mYcv0LdBv2agQfOpKGwpSRL9VE,11742
|
@@ -65,8 +65,8 @@ rdworks/predefined/misc/reactive-part-3.xml,sha256=LgWHSEbRTVmgBoIO45xbTo1xQJs0X
|
|
65
65
|
rdworks/predefined/misc/reactive.xml,sha256=syedoQ6VYUfRLnxy99ObuDniJ_a_WhrWAJbTKFfJ6VY,11248
|
66
66
|
rdworks/xtb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
67
67
|
rdworks/xtb/wrapper.py,sha256=I0nW89vlJZ5Za5pCjIpjsEOFbTm7HpeNGiPgssheWn8,11350
|
68
|
-
rdworks-0.
|
69
|
-
rdworks-0.
|
70
|
-
rdworks-0.
|
71
|
-
rdworks-0.
|
72
|
-
rdworks-0.
|
68
|
+
rdworks-0.36.2.dist-info/licenses/LICENSE,sha256=UOkJSBqYyQUvtCp7a-vdCANeEcLE2dnTie_eB1By5SY,1074
|
69
|
+
rdworks-0.36.2.dist-info/METADATA,sha256=GRcE_cV1nVX4j60RB1Cm_Y69Ad_y3HrZgOwnNau177Y,1183
|
70
|
+
rdworks-0.36.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
71
|
+
rdworks-0.36.2.dist-info/top_level.txt,sha256=05C98HbvBK2axUBogC_hAT_CdpOeQYGnQ6vRAgawr8s,8
|
72
|
+
rdworks-0.36.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|