Request for SMARTS object in Open Babel bindings
Opened this issue · 2 comments
Hi @partridgejiang, thanks to your help I've developed an application that uses Indigo for SMARTS searching. It's available at https://baoilleach.github.io/smartersmarts-js/. I plan to write a blog post explaining about this and give you credit there (and on the app).
However, before that, I was thinking it would be cool to be able to choose different toolkits, and yet have the same application. This would be a good example of use for people, and also illustrate that several different toolkits are now available as JS libraries (also OpenChemLib for example if I can figure it out). Because I use a web worker for the cheminformatics, it allows simple separation of application logic and cheminformatics logic.
Which brings me to Open Babel, a toolkit close to my heart. The only thing I'm missing is OBSmartsPattern, where I need to match a pattern (single-match) and identify the matching atoms. Do you think you could add this? If not, let me know, and I can see if I can figure it out.
Hi @baoilleach, please check the new commit to OpenBabel3/OpenBabel-js/bin/ of this repo. Now the OBSmartsPattern
class with most of its public methods are now exported in wasm. I am not quite familiar with OBSmartsPattern
but I guess the following code should work for now:
let smartsPattern = new OBModule.OBSmartsPattern(); // suppose OBModule is the module object of OpenBabel
smartsPattern.Init('c1ccccc1');
let matched = smartsPattern.Match(obMolecule, true);
if (matched)
{
let mapList = smartsPattern.GetMapList();
console.log(mapList.size());
console.log(mapList.get(0).get(0));
}
Wow, again. That's fantastic. It looks exactly what I was looking for. I'll get on it, and keep you updated.