Re: [Rdkit-devel] drawing amino acids
Greg, I figured out what the problem is: getStringSize() calculates the pixel height/width of a given atom label. For labels such as NH3+ the argument this function is getting is NH3+ which makes for a very long sting, which throws off the scale calculation. I am not sure why it works correctly with the drawers other than SVG but for wxWidgets I need to clean from the label , , , and before computing the string width. Hope this helps to someone who might have the same problem. Best regards, Igor On Fri, Sep 8, 2017 at 8:29 AM, Igor Filippovwrote: > Great - thanks, I'll try it! > > Igor > > On Fri, Sep 8, 2017 at 8:27 AM, Greg Landrum > wrote: > >> >> On Fri, Sep 8, 2017 at 2:10 PM, Igor Filippov >> 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)[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/9af90524a41825b67ffb19cd >> bff9b363d5a7ca7e/Code/GraphMol/MolDraw2D/test1.cpp#L987 >> >> There are a bunch of other examples in that file too. >> >> -greg >> >> > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-devel mailing list Rdkit-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-devel
Re: [Rdkit-devel] drawing amino acids
Great - thanks, I'll try it! Igor On Fri, Sep 8, 2017 at 8:27 AM, Greg Landrumwrote: > > On Fri, Sep 8, 2017 at 2:10 PM, Igor Filippov > 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)[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/9af90524a41825b67ffb19cdbff9b3 > 63d5a7ca7e/Code/GraphMol/MolDraw2D/test1.cpp#L987 > > There are a bunch of other examples in that file too. > > -greg > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-devel mailing list Rdkit-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-devel
Re: [Rdkit-devel] drawing amino acids
Hi Igor, Could it be that you didn't generate coordinates for the molecule? BTW: rdMolDraw2D.PrepareMolForDrawing() is a useful function to know about. -greg On Thu, Sep 7, 2017 at 2:16 PM, Igor Filippovwrote: > Dear Colleagues, > > I seem to remember there already was a discussion about this, > but I cannot find the relevant email thread, nor recall what was the > conclusion. > > When I try to draw the following molecule I am getting an image of a few > pixels in size, quite > unusable. > > NC(=O)C(N)[NH3+] > > Has anyone else seen this problem? > > Best regards, > Igor > > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > ___ > Rdkit-devel mailing list > Rdkit-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-devel > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Rdkit-devel mailing list Rdkit-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-devel