partridgejiang / Kekule.js

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

Stereoisomers comparison giving false negative #193

Open franciscohanna92 opened 4 years ago

franciscohanna92 commented 4 years ago

Hi there!

I'm trying to do some stereoisomers comparison, but I think Kekule is giving me a false negative. The two stereoisomers that I'm comparing are:

image image

The options for compare are:

{
  "method": 10,
  "doStandardize": false,
  "extraComparisonProperties": [
    "canonicalizationIndex"
  ],
  "lonePair": true,
  "hydrogen_display_type": "IMPLICIT",
  "stereo": true,
  "skeletalMode": true,
  "strictStereoBondGeometry": true,
  "atom": true,
  "compareAtom": true,
  "mass": true,
  "compareMass": true,
  "linkedConnectorCount": true,
  "compareLinkedConnectorCount": true,
  "charge": true,
  "compareCharge": true,
  "radical": true,
  "compareRadical": true,
  "compareStereo": true,
  "hydrogenCount": true,
  "compareHydrogenCount": true,
  "connectedObjCount": true,
  "compareConnectedObjCount": true,
  "bondType": true,
  "compareBondType": true,
  "bondOrder": true,
  "compareBondOrder": true
}

What am I doing wrong here? Is this something that Kekule supports out of the box?

franciscohanna92 commented 4 years ago

I see that the comparison for the following works fine: image image

partridgejiang commented 4 years ago

Hi @franciscohanna92, the test with the latest dist of Kekule.js gives a positive result: 图片 Please try again with the latest files on GitHub, since in some old releases, there did exist a bug that causes wrong comparison result on molecules with explicit hydrogen atoms. By the way, when doing molecule comparison, it is recommended to set doStandardize option to true. Otherwise the molecules may not be canonicalized before comparison, thus a wrong result may be invoked too.

franciscohanna92 commented 4 years ago

Hi @partridgejiang , thanks for your answer. Indeed, the latest version of Kekule works fine. Sadly, we have a heavily modified version of it, for which its maintainers no longer work on the project.

I see that the point of failure (for the example above) in our Kekule version is this line https://github.com/partridgejiang/Kekule.js/blob/fa64625d6486c0aa752dadd10fedaa15310ce275/src/core/kekule.structures.js#L1208

Any clues on why this may be failing? I'm setting doStandardize: true

partridgejiang commented 4 years ago

Hi @franciscohanna92, please check if /algorithm/kekule.structures.stereos.js has been modified in your version. If not, perhaps you could overwrite it with the file in this repository directly?