rdworks 0.36.1__py3-none-any.whl → 0.36.3__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '0.36.1'
1
+ __version__ = '0.36.3'
2
2
 
3
3
  from rdworks.conf import Conf
4
4
  from rdworks.mol import Mol
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,51 +368,62 @@ class Mol:
367
368
  self.confs.append(conf)
368
369
 
369
370
  elif method.upper() == 'CONFORGE':
370
- with tempfile.NamedTemporaryFile() as tmpfile:
371
- mol = CDPL.Chem.parseSMILES(self.smiles)
372
- # create and initialize an instance of the class ConfGen.ConformerGenerator which
373
- # will perform the actual conformer ensemble generation work
374
- conf_gen = CDPL.ConfGen.ConformerGenerator()
375
- conf_gen.settings.timeout = 60 * 1000 # 60 sec.
376
- conf_gen.settings.minRMSD = 0.5
377
- conf_gen.settings.energyWindow = 20.0 # kcal/mol(?)
378
- conf_gen.settings.maxNumOutputConformers = n
379
- # dictionary mapping status codes to human readable strings
380
- status_to_str = {
381
- CDPL.ConfGen.ReturnCode.UNINITIALIZED : 'uninitialized',
382
- CDPL.ConfGen.ReturnCode.TIMEOUT : 'max. processing time exceeded',
383
- CDPL.ConfGen.ReturnCode.ABORTED : 'aborted',
384
- CDPL.ConfGen.ReturnCode.FORCEFIELD_SETUP_FAILED : 'force field setup failed',
385
- CDPL.ConfGen.ReturnCode.FORCEFIELD_MINIMIZATION_FAILED : 'force field structure refinement failed',
386
- CDPL.ConfGen.ReturnCode.FRAGMENT_LIBRARY_NOT_SET : 'fragment library not available',
387
- CDPL.ConfGen.ReturnCode.FRAGMENT_CONF_GEN_FAILED : 'fragment conformer generation failed',
388
- CDPL.ConfGen.ReturnCode.FRAGMENT_CONF_GEN_TIMEOUT : 'fragment conformer generation timeout',
389
- CDPL.ConfGen.ReturnCode.FRAGMENT_ALREADY_PROCESSED : 'fragment already processed',
390
- CDPL.ConfGen.ReturnCode.TORSION_DRIVING_FAILED : 'torsion driving failed',
391
- CDPL.ConfGen.ReturnCode.CONF_GEN_FAILED : 'conformer generation failed',
392
- }
393
- writer = CDPL.Chem.MolecularGraphWriter( f"{tmpfile.name}.sdf", "sdf" )
394
- # SB - io.StringIO does not work with Chem.MolecularGraphWriter()
395
- # We have to create a temporary file and re-read it for storing individual conformers.
396
- try:
397
- # prepare the molecule for conformer generation
398
- CDPL.ConfGen.prepareForConformerGeneration(mol)
399
- # generate the conformer ensemble
400
- status = conf_gen.generate(mol)
401
- # if successful, store the generated conformer ensemble as
402
- # per atom 3D coordinates arrays (= the way conformers are represented in CDPKit)
403
- if status == CDPL.ConfGen.ReturnCode.SUCCESS or status == CDPL.ConfGen.ReturnCode.TOO_MUCH_SYMMETRY:
404
- # TOO_MUCH_SYMMETRY: output ensemble may contain duplicates
405
- 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 ]
409
- else:
410
- raise RuntimeError('Error: conformer generation failed: %s' % status_to_str[status])
411
- except Exception as e:
412
- raise RuntimeError('Error: conformer generation failed: %s' % str(e))
413
- # tmpfile is automatically closed and deleted here
414
-
371
+ mol = CDPL.Chem.parseSMILES(self.smiles)
372
+ # create and initialize an instance of the class ConfGen.ConformerGenerator which
373
+ # will perform the actual conformer ensemble generation work
374
+ conf_gen = CDPL.ConfGen.ConformerGenerator()
375
+ conf_gen.settings.timeout = 60 * 1000 # 60 sec.
376
+ conf_gen.settings.minRMSD = 0.5
377
+ conf_gen.settings.energyWindow = 20.0 # kcal/mol(?)
378
+ conf_gen.settings.maxNumOutputConformers = n
379
+ # dictionary mapping status codes to human readable strings
380
+ status_to_str = {
381
+ CDPL.ConfGen.ReturnCode.UNINITIALIZED : 'uninitialized',
382
+ CDPL.ConfGen.ReturnCode.TIMEOUT : 'max. processing time exceeded',
383
+ CDPL.ConfGen.ReturnCode.ABORTED : 'aborted',
384
+ CDPL.ConfGen.ReturnCode.FORCEFIELD_SETUP_FAILED : 'force field setup failed',
385
+ CDPL.ConfGen.ReturnCode.FORCEFIELD_MINIMIZATION_FAILED : 'force field structure refinement failed',
386
+ CDPL.ConfGen.ReturnCode.FRAGMENT_LIBRARY_NOT_SET : 'fragment library not available',
387
+ CDPL.ConfGen.ReturnCode.FRAGMENT_CONF_GEN_FAILED : 'fragment conformer generation failed',
388
+ CDPL.ConfGen.ReturnCode.FRAGMENT_CONF_GEN_TIMEOUT : 'fragment conformer generation timeout',
389
+ CDPL.ConfGen.ReturnCode.FRAGMENT_ALREADY_PROCESSED : 'fragment already processed',
390
+ CDPL.ConfGen.ReturnCode.TORSION_DRIVING_FAILED : 'torsion driving failed',
391
+ CDPL.ConfGen.ReturnCode.CONF_GEN_FAILED : 'conformer generation failed',
392
+ }
393
+
394
+ # We have to create a temporary file and re-read it for storing individual conformers.
395
+ tmp_dir = os.environ.get('TMPDIR', '/tmp')
396
+ tmp_name = next(tempfile._get_candidate_names()) + '.sdf'
397
+ tmp_filename = os.path.join(tmp_dir, tmp_name)
398
+
399
+ writer = CDPL.Chem.MolecularGraphWriter(tmp_filename, "sdf" )
400
+ # SB - io.StringIO does not work with Chem.MolecularGraphWriter()
401
+
402
+ try:
403
+ # prepare the molecule for conformer generation
404
+ CDPL.ConfGen.prepareForConformerGeneration(mol)
405
+ # generate the conformer ensemble
406
+ status = conf_gen.generate(mol)
407
+ # if successful, store the generated conformer ensemble as
408
+ # per atom 3D coordinates arrays (= the way conformers are represented in CDPKit)
409
+ if status == CDPL.ConfGen.ReturnCode.SUCCESS or status == CDPL.ConfGen.ReturnCode.TOO_MUCH_SYMMETRY:
410
+ # TOO_MUCH_SYMMETRY: output ensemble may contain duplicates
411
+ conf_gen.setConformers(mol)
412
+ writer.write(mol)
413
+ writer.close()
414
+ else:
415
+ raise RuntimeError('Error: conformer generation failed: %s' % status_to_str[status])
416
+ except Exception as e:
417
+ raise RuntimeError('Error: conformer generation failed: %s' % str(e))
418
+
419
+ # tmpfile is automatically closed here but kept, as delete=False was set
420
+
421
+ with Chem.SDMolSupplier(tmp_filename, sanitize=True, removeHs=False) as sdf:
422
+ self.confs = [ Conf(m) for m in sdf if m is not None ]
423
+
424
+ # tmpfile is not deleted here because delete=False
425
+ # we should remove the file when it is no longer needed
426
+ os.remove(tmp_filename)
415
427
 
416
428
  # energy evaluations for ranking
417
429
  for conf in self.confs:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdworks
3
- Version: 0.36.1
3
+ Version: 0.36.3
4
4
  Summary: Frequently used tasks built on RDKit and other tools
5
5
  Author-email: Sung-Hun Bae <sunghun.bae@gmail.com>
6
6
  Maintainer-email: Sung-Hun Bae <sunghun.bae@gmail.com>
@@ -1,10 +1,10 @@
1
- rdworks/__init__.py,sha256=XNynPKNPZU13ohhw1sU4JkJOn4FIf6aQXMLqCDGE0OU,1368
1
+ rdworks/__init__.py,sha256=NUqsdwOfzrq7ScnkWWtLndsZ-yPp6cKnh0xL1Mjrz5Q,1368
2
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=5ZaBIpCnKIqxbIZM0IAJ2uG5fEIlZotw1Lb2QT_IXe0,71145
7
+ rdworks/mol.py,sha256=pAzz16jok2xxDxYgL6L08H5Ne225g-iYX61DeLPbZiQ,71402
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.36.1.dist-info/licenses/LICENSE,sha256=UOkJSBqYyQUvtCp7a-vdCANeEcLE2dnTie_eB1By5SY,1074
69
- rdworks-0.36.1.dist-info/METADATA,sha256=12x3_XSJPwhUcidBwjWyNRTBV7dbWouucI-KzDrw_ac,1183
70
- rdworks-0.36.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
71
- rdworks-0.36.1.dist-info/top_level.txt,sha256=05C98HbvBK2axUBogC_hAT_CdpOeQYGnQ6vRAgawr8s,8
72
- rdworks-0.36.1.dist-info/RECORD,,
68
+ rdworks-0.36.3.dist-info/licenses/LICENSE,sha256=UOkJSBqYyQUvtCp7a-vdCANeEcLE2dnTie_eB1By5SY,1074
69
+ rdworks-0.36.3.dist-info/METADATA,sha256=EoJiTuFvNQ50TU2n4ZZd7N3tNC-QQqdbaqKjiFRHjkA,1183
70
+ rdworks-0.36.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
+ rdworks-0.36.3.dist-info/top_level.txt,sha256=05C98HbvBK2axUBogC_hAT_CdpOeQYGnQ6vRAgawr8s,8
72
+ rdworks-0.36.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5