cheminfo / openchemlib-js

JavaScript port of OpenChemLib
https://cheminfo.github.io/openchemlib-js/index.html
BSD 3-Clause "New" or "Revised" License
71 stars 20 forks source link

getSimilarityTanimoto from SSSearcherWithIndex #201

Closed aa-schoepfer closed 2 months ago

aa-schoepfer commented 2 months ago

Hello, I'm trying to compute similarities with SSSearcherWithIndex

Here is a snippet to simulate my problem using version 8.9.0:

const { Molecule, SSSearcherWithIndex } = require('openchemlib');

const mol1 = Molecule.fromSmiles('CO');
const mol2 = Molecule.fromSmiles('CCO');

const sss = new SSSearcherWithIndex();
const index1 = sss.createIndex(mol1);
const index2 = sss.createIndex(mol2);

const similarity = sss.getSimilarityTanimoto(index1, index2);
console.log(similarity)

This gives the following error: TypeError: sss.getSimilarityTanimoto is not a function. However, the following does the trick:

const similarity = sss.sc.e.getSimilarityTanimoto(index1, index2);

I guess that this is not the intended way... Thanks for the awesome package otherwise!

targos commented 2 months ago

This is a static method so should be called using the constructor: SSSearcherWithIndex.getSimilarityTanimoto(index1, index2)

https://github.com/cheminfo/openchemlib-js/blob/70edd49cc5b7d45ac0e7060ad81f3281fdc4cef4/types.d.ts#L3134