Re: [Rdkit-devel] drawing amino acids
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Greg L. <gre...@gm...> - 2017-09-08 12:27:41
|
On Fri, Sep 8, 2017 at 2:10 PM, Igor Filippov <igo...@gm...>
wrote:
>
>>
>> Could it be that you didn't generate coordinates for the molecule?
>>
>> The result is the same for me whether I load the molecule from an SD file
> with coordinates, or generate 2D or 3D coordinates on the fly.
> Does it display correctly for you?
>
Yeah, This snippet:
In [21]: m = Chem.MolFromSmiles('NC(=O)C(N)CCCC[NH3+]')
In [22]: nm = Draw.PrepareMolForDrawing(m)
In [23]: d = Draw.MolDraw2DCairo(200,200)
In [24]: d.DrawMolecule(nm)
In [25]: d.FinishDrawing()
In [26]: open('blah.png','wb+').write(d.GetDrawingText())
Out[26]: 2730
Produces the png file that's attached.
> BTW: rdMolDraw2D.PrepareMolForDrawing() is a useful function to know
>> about.
>>
> I am doing it from c++, is there an equivalent there?
>
Sure, here's some testing code that uses it:
https://github.com/rdkit/rdkit/blob/9af90524a41825b67ffb19cdbff9b363d5a7ca7e/Code/GraphMol/MolDraw2D/test1.cpp#L987
There are a bunch of other examples in that file too.
-greg
|