Drkcore

05 05 2021 chemoinformatics q-chem Tweet

Storing GAMESS calculation results in RDKit Chem object

Japan is under a state of emergency for the third time, which forced me to do self-quarantine. After all, my five days of GW holidays were spent developing the pygamess library.

This is an example of storing GAMESS calculation results into RDKit's Chem object. I will calculate the two molecules, ethane, and ethanol, to export as an SDF file later.

>>> from pygamess import Gamess
>>> from pygamess.utils import rdkit_optimize
>>> from rdkit import Chem
>>> ethane = rdkit_optimize("CC")
>>> ethanol = rdkit_optimize("CCO")
>>> g = Gamess()
>>> g.run_type("optimize")
>>> ethane_result = g.run(ethane)
>>> optimized_ethane = ethane_result.mol
>>> ethanol_result = g.run(ethanol)
>>> optimized_ethanol = ethanol_result.mol

Orbital energies and dipole moments including HOMO and LUMO energies are stored in the object. Each atom is also assigned a mulliken charge/lowdin charge.

>>> optimized_ethane.GetProp("HOMO")
'-0.46029999999999999'
>>> optimized_ethane.GetProp("LUMO")
'0.65559999999999996'
>>> optimized_ethane.GetProp("dipole_moment")
'1.9999999999999999e-06'
>>> optimized_ethane.GetProp("orbital_energies")
'-11.0355 -11.0352 -0.981 -0.8121 -0.572 -0.572 -0.4717 -0.4603 -0.4603 0.6556 0.6556 0.687 0.737 0.7814 0.7893 0.7893'
>>> for a in optimized_ethane.GetAtoms():
...   print("{}:\t{:.4f}".format(a.GetSymbol(), float(a.GetProp("mulliken_charge"))))
... 
C:  -0.1748
C:  -0.1748
H:  0.0583
H:  0.0583
H:  0.0583
H:  0.0583
H:  0.0583
H:  0.0583

Finally, I'll export the object to SDF.

>>> optimized_mols = [optimized_ethane, optimized_ethanol]
>>> w = Chem.SDWriter('test.sdf')
>>> for m in optimized_mols:
...   w.write(m)
... 
>>> w.close()

Looking at the exported SDF, we can see these results are persisted.

$ cat test.sdf
     RDKit          3D

  8  7  0  0  0  0  0  0  0  0999 V2000
   -0.7687    0.0082   -0.0152 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7687   -0.0082    0.0152 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1742   -0.1016    0.9863 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1352    0.9432   -0.4285 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1499   -0.8048   -0.6260 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.1499    0.8048    0.6260 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.1742    0.1016   -0.9863 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.1352   -0.9432    0.4285 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0
  1  3  1  0
  1  4  1  0
  1  5  1  0
  2  6  1  0
  2  7  1  0
  2  8  1  0
M  END
>  <total_energy>  (1) 
-78.306179626800002

>  <HOMO>  (1) 
-0.46029999999999999

>  <LUMO>  (1) 
0.65559999999999996

>  <nHOMO>  (1) 
-0.46029999999999999

>  <nLUMO>  (1) 
0.65559999999999996

>  <dipole_moment>  (1) 
1.9999999999999999e-06

>  <dx>  (1) 
-0

>  <dy>  (1) 
-1.9999999999999999e-06

>  <dz>  (1) 
0

>  <orbital_energies>  (1) 
-11.0355 -11.0352 -0.981 -0.8121 -0.572 -0.572 -0.4717 -0.4603 -0.4603 0.6556 0.6556 0.687 0.737 0.7814 0.7893 0.7893

>  <atom.dprop.mulliken_charge>  (1) 
-0.174764 -0.174764 0.058255000000000001 0.058255000000000001 0.058254 0.058255000000000001 0.058255000000000001 0.058255000000000001

TODO: Add GAMESS calculation conditions as attributes, like "HF/6-31G**".

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021