cheminfo / openchemlib-js

JavaScript port of OpenChemLib
https://cheminfo.github.io/openchemlib-js/index.html
BSD 3-Clause "New" or "Revised" License
72 stars 21 forks source link

fromSmiles and then toSVG not creating expected molecular structure #123

Closed bylethviva closed 2 years ago

bylethviva commented 2 years ago

Hi there! There seem to be some issues when rendering certain chemicals using their smile codes and I'm not sure if I'm doing something wrong or if there is an issue with the library.

When I convert the smile code I for Hydriodic acid I get the correct atoms, but there's no bond shown.

I

Another example is rendering [Na]C#N (Sodium cyanide), no C is rendered in the SVG as can be seen in the pubchem molecular structure.

MFCD00003523

Am I missing a particular option on the toSVG IMoleculeToSVGOptions to render structures correctly? The fromSmiles options don't look that helpful either given the problem I'm running into.

Here's the snippet of code that I'm using currently.

OCL.Molecule.fromSmiles(smileCode).toSVG(200, 100, fileName)
lpatiny commented 2 years ago

By default H are added to the corresponding heavy atom and as far as I know you can not from smiles draw the single bond even using [I][H]. From molfile you should be able to display this bond.

Concerning NaCN the library does not display carbon because it was designed for organic molecules and in organic chemistry we usually don't display carbons.

bylethviva commented 2 years ago

@lpatiny thanks so much for the answers and explanations!