partridgejiang / Kekule.js

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

Allow symbols for atom without throwing error #278

Closed agrodet closed 2 years ago

agrodet commented 2 years ago

Hello. In https://github.com/partridgejiang/Kekule.js/issues/135 , you mentioned a way to forbid unknown atom symbols. Is there any way to allow some additional symbols? In particular, I would like to be able to use * without throwing any error, especially the following bar image

Even with setAllowUnknownAtomSymbol(true), I'm facing an error if I modify, let's say an oxygen atom to *, but the label is replaced. However, if I try to do it a second time, I'm facing an error that doesn't let me do anything.

Notice that the SMILES is generated with * as expected COc1cc(ccc1)CNC(=O)c2cc3c(cc2)n(c(n3)N)CCC[*]C.

partridgejiang commented 2 years ago

Hi @agrodet, by default, any symbol input (including *) is allowed for atom. When an unknown symbol is received, the atom will be simply set to Pseudoatom and there should be no errors be thrown out. The attached video file illustrates the modification process.

https://user-images.githubusercontent.com/10516825/164010391-446adb38-f9a9-48ae-b68c-f1fcb02ccfd2.mp4

Please play with the editor demo page (http://partridgejiang.github.io/Kekule.js/demos/items/chemEditor/chemEditor.html) to check whether those errors still exist.

agrodet commented 2 years ago

Dear @partridgejiang, thank you for your prompt response! I understand the problem. I'm facing the issue I mentioned when using the "Set atom" button of the "Select tool". I've made a small video.

https://user-images.githubusercontent.com/42261966/165202219-2c826b2f-ee11-49bf-bf61-ed5cc8dbe26e.mov

partridgejiang commented 2 years ago

Thanks for the attached video helping to locate the bug. Now a fix has been made, please check the new dist file and have a test.

agrodet commented 2 years ago

Thank you. It seems that everything is working as expected now.