To further clarify what I mean: I created a nonanoic acid representation
(via the smiles code "CCCCCCCCC(=O)O").
"Pelarginic_acid.svg.png" is what I expect to get in terms of coordinates,
while "test_out.png" are the coordinates I actually get.
On Sun, Aug 13, 2017 at 1:30 PM, Peleg Bar-Sapir <pel...@gmail.com> wrote:
> Hi Greg,
>
> Thank you for your reply!
> I tested the method you suggested, but it seems like
> rdMolDraw2D.PrepareMolForDrawing()
> has no affect.
> e.g, I have a molecule m, to which I add hydrogens. I then compute the 2D
> coordinates of m, and use rdMolDraw2D.PrepareMolForDrawing() as you
> suggested.
> To test it, I compare the outputs of Chem.MolToMolBlock() on the molecule
> and on the prepared drawing.
> The results are the same, and it is defently not what you would expect
> from a standard representation (i.e. the ketone oxygen is not vertically up
> from its carbon, the chain is not oriented right, etc.).
>
> See the following explicit example:
>
> In[5]: m = Chem.MolFromSmiles('CCC(O)=O')
>
> In[6]: m = Chem.AddHs(m)
>
> In[7]: AllChem.Compute2DCoords(m)
>
> In[8]: m_draw = Chem.Draw.rdMolDraw2D.PrepareMolForDrawing(m)
>
> In[9]: print (Chem.MolToMolBlock(m))
>
> RDKit 2D
>
> 11 10 0 0 0 0 0 0 0 0999 V2000
> 1.3490 -0.4340 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.3421 0.6778 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> -1.1242 0.3617 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> -1.5836 -1.0662 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
> -2.1311 1.4735 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
> 2.8153 -0.1180 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1.9149 -1.8232 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 0.0792 -1.2326 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1.6119 1.4763 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> -0.2238 2.0669 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> -3.0499 -1.3823 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1 2 1 0
> 2 3 1 0
> 3 4 1 0
> 3 5 2 0
> 1 6 1 0
> 1 7 1 0
> 1 8 1 0
> 2 9 1 0
> 2 10 1 0
> 4 11 1 0
> M END
>
> In[10]: print (Chem.MolToMolBlock(m_draw))
>
> RDKit 2D
>
> 11 10 0 0 0 0 0 0 0 0999 V2000
> 1.3490 -0.4340 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.3421 0.6778 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> -1.1242 0.3617 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
> -1.5836 -1.0662 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
> -2.1311 1.4735 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
> 2.8153 -0.1180 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1.9149 -1.8232 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 0.0792 -1.2326 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1.6119 1.4763 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> -0.2238 2.0669 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> -3.0499 -1.3823 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1 2 1 0
> 2 3 1 0
> 3 4 1 0
> 3 5 2 0
> 1 6 1 0
> 1 7 1 0
> 1 8 1 0
> 2 9 1 0
> 2 10 1 0
> 4 11 1 0
> M END
>
>
> Am I missing something?
>
> Best,
> Peleg
>
> On Sun, Aug 13, 2017 at 11:59 AM, Greg Landrum <greg.land...@gmail.com>
> wrote:
>
>> Hi Peleg,
>>
>> On Sat, Aug 12, 2017 at 4:08 PM, Peleg Bar-Sapir <pel...@gmail.com>
>> wrote:
>>
>>>
>>> I'm trying to get the 2D coordinates and info of all the atoms and
>>> bonds, including hydrogens (i.e. atom type, bond type, etc.) of a molecule
>>> in a standard structural formula. To clarify: I'm not referring to
>>> Chem.MolToMolBlock(), but the coordinates used by the Draw class (e.g. in
>>> MolToFile()) to create standard representations.
>>>
>>> Any advice on how to extract those? Maybe one can reach them via one of
>>> the Draw member functions/variables?
>>>
>>
>> The drawing code calls rdMolDraw2D.PrepareMolForDrawing() before
>> actually doing the drawing. This function, among other things, assigns
>> coordinates. Assuming that you're looking for the coordinates in the
>> molecule's coordinate space, you can get access to them by calling
>> PrepareMolForDrawing() and then either getting a mol block:
>>
>> In [7]: m = Chem.AddHs(Chem.MolFromSmiles('CC#C'))
>>
>> In [8]: nm = rdMolDraw2D.PrepareMolForDrawing(m)
>>
>> In [9]: print(Chem.MolToMolBlock(nm))
>>
>> RDKit 2D
>>
>> 7 6 0 0 0 0 0 0 0 0999 V2000
>> -0.6887 -0.0795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
>> 0.8112 -0.0614 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
>> 2.3111 -0.0433 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
>> -1.4230 -1.3875 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
>> -2.1044 0.4165 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
>> -0.4461 1.4007 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
>> 1.5400 -0.2455 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
>> 1 2 1 0
>> 2 3 3 0
>> 1 4 1 0
>> 1 5 1 0
>> 1 6 1 0
>> 3 7 1 0
>> M END
>>
>>
>> Or by using the molecule's conformer object:
>>
>> In [13]: conf = nm.GetConformer()
>>
>> In [14]: for aidx in range(conf.GetNumAtoms()):
>> ...: pos = conf.GetAtomPosition(aidx)
>> ...: print(pos.x, pos.y, pos.z)
>> ...:
>> -0.6887274130576998 -0.07950997820751476 0.0
>> 0.8111632161215289 -0.0613964335423347 0.0
>> 2.311053845300757 -0.04328288887715446 0.0
>> -1.4229859378146839 -1.387510138307542 0.0
>> -2.104358766425875 0.416461665499047 0.0
>> -0.4461124978218231 1.4007393261007453 0.0
>> 1.5399675536977953 -0.24550155266524612 0.0
>>
>>
>> I'm not sure what kind of additional info you are looking for, but maybe
>> this much helps?
>>
>> -greg
>>
>>
>>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss