Comments (6)
from rdkitjs-legacy.
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
from rdkitjs-legacy.
Unfortunately, we were not able to come up with a solution that doesn't require us to write the bindings for each function manually.
from rdkitjs-legacy.
OK, I see. May I ask if this remains a long-term goal, or if you see any other potential ways forward?
from rdkitjs-legacy.
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!
from rdkitjs-legacy.
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
from rdkitjs-legacy.
Related Issues (16)
- Bug in Emscripten 1.32.4 HOT 3
- cannot create molecule from pickle HOT 2
- general comment on rdkit HOT 1
- 2d rendering using last rdkit version including highligths
- Compilation test pickle failed with RDKit 2018.09.1 HOT 1
- How to avoid all the global variables
- TypeError: bindings.SmilesToMol is not a function HOT 3
- Cannot import the module with require('rdkit') HOT 5
- Smiles can be converted to mol files HOT 1
- Add a molecule from Molfile HOT 8
- Empty result from MolToBinary HOT 1
- Molecule is not changed if we call Mucko decomposition HOT 2
- get,set & hasProperties HOT 1
- Descriptors._descList HOT 7
- Proposed API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rdkitjs-legacy.