partridgejiang / Kekule.js

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

Hello, does Kekule's Composer support CDX format? #289

Open hanyue1998 opened 1 year ago

hanyue1998 commented 1 year ago

Hello, does Kekule's Composer support CDX format?Is it interchangeable with chemDraw?

partridgejiang commented 1 year ago

CDX format files (saved from ChemDraw) can be loaded when OpenBabel module is enabled. However, the reader only handles molecules inside it, and all other objects (texts, glyphs, etc.) will be discarded. Anyway, it is not recommended to use such a proprietary format on web.

hanyue1998 commented 1 year ago

Ok, I see. Thank you for your answer. Another question I want to know is whether Kekule's Composer supports molecular structure query? For example, if you draw a benzene ring, you can query the related molecular structure formula containing the benzene ring. Is there any method to provide such a method?

partridgejiang commented 1 year ago

Sub structure query can be applied by the Molecule.search method, e.g.:

let queryStructure = composer.exportObj(Kekule.StructureFragment);  // get the structure drawn in composer
let founds = [];
// suppose mols is an array of candidate molecules
mols.forEach(mol => {
  let searchResult = mol.search(queryStructure);
  if (searchResult)
  {
    founds.push(mol);
  }
});                 

By the way, the sub structure search online demo (http://partridgejiang.github.io/Kekule.js/demos/demoLauncher.html?id=structSearch) provides more details of that process.