About the best I can think of is to set a property on the molecule and
generate an SDF. This contains the information, but is somewhat ugly:


In [19]: m = Chem.MolFromSmiles('c1cccnc1OC')

In [20]: AllChem.ComputeGasteigerCharges(m)

In [21]: chgs = [x.GetDoubleProp('_GasteigerCharge') for x in m.GetAtoms()]

In [22]: m.SetProp('GasteigerCharges','\n'.join(['%.3f'%x for x in chgs]))

In [23]: from io import StringIO

In [24]: sio = StringIO()

In [25]: w = Chem.SDWriter(sio)

In [26]: w.write(m)

In [27]: w.flush()

In [28]: print(sio.getvalue())

     RDKit

  8  8  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0
  2  3  1  0
  3  4  2  0
  4  5  1  0
  5  6  2  0
  6  7  1  0
  7  8  1  0
  6  1  1  0
M  END
>  <GasteigerCharges>  (1)
0.000
-0.055
-0.044
0.031
-0.222
0.212
-0.481
0.079

$$$$

Maybe there's a better solution. What are you trying to do with the partial
charge data?

-greg


On Mon, Oct 31, 2016 at 6:11 PM, James Johnson <totalboron...@gmail.com>
wrote:

> Is there any supported format that outputs partial charges?
>
> The speed of RDKit is phenomenal (0.02 seconds) vs obabel's 2 seconds, but
> if I cannot output partial charges I'll be forced to use obabel.
>
> Thank you for your time.
>
> -James
>
> On Mon, Oct 31, 2016 at 1:00 AM, Greg Landrum <greg.land...@gmail.com>
> wrote:
>
>> Hi James,
>>
>> Due to problems with the general ambiguity of the format the RDKIt does
>> not have a mol2 writer.
>>
>> -greg
>>
>>
>>
>>
>>
>> On Mon, Oct 31, 2016 at 12:22 AM +0100, "James Johnson" <
>> totalboron...@gmail.com> wrote:
>>
>> Hello all,
>>>
>>> I've been trying to output my 3D mol object that has Gasteiger charges
>>> to mol2 file format. How would I go about that? I've only found it for mol
>>> and pdb.
>>>
>>> Here is the code I'be been using if that helps:
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> from rdkit import Chem
>>> from rdkit.Chem import AllChem
>>>
>>> smile = 'Cc1ccccc1'
>>>
>>> uncharged_mol_1D = Chem.MolFromSmiles(smile)
>>>
>>> uncharged_mol_3D = Chem.AddHs(uncharged_mol_1D)
>>> AllChem.EmbedMolecule(uncharged_mol_3D)
>>> AllChem.UFFOptimizeMolecule(uncharged_mol_3D)
>>>
>>> charged_mol_3D = uncharged_mol_3D
>>> AllChem.ComputeGasteigerCharges(charged_mol_3D)
>>>
>>> fout = Chem.SDWriter('./charged_test.mol')
>>> fout.write(charged_mol_3D)
>>> fout.close()
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> Thank you!
>>>
>>
>
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to