reymond-group / smilesDrawer

A small, highly performant JavaScript component for parsing and drawing SMILES strings. Released under the MIT license.
https://smilesdrawer.rocks
MIT License
416 stars 66 forks source link

Problem : Drawing multiple Smiles separates by "." / drawing complexe smile using "." ionic bond #184

Open fjuniat opened 4 months ago

fjuniat commented 4 months ago

Hello, I would like to draw the 2,2,2-Trifluoroethylamine hydrochloride chemical with the following SMILE : "C(C(F)(F)F)N.Cl" that has a ionic bond.

https://pubchem.ncbi.nlm.nih.gov/compound/9772#section=IUPAC-Name

However, when I tried to draw it, I obtain a result with some hydrogens missing :

Capture d'écran 2024-03-04 161452

The "N" should have two hydrogens. And the Cl one.

In the file Edge.js, we have theses following bounds : image

I found that the "." is missing and during the "setBondType" the return weight will be "undefined". One "edge" in _init of Graph.js will have a weight undefined and during the "addEdge", we will have a result of number += undefined. The result will be "NaN" and the added hyrdogens by comparing the weights will not be added.

Do you have a solution to draw molecule that has ionic bound please ?

Thanks

xavierholt commented 2 months ago

You could specify the hydrogens explicitly - this SMILES string seems to give what you're looking for:

C(C(F)(F)F)[NH2].[ClH]
Screen Shot 2024-05-07 at 8 56 18 PM