How to use openchemlib - 1 common examples

To help you get started, we’ve selected a few openchemlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cheminfo / wikipedia / dump / wiki-parse.js View on Github external
var uniq = {}; // Keep a hashmap of pageID + actelionID to prevent duplicates

for (var i = 0; i < length; i++) {
    var id = pageList[i].id;
    var path = util.getPagePath(id);
    var file = path.full;
    var page = JSON.parse(fs.readFileSync(file));
    var result;

    var allError = true;

    var smiles = getSmiles(page.content);
    if (smiles.length) {
        for (var j = 0; j < smiles.length; j++) {
            try {
                var molecule = ACT.Molecule.fromSmiles(smiles[j]);
                allError = false; // At least one SMILES is good for this file
                var idcode = molecule.getIDCode();
                var uniqid = id + '_' + idcode;
                if (uniq[uniqid]) {
                    dup.push(id);
                    continue; // If exact same molecule is already present for this page, skip
                }
                var mf = molecule.getMolecularFormula().formula;
                result = {
                    id: page.id,
                    code: page.title,
                    smiles: smiles[j],
                    mf: {type: 'mf', value: mf},
                    mw: 0,
                    em: 0,
                    act_idx: molecule.getIndex(),

openchemlib

Manipulate molecules

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis

Popular openchemlib functions