Re: [Rdkit-discuss] RDKit Font weight
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: mark <em...@ej...> - 2017-10-18 10:12:29
|
Thanks Greg - it's nice of you to even be willing to support the old drawing methods in terms of documenting them. I did have a search for Cairo docs but my quick goog ran aground. I had been expecting to roll something to process obabel svg output, I thought I'd get more of the control done from the source conversion of InchI to SVG and that's still the case - I'll look further into the rdkit code. Could I ask: 1) Which of MolDraw2DSVG and MolDraw2DCairo is best (hopefully not too contentious a question). My requirement is to ideally: a. Take InchI string b. Render as a set of SVGs optimised for current iPhone, iPad and latest Android screen resolutions - transparent bg - all white bonds and atom text in sans bold - ensure all non-carbon atoms' text identifiers are perfectly positioned in the mol render (think max-posh latest mobile rendering) + this is so that as technology advances, each device equivalent will get a higher res-still, but as SVG, the nearest image to fit will scale OK (probably until I end up using iPad-optimised images for iPhones...) with no worries about antialiasing artefacts, bond lines perfectly meeting each end it was originally rendered to, as the svg is scaled to fit a new, slightly larger resolution + I've given up the notion of being able to rotate a molecule after rendering and have the text remain the right way up - unless you know of a way (not googled this yet) c. Use a self-rolled post-pro script to edit the svg into the required state (such as bold text etc) as needed d. Use python where possible 2) You mention using c++ classes, and although I can programme c++ my knowledge is 20 years old; I can programme c and python more easily, so are you suggesting I need to actually write this in c++? Thanks, Mark Lewis > On 18 Oct 2017, at 10:48, Greg Landrum <gre...@gm...> wrote: > > Hi Mark, > > I'm afraid that a lot of the fine control that it looks like you want is not going to be possible. But I will do what I can. > > Your questions are all connected to the old, pure Python, drawing code. We're not doing anything further with this and I'm encouraging people to switch over to the new C++ drawing code. There are some functions in rdkit.Chem.Draw that use this, but if you're interested in having a bit more control over the options, you should use the MolDraw2DSVG or MolDraw2DCairo classes for this. > > A general point is that all of this stuff is "under documented". There is some info on the RDKit blog, but the best way to figure out how to use it is generally via searching the mailing list, asking here, or just experimenting with the options that are there. I will eventually write docs for this, but it's one of those things that can also be done by members of the community. > > A couple more detailed answers, in the context of using MolDraw2DSVG since I think that's what you're looking to generate, are below. > > On Wed, Oct 18, 2017 at 7:21 AM, mark <em...@ej... <mailto:em...@ej...>> wrote: > This outputs several files for various screen sizes of mobile I'm developing for. > > 1) How can I make the font weight bold? or italic for that matter. The sping/piddle docs list these with the font face and size but these are split out in the rdkit docs > > At the moment there's no way to do this other than editing the SVG that comes out of the rendering code. As long as you want all the text to be the same, this is a straightforward string replacement operation. Finer control than that is not currently possible. > > 2) I found http://www.rdkit.org/docs/api/rdkit.Chem.Draw.MolDrawing%27.DrawingOptions-class.html <http://www.rdkit.org/docs/api/rdkit.Chem.Draw.MolDrawing'.DrawingOptions-class.html> having looked at the code for MolDrawing, but there appears to be no documentation as regard what each of these options does. Where is this documentation? > > non-existent, see above > > 3) Even with options.defaultColor = (1, 1, 1) non-carbon atoms display coloured (O red, N blue etc). But I need a monochrome image. Can anyone confirm if monochrome images are possible please and how this is done? > > Here's how you draw a molecule in black and white using the new code: > d = Draw.MolDraw2DSVG(300, 300) > d.drawOptions().useBWAtomPalette() > d.DrawMolecule(dm) > d.FinishDrawing() > > > 4) In the attached image, you will notice that the non-carbon, non-hydrogen atoms are slightly out of place, too far down from exactly where they are expected to be drawn. How can this be adjusted? It appears not to matter what I set the font size to, they are always out of place. I think this might be because of the fact the glyphs are aligned to the bottom of their containers in the svg. > > <PastedGraphic-1.png> > > > Dealing with this stuff in a cross-platform way is a really hard problem. Try the new code out. You may find that it's better at this. It should at least have different pathologies. :-S > > Great kit! > > Thanks! > > -greg > > > Thanks IA, > > Mark Lewis > > > > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot <http://sdm.link/slashdot> > _______________________________________________ > Rdkit-discuss mailing list > Rdk...@li... <mailto:Rdk...@li...> > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss <https://lists.sourceforge.net/lists/listinfo/rdkit-discuss> > > |