partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

Formula-Tool: MDL table issue for single atoms? #302

Closed elcoucho closed 1 year ago

elcoucho commented 1 year ago

Hi there,

I've a question about the formula tool and exporting to InChI-Code. Assuming I want to enter a single Chloride-Anion, there are different ways to achieve this in Kekulé.js with different results for displaying and exporting to InChI-Code.

1) Using the "Formula Tool" and then typing "Cl-": Kekulé.js will display it correctly and will automatically superscript the negative charge. However, trying to export this to InChI will result in "Molecule has no connection table and can not be output to MDL format." 2) Inserting Methane using the specific button for this. Afterwards using the "Atom Tool" to change it to chloride. This can be exported to InChI. (However, the charge is not superscripted in the display.)

Now the question: is it possible to make method 1 also export an InChI-Code at least for single atoms/ions, where there can be no connection to other atoms?

Best regards!

partridgejiang commented 1 year ago

Hi @elcoucho, currently the formula tool is not able to generate an atom connection table automatically (generating from Cl- is quite simple but the input formula may be somewhat complex like Ag(NH₃)₂+OH- and so on, there is no universal and straightforward approach to convert it to ctable). So in your case, the second method should be used. After applying charge -1 to the Cl atom, you may use the selecting tool and drag the - symbol around the atom (or with a holding Alt key for a freer drag) to create a superscript outlook, :).

elcoucho commented 1 year ago

Hello @partridgejiang, thanks a lot for the quick answer!

That's a little unfortunate, because we use your editor for our students and use the returned InChI to check if the input is correct. However, I understand the reason you described. As we are planning to switch to the internal json or xml representation in future for checking the answer, this problem should be obsolete in the future. Until then we are going to hide the "Formula Tool" button.

I have another (unrelated) question or better said: a feature request. We like to ask our students in future to draw complete reaction mechanisms. Some mechanisms have transition states (e.g. Sn2-mechanism: https://en.wikipedia.org/wiki/Nucleophilic_substitution#/media/File:Sn2EtCl+bromide.png ), which require to draw dashed bonds. I saw that Kekulé.js supports dashed bonds, but the corresponding button is named "hydrogen bond". Of course it would be wrong to tell our students to use "hydrogen bonds", if they want to indicate bond breakings and bond formation.

To draw transition states I would like to ask for the following to features:

  1. Would it be possible to have another bond type, which is named "dashed bond" (or similar) to represent developing and breaking bonds in transition states?
  2. Is it possible to add a drawing option for brackets like, "( )"; "[ ]" and "{ }".

Kind regards!

partridgejiang commented 1 year ago

Hi @elcoucho, the transition bond type has been added, currently this type of bond is also rendered as a dashed line. Please check the latest dist files in this repo, :). 图片 As for the brackets, they may need a little more efforts, please wait for some time.

elcoucho commented 1 year ago

Dear @partridgejiang, I am absolutely flashed about your fast response and the effort you put into Kekulé.js. It’s an amazing tool!

Thanks a lot for implementing my feature request! :) (Having the new bond type is currently more important than the brackets, so waiting for the brackets is absolutely fine.)