3
$\begingroup$

I have a need to automatically draw SMARTS reactions. Rdkit's drawings are suboptimal. OpenBabel's drawings don't work properly on macOS. Indigo's drawings are cut off half the page.

I would love to use ChemDraw, but I can't seem to find an API for it to draw reactions with SMILES/SMARTS. I would absolutely be willing to write a wrapper to do this if there is a nice API to actually programmatically do drawings headlessly.

$\endgroup$
4
  • 3
    $\begingroup$ Also, what do you mean by "Rdkit's drawings are suboptimal"? $\endgroup$ Dec 21, 2020 at 9:27
  • $\begingroup$ Open Babel works fine on Mac - I'm one of the developers and using a MacBook. The easiest solution is to export to SVG. But I'd recommend RDKit - it currently has the best depiction methods IMHO. $\endgroup$ Dec 24, 2020 at 3:23
  • $\begingroup$ @StanislavBashkyrtsev RDKit's drawings are just ugly. For example, double bonds are not properly centered. Try drawing an aldehyde with an implicit hydrogen. You will see that the double bond does not align properly. Furthermore, the reagents in reactions are seemingly randomly rotated. They do not all have the same 30º, 150º, 270º to the horizontal that you would expect. Some are rotated differently than others for seemingly no reason, and this is not configurable. You need to hack it to not draw weird radicals when drawing SMARTS. Finally, bond lengths etc. are not configurable. $\endgroup$ Dec 25, 2020 at 7:15
  • $\begingroup$ @GeoffHutchison OpenBabel reaction SMILES to PNG or SVG does not properly work on macOS. See more here: github.com/openbabel/openbabel/issues/2306 $\endgroup$ Dec 25, 2020 at 7:16

1 Answer 1

3
$\begingroup$

OpenEye is probably the most powerful and fast depiction SDK, but it costs money. Also OpenEye is a low-level, cumbersome, complicated library - so I'd consider it only if you have very sophisticated needs. It's written in C++, but it has Python/Java wrappers.

CDK (Java) has an OS-agnostic depiction API, works great for simple needs, haven't tried anything super complicated.

I tried Indigo several years ago and it worked fine, maybe you misconfigured it? Though it did require an additional OS-level dependency for fonts (Cargo?) on Linux. Don't remember if there were problems with other OS's.

$\endgroup$
4
  • $\begingroup$ OpenEye is great looking. I may shoot them an email to see if I can get some academic license since I am a university student intending to use this software for notetaking. The example drawings on CDK certainly look very promising. I installed Indigo via Homebrew first, and it did not come with indigo-depict. So, I downloaded the executable directly from their website. It produced quite an ugly depiction which was unusable because the whole drawing was offset to the left and downwards and several carbons of the leftmost reagent are cut off. $\endgroup$ Dec 25, 2020 at 7:20
  • $\begingroup$ Accepting this answer because the CDK drawings are fantastic. They are almost as good as ChemDraw, and certainly much better than any of the other tools I have tried (OpenBabel, Indigo, and RDKit) Thanks! $\endgroup$ Dec 25, 2020 at 7:23
  • $\begingroup$ One thing I will note is that unfortunately it apears that CDK does not handle reaction SMARTS but instead reaction SMILES. It does not properly handle things like degree, for example. $\endgroup$ Dec 25, 2020 at 7:35
  • $\begingroup$ @ThorCorreia, you can raise a ticket for this: github.com/cdk/cdk CDK team usually is pretty responsive. $\endgroup$ Dec 25, 2020 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.