Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(),