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

Connect multiple benzene rings, presenting a large circle #162

Open liu7A opened 1 year ago

liu7A commented 1 year ago

hi bro, I like SMILES DRAWER! THX.

I used a MOLVIEW to draw a number of benzene rings, and a large ring shape appeared on the SMILES_DRAWER.

SMILES: C(C1=CC=CC=C1)1=CC=C(C2C=CC(C3C=CC(C4C=CC(C5C=CC=CC=5)=CC=4)=CC=3)=CC=2)C=C1

MOLVIEW:

image

SMILES_DRAWER:

image
xavierholt commented 2 months ago

This looks like a backreference parsing bug. Reference 1 to the first carbon in the chain should have been cleared as soon as the next 1 linked back to it. But it looks like when parsing reaches the end of the SMILES string, 1 still refers to the original carbon.

You can work around this by using 6 instead of 1 for the other reference:

C(C1=CC=CC=C1)6=CC=C(C2C=CC(C3C=CC(C4C=CC(C5C=CC=CC=5)=CC=4)=CC=3)=CC=2)C=C6