Re: [Rdkit-discuss] Extracting data of a standard structural formula

2017-08-16 Thread Peleg Bar-Sapir
Hi Jason,

yes, indeed it helped!
Many many thanks!

Regards,
Peleg

On Sun, Aug 13, 2017 at 4:29 PM, Jason Biggs  wrote:

> Peleg,
> I was doing something similar using the c++ function compute2DCoords,
> where you can give a coordinate map as the second argument.  It looks like
> this is exposed in python, using the Compute2DCoords method (
> http://www.rdkit.org/Python_Docs/rdkit.Chem.rdchem.Mol-
> class.html#Compute2DCoords), so you could do something like this
>
>   int generate2DCoordinatesPlacintHeavyAtomsFirst( RDKit::RWMol 
> *thisMolecule,
>   bool placeHeavyAtomsFirst,
>   bool canonicalize,
>   int randomseed)
>   {
>
>
>   int hydrogenFreeConformerIndex = 
> RDDepict::compute2DCoords(*thisMolecule, 0,
>   canonicalize);
>
>   //now make a map of the coordinates which were optimized
>   //sans hydrogens
>
>   RDGeom::INT_POINT2D_MAP coordMap;
>   if(placeHeavyAtomsFirst)
>   {
>   int numAtoms = thisMolecule->getNumAtoms();
>   RDKit::Conformer hydrogenFreeConformer = 
> thisMolecule->getConformer(hydrogenFreeConformerIndex);
>   for (int i=0; i < numAtoms; i++)
>   {
>   RDGeom::Point3D pt = 
> hydrogenFreeConformer.getAtomPos(i);
>   RDGeom::Point2D pt2;
>   pt2.x = pt.x;
>   pt2.y = pt.y;
>   coordMap[i] = pt2;
>   }
>   }
>
>   RDKit::MolOps::addHs(*thisMolecule, false, false);
>
>   int confID = RDDepict::compute2DCoords(
>   *thisMolecule,
>   placeHeavyAtomsFirst ? &coordMap : 0, true);
>   const RDKit::Conformer &conf = 
> thisMolecule->getConformer(confID);
>   RDKit::WedgeMolBonds(*thisMolecule, &conf);
>   return confID;
>
>   }
>
>
> Now when I feed the result to my plotting program, I can give the option
> of showing hydrogens or not, getting these two diagrams
>
> Hope this helps,
>
> Jason
>
>
> On Sun, Aug 13, 2017 at 6:45 AM, Peleg Bar-Sapir  wrote:
>
>> Greg,
>>
>> sorry for flooding you with replies, I think I understand where they
>> issue stems from: the added hydrogens.
>> Without the hydrogens the positions look fine (see C9_acid_out.png).
>> Is there a way to add hydrogens so it will form a more "classic"
>> representation? (e.g. C9_acid_expect.png)
>>
>> Best,
>> Peleg
>>
>> On Sun, Aug 13, 2017 at 1:36 PM, Peleg Bar-Sapir 
>> wrote:
>>
>>> To further clarify what I mean: I created a nonanoic acid representation
>>> (via the smiles code "C(=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 
>>> 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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
 0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
-1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
-1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
-2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
 2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
 1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
 0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
 1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
-0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
-3.0499   -1.38230. H   0  0  0  0  0  0  0  0  0  0  0  0
   1  2  1  0
   2  3  1  0
   3  

Re: [Rdkit-discuss] Extracting data of a standard structural formula

2017-08-13 Thread Jason Biggs
Peleg,
I was doing something similar using the c++ function compute2DCoords, where
you can give a coordinate map as the second argument.  It looks like this
is exposed in python, using the Compute2DCoords method (
http://www.rdkit.org/Python_Docs/rdkit.Chem.rdchem.Mol-class.html#Compute2DCoords),
so you could do something like this

int generate2DCoordinatesPlacintHeavyAtomsFirst( RDKit::RWMol 
*thisMolecule,
bool placeHeavyAtomsFirst,
bool canonicalize,
int randomseed)
{


int hydrogenFreeConformerIndex = 
RDDepict::compute2DCoords(*thisMolecule, 0,
canonicalize);

//now make a map of the coordinates which were optimized
//sans hydrogens

RDGeom::INT_POINT2D_MAP coordMap;
if(placeHeavyAtomsFirst)
{
int numAtoms = thisMolecule->getNumAtoms();
RDKit::Conformer hydrogenFreeConformer =
thisMolecule->getConformer(hydrogenFreeConformerIndex);
for (int i=0; i < numAtoms; i++)
{
RDGeom::Point3D pt = 
hydrogenFreeConformer.getAtomPos(i);
RDGeom::Point2D pt2;
pt2.x = pt.x;
pt2.y = pt.y;
coordMap[i] = pt2;
}
}

RDKit::MolOps::addHs(*thisMolecule, false, false);

int confID = RDDepict::compute2DCoords(
*thisMolecule,
placeHeavyAtomsFirst ? &coordMap : 0, true);
const RDKit::Conformer &conf = 
thisMolecule->getConformer(confID);
RDKit::WedgeMolBonds(*thisMolecule, &conf);
return confID;

}


Now when I feed the result to my plotting program, I can give the option of
showing hydrogens or not, getting these two diagrams

Hope this helps,

Jason


On Sun, Aug 13, 2017 at 6:45 AM, Peleg Bar-Sapir  wrote:

> Greg,
>
> sorry for flooding you with replies, I think I understand where they issue
> stems from: the added hydrogens.
> Without the hydrogens the positions look fine (see C9_acid_out.png).
> Is there a way to add hydrogens so it will form a more "classic"
> representation? (e.g. C9_acid_expect.png)
>
> Best,
> Peleg
>
> On Sun, Aug 13, 2017 at 1:36 PM, Peleg Bar-Sapir  wrote:
>
>> To further clarify what I mean: I created a nonanoic acid representation
>> (via the smiles code "C(=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 
>> 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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
>>> 0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
>>>-1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
>>>-1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
>>>-2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
>>> 2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
>>> 1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
>>> 0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
>>> 1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
>>>-0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
>>>-3.0499   -1.38230. 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  

Re: [Rdkit-discuss] Extracting data of a standard structural formula

2017-08-13 Thread Peleg Bar-Sapir
To further clarify what I mean: I created a nonanoic acid representation
(via the smiles code "C(=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  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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
> 0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
>-1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
>-1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
>-2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
> 2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
> 1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
> 0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
> 1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
>-0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
>-3.0499   -1.38230. 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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
> 0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
>-1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
>-1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
>-2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
> 2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
> 1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
> 0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
> 1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
>-0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
>-3.0499   -1.38230. 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 
> wrote:
>
>> Hi Peleg,
>>
>> On Sat, Aug 12, 2017 at 4:08 PM, Peleg Bar-Sapir 
>> 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.07950. C   0  0  0  0  0  0  0  0  0  0  0  0
>> 0.8112   -0.06140. C   0  0  0  0  0  0  0  0  0  0  0  0
>> 2.3111   -0.04330. C   0  0  0  0  0  0  0  0  0  0  0  0
>>-1.4230   -1.38750. H   0  0  0  0  0  0  0  0  0  0  0  0
>>-2.10440.41650. H   0  0  0  0  0  0  0  0  0  0  0  0
>>-0.44611.40070. H   0  0  0  0  0  0  0  0  0  0  0  0
>> 1.5400   -0.2455 

Re: [Rdkit-discuss] Extracting data of a standard structural formula

2017-08-13 Thread Peleg Bar-Sapir
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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
   -2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
   -3.0499   -1.38230. 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.43400. C   0  0  0  0  0  0  0  0  0  0  0  0
0.34210.67780. C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.12420.36170. C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.5836   -1.06620. O   0  0  0  0  0  0  0  0  0  0  0  0
   -2.13111.47350. O   0  0  0  0  0  0  0  0  0  0  0  0
2.8153   -0.11800. H   0  0  0  0  0  0  0  0  0  0  0  0
1.9149   -1.82320. H   0  0  0  0  0  0  0  0  0  0  0  0
0.0792   -1.23260. H   0  0  0  0  0  0  0  0  0  0  0  0
1.61191.47630. H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.22382.06690. H   0  0  0  0  0  0  0  0  0  0  0  0
   -3.0499   -1.38230. 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 
wrote:

> Hi Peleg,
>
> On Sat, Aug 12, 2017 at 4:08 PM, Peleg Bar-Sapir  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.07950. C   0  0  0  0  0  0  0  0  0  0  0  0
> 0.8112   -0.06140. C   0  0  0  0  0  0  0  0  0  0  0  0
> 2.3111   -0.04330. C   0  0  0  0  0  0  0  0  0  0  0  0
>-1.4230   -1.38750. H   0  0  0  0  0  0  0  0  0  0  0  0
>-2.10440.41650. H   0  0  0  0  0  0  0  0  0  0  0  0
>-0.44611.40070. H   0  0  0  0  0  0  0  0  0  0  0  0
> 1.5400   -0.24550. 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.043

Re: [Rdkit-discuss] Extracting data of a standard structural formula

2017-08-13 Thread Greg Landrum
Hi Peleg,

On Sat, Aug 12, 2017 at 4:08 PM, Peleg Bar-Sapir  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.07950. C   0  0  0  0  0  0  0  0  0  0  0  0
0.8112   -0.06140. C   0  0  0  0  0  0  0  0  0  0  0  0
2.3111   -0.04330. C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.4230   -1.38750. H   0  0  0  0  0  0  0  0  0  0  0  0
   -2.10440.41650. H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.44611.40070. H   0  0  0  0  0  0  0  0  0  0  0  0
1.5400   -0.24550. 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.0432827715446 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


[Rdkit-discuss] Extracting data of a standard structural formula

2017-08-12 Thread Peleg Bar-Sapir
Hello all,

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?

Best,
Peleg
--
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