Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substructure/similarity search functions? #18

Open
flatkinson opened this issue Jul 4, 2018 · 6 comments
Open

Substructure/similarity search functions? #18

flatkinson opened this issue Jul 4, 2018 · 6 comments

Comments

@flatkinson
Copy link

I might be missing something, but the substructure and similarity functionality does not seem to be exposed in the current version of RDKitjs (it was accessible in the old version). Do you have plans to add this in the near future?

@virago-bot
Copy link

virago-bot commented Jul 4, 2018 via email

@flatkinson
Copy link
Author

Guillaume,

Please allow me to rephrase my original question, as I'm not sure it was clear what I was asking.
The problem is that my C++ is limited and I haven't been able to work out the answer to my question by browsing the source code.

So: when using the RDKit from Python, I can instantiate a molecule object which has, for example, a HasSubstructMatch method. This is handled by a layer of Python code that wraps a native RDKit C++ object and associated methods. Where this wrapping is not done, the functionality provided by C++ is not available from Python.

Similarly, the Emscripten toolchain compiles all of the RDKit C++ source to WASM, so all objects/methods in C++ RDKit are potentially available from JavaScript. However, for a given C++/WASN method to be accessible from JavaScript, there needs to be a wrapping step, similar to what is done in Python. So far, your team has, done this wrapping manually for some RDKit C++ objects/methods, but not all, and that, where the wrapping has not yet been done, the functionality is not accessible. Thus, at the moment, there is no RDKitjs equivalent of the HasSubstructMatch/GetSubstructMatches methods, and RDKit-based substructure-searching is not yet available from JavaScript. Is my understanding correct?

The other possibility I've considered is that the wrapping is more for convenience, and that all the RDKit functionality is available from JavaScript, if you know how to do it.
If this is the case, I just haven't been able to work it out.

I hope this version of the question makes more sense.

Many thanks,

    Francis

@targos
Copy link
Contributor

targos commented Jul 18, 2018

Unfortunately, we were not able to come up with a solution that doesn't require us to write the bindings for each function manually.

@flatkinson
Copy link
Author

OK, I see. May I ask if this remains a long-term goal, or if you see any other potential ways forward?

@kathrynloving
Copy link

Chiming in as another person interested in the substructure/similarity search functions. (And also ReplaceCore, ReplaceSidechains, GetMolFrags, for SAR analysis.)

You mentioned above that you must write the bindings for each function manually... I think there's enough interest in this project that people would be willing contribute these to the project for the functions they need. (I would, anyway.)

Could you provide a detailed "how to" for one function that we could use as a template for adding more? Thanks!

@thegodone
Copy link
Contributor

thegodone commented Nov 10, 2018

Hello,


First step env configuration: You need a linux/Mac env (use Docker if required):

Follow "README" instruction for installation. This will give you also an environnement to develop.


Old sources are still in the repo

There is a "old" session where we store old wrapping style code. main function is there
https://github.com/cheminfo/RDKitjs/blob/master/old/src/rdmol.cpp & https://github.com/cheminfo/RDKitjs/blob/master/old/src/rdmol.h
If you want to contribute that's very nice.


Major issue works with two molecules

One major issue we had is to compare two molecules (two objects), this is easy in python RDKit or C++ but not so simple in javascript.


Old code style

/**

  • @brief [MMFFoptimizeMolecule]
  • @details [generate the 3D optimized molecule coordonate based on MMFF field force model]
  • @return [return the status of the optimization and the energie of the optimal structure]
    */
    vector Molecule::MMFFoptimizeMolecule()
    {
    vector res(2);
    pair<int, double> p = RDKit::MMFF::MMFFOptimizeMolecule(*rdmol);
    res[0] = static_cast(p.first);
    res[1] = p.second;
    return res;
    }

/**

  • @brief [MMFFoptimizeMolecule]
  • @details [generate the 3D optimized molecule coordonate based on MMFF field force model]
  • @param maxIters [number of max iteration option]
  • @param mmffVariant [MMFF variant field force option]
  • @return [return the status of the optimization and the energie of the optimal structure]
    */
    vector Molecule::MMFFoptimizeMolecule(int maxIters, string mmffVariant)
    {
    pair<int, double> p = RDKit::MMFF::MMFFOptimizeMolecule(*rdmol,maxIters,mmffVariant);
    vector res(2);
    res[0] = static_cast(p.first);
    res[1] = p.second;
    return res;
    }

New style

vector MMFFOptimizeMolecule(RWMol *mol,
int maxIters,
string mmffVariant,
double nonBondedThresh,
int confId,
bool ignoreInterfragInteractions)
{
vector res(2);
std::pair<int, double> p = RDKit::MMFF::MMFFOptimizeMolecule(*mol,
maxIters,
mmffVariant,
nonBondedThresh,
confId,
ignoreInterfragInteractions);
res[0] = static_cast(p.first);
res[1] = p.second;
return res;
}

#define BIND_Chem_rdForceFieldHelpers()
{
function("MMFFOptimizeMolecule", &MMFFOptimizeMolecule, allow_raw_pointers());
}

Lot of code (old) need to be converted into new style.


RDKit function need to exist at c++ level:

We can also add new RDKit c++ functions.

Caution, If you need a function only available at the python level in RDKit, you will need to translate it to c++ than write the mapping function. Or better is to write a js function that emulates python fonction.
there are lot of example of function I wrote following the same principal but using all style code.


Function Naming Matters:

In the new style we decided to use same function names as RDKit. this is to simplify the user code transfer from python to js.

Guillaume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants