partridgejiang / Kekule.js

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

Another matching issue (Cyclic structures) #93

Closed MrDarkHorse closed 5 years ago

MrDarkHorse commented 5 years ago
screen shot 2018-12-13 at 1 11 58 pm
MrDarkHorse commented 5 years ago

It seems like the standardizer is tripping over normalizing this structure, so the nodes are out of order when it tries to compare them.

MrDarkHorse commented 5 years ago
screen shot 2018-12-13 at 1 22 47 pm screen shot 2018-12-13 at 1 22 12 pm
MrDarkHorse commented 5 years ago

I'm increasingly of the opinion that this change likely caused the regression. I will attempt to prove this tomorrow

https://github.com/partridgejiang/Kekule.js/commit/e1767d7dfa7e935025d56ba09bf35d8ab5bdb01d

partridgejiang commented 5 years ago

@MrDarkHorse Thanks a lot again. A rough fix has been made in commit 8401caa, it seems to solve the problem.

MrDarkHorse commented 5 years ago

I'm still seeing errors on these 2, but I will investigate further

screen shot 2018-12-18 at 11 25 02 am screen shot 2018-12-18 at 11 24 01 am
MrDarkHorse commented 5 years ago

I don't know. Just seems like the canonical index isn't getting set correctly. I get lost in the graph theory stuff though. :\

partridgejiang commented 5 years ago

A little bewildered... In my test: screen shot 2018-12-19 at 09 14 26 @MrDarkHorse Could you please provide the source files of your test cases? Thanks.

MrDarkHorse commented 5 years ago

These should be sufficient. Those 2 files appear to be the same but don't match

partridgejiang commented 5 years ago

eh...... Aren't those two files exactly the same? Maybe a wrong file is pasted here?

MrDarkHorse commented 5 years ago

Oops... trying again

MrDarkHorse commented 5 years ago

{ "coordPos2D": 0, "coordPos3D": 0, "renderOptions": { "expanded": true, "__type__": "object" }, "coord2D": { "x": 2.307956300727386, "y": 5.88003329039293, "__type__": "object" }, "charge": 0, "parity": null, "ctab": { "nodes": [{ "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": -0.6928203230275534, "y": 0.40000000000000213, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": -0.6928203230275543, "y": -0.40000000000000213, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0, "y": 0.8000000000000025, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0, "y": -0.8000000000000043, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0.6928203230275525, "y": 0.40000000000000036, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0.6928203230275525, "y": -0.40000000000000213, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }], "anchorNodes": [], "connectors": [{ "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [0, 1] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [0, 2] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [1, 3] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [2, 4] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [3, 5] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "bondType": "covalent", "bondOrder": 2, "electronCount": 4, "isInAromaticRing": false, "connectedObjs": [4, 5] }], "__type__": "Kekule.StructureConnectionTable" }, "__type__": "Kekule.Molecule" }

MrDarkHorse commented 5 years ago

{ "coordPos2D": 0, "coordPos3D": 0, "renderOptions": { "expanded": true, "__type__": "object" }, "coord2D": { "x": 2.045086640267364, "y": 5.58901262913221, "__type__": "object" }, "charge": 0, "parity": null, "ctab": { "nodes": [{ "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0, "y": -0.8000000000000025, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0.6928203230275525, "y": -0.40000000000000036, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": -0.6928203230275543, "y": -0.40000000000000036, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0.6928203230275525, "y": 0.40000000000000036, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": -0.6928203230275534, "y": 0.40000000000000036, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }, { "__type__": "Kekule.Atom", "coordPos2D": 0, "coordPos3D": 0, "coord2D": { "x": 0, "y": 0.8000000000000025, "__type__": "object" }, "charge": 0, "parity": null, "explicitHydrogenCount": 0, "isotopeId": "C" }], "anchorNodes": [], "connectors": [{ "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [0, 1] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [0, 2] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "bondType": "covalent", "bondOrder": 2, "electronCount": 4, "isInAromaticRing": false, "connectedObjs": [1, 3] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [2, 4] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [3, 5] }, { "__type__": "Kekule.Bond", "coordPos2D": 0, "coordPos3D": 0, "parity": null, "bondType": "covalent", "bondOrder": 1, "electronCount": 2, "isInAromaticRing": false, "connectedObjs": [4, 5] }], "__type__": "Kekule.StructureConnectionTable" }, "__type__": "Kekule.Molecule" }

partridgejiang commented 5 years ago

Still these two structures are same in my test with the latest commits... image

MrDarkHorse commented 5 years ago

Happy New Year!

So I'm running the structure compare demo tool in master, and I pasted the above structures in using the JSON loader.

I modified the demo file to point to the local src, like so:

<title>Molecule Compare</title>

<script src="../../libs/raphael-min.2.0.1.js"></script>
<script src="../../../src/kekule.js"></script>  

Still coming up as different.

screen shot 2019-01-02 at 2 49 39 pm

Are you sure you're both running the latest code and using the exact JSON files that I'm using?

partridgejiang commented 5 years ago

Eh... Sorry that I forgot to update the min js files in demo directoy, and I myself did all those tests on test/algorithmTest/structureCompare.html. Now the demos have been updated, please have another try, :).

MrDarkHorse commented 5 years ago

Oh man.... somehow we had missed SHA 7601bb4a5cdbe7fca0183c39b7352d613e340c9c in our fork.

So this resolved itself. Just took me a while to figure out what was going on.

Thanks!