Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openchemlib-utils

Package Overview
Dependencies
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openchemlib-utils - npm Package Compare versions

Comparing version 2.7.1 to 2.8.0

src/db/utils/appendEntries.js

27

package.json
{
"name": "openchemlib-utils",
"version": "2.7.1",
"version": "2.8.0",
"description": "Various utilities that extends openchemlib-js like HOSE codes or diastereotopic IDs",

@@ -33,13 +33,13 @@ "main": "lib/index.js",

"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.20.11",
"@types/jest": "^29.4.0",
"cheminfo-build": "^1.1.11",
"eslint": "^8.32.0",
"eslint-config-cheminfo": "^8.1.3",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@types/jest": "^29.5.3",
"cheminfo-build": "^1.2.0",
"eslint": "^8.45.0",
"eslint-config-cheminfo": "^9.0.2",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.4.0",
"jest": "^29.6.1",
"jest-matcher-deep-close-to": "^3.0.2",
"openchemlib": "^8.2.0",
"prettier": "^2.8.3",
"rollup": "^3.10.1"
"openchemlib": "^8.3.0",
"prettier": "^3.0.0",
"rollup": "^3.26.3"
},

@@ -49,10 +49,11 @@ "dependencies": {

"ensure-string": "^1.2.0",
"ml-floyd-warshall": "^2.0.1",
"get-value": "^3.0.1",
"ml-floyd-warshall": "^3.0.1",
"ml-matrix": "^6.10.4",
"papaparse": "^5.3.2",
"papaparse": "^5.4.1",
"sdf-parser": "^6.0.1"
},
"peerDependencies": {
"openchemlib": ">=8.0.0"
"openchemlib": ">=8.3.0"
}
}
import appendCSV from './utils/appendCSV';
import appendColor from './utils/appendColor';
import appendEntries from './utils/appendEntries.js';
import appendSDF from './utils/appendSDF';

@@ -34,2 +35,22 @@ import appendSmilesList from './utils/appendSmilesList';

/**
* Append an array of entries to the current database. An entry is an object that by default should contain a 'ocl' property containing idCode and optionally index and coordinates
* @param {*} moleculesDB
* @param {object[]} entries
* @param {object} [options={}]
* @param {string} [options.idCodePath='ocl.idCode']
* @param {string} [options.indexPath='ocl.index']
* @param {string} [options.coordinatesPath='ocl.coordinates']
* @param {string} [options.mwPath='mw']
* @param {string} [options.smilesPath]
* @param {string} [options.molfilePath]
* @param {function} [options.onStep] call back to execute after each molecule
*/
appendEntries(entries, options) {
return appendEntries(this, entries, {
computeProperties: this.computeProperties,
...options,
});
}
/**
* append to the current database a CSV file

@@ -43,3 +64,2 @@ * @param {string|ArrayBuffer} csv - text file containing the comma separated value file

*/
appendCSV(csv, options) {

@@ -59,3 +79,2 @@ return appendCSV(this, csv, {

*/
appendSDF(sdf, options) {

@@ -75,3 +94,2 @@ return appendSDF(this, sdf, {

*/
appendSmilesList(text, options) {

@@ -109,3 +127,3 @@ return appendSmilesList(this, text, {

* @param {object} [options={}]
* @param {string} [options.format='idCode'] - query is in the format 'smiles', 'oclid' or 'molfile'
* @param {'smiles'|'idCode'|'smarts'|'molfile'} [options.format='idCode'] - query format
* @param {string} [options.mode='substructure'] - search by 'substructure', 'exact' or 'similarity'

@@ -126,3 +144,3 @@ * @param {boolean} [options.flattenResult=true] - The database group the data for the same product. This allows to flatten the result

* @param {object} [options={}]
* @param {string} [options.format='idCode'] - query is in the format 'smiles', 'oclid' or 'molfile'
* @param {'smiles'|'idCode'|'smarts'|'molfile'} [options.format='idCode'] - query format
* @param {string} [options.mode='substructure'] - search by 'substructure', 'exact' or 'similarity'

@@ -129,0 +147,0 @@ * @param {boolean} [options.flattenResult=true] - The database group the data for the same product. This allows to flatten the result

@@ -15,3 +15,3 @@ import { ensureString } from 'ensure-string';

csv = ensureString(csv);
const moleculeCreators = getMoleculeCreators(moleculesDB.OCL.Molecule);
const moleculeCreators = getMoleculeCreators(moleculesDB.OCL);

@@ -18,0 +18,0 @@ if (typeof csv !== 'string') {

@@ -1,10 +0,14 @@

export default function getMoleculeCreators(Molecule) {
export default function getMoleculeCreators(OCL) {
const fields = new Map();
fields.set('oclid', Molecule.fromIDCode);
fields.set('idcode', Molecule.fromIDCode);
fields.set('smiles', Molecule.fromSmiles);
fields.set('molfile', Molecule.fromMolfile);
fields.set('oclid', OCL.Molecule.fromIDCode);
fields.set('idcode', OCL.Molecule.fromIDCode);
fields.set('smiles', OCL.Molecule.fromSmiles);
fields.set('molfile', OCL.Molecule.fromMolfile);
fields.set('smarts', (smarts) => {
const smilesParser = new OCL.SmilesParser({ smartsMode: 'smarts' });
return smilesParser.parseMolecule(smarts);
});
return fields;
}

@@ -20,5 +20,3 @@ /**

let moleculeIDCode = moleculeInfo.idCode
? moleculeInfo.idCode
: molecule.getIDCode();
let moleculeIDCode = getMoleculeIDCode(molecule, moleculeInfo);
let entry = moleculesDB.db[moleculeIDCode];

@@ -64,1 +62,6 @@ if (!entry) {

}
function getMoleculeIDCode(molecule, moleculeInfo) {
if (moleculeInfo.idCode) return moleculeInfo.idCode;
return molecule.getIDCode();
}

@@ -14,3 +14,3 @@ import { noWait } from '../../util/noWait.js';

if (typeof query === 'string') {
const moleculeCreators = getMoleculeCreators(moleculesDB.OCL.Molecule);
const moleculeCreators = getMoleculeCreators(moleculesDB.OCL);
query = moleculeCreators.get(format.toLowerCase())(query);

@@ -17,0 +17,0 @@ } else if (!(query instanceof moleculesDB.OCL.Molecule)) {

@@ -22,2 +22,3 @@ export * from './diastereotopic/addDiastereotopicMissingChirality';

export * from './util/getMF';
export * from './util/getCharge';
export * from './util/getAtoms';

@@ -24,0 +25,0 @@ export * from './util/nbOH';

@@ -1,2 +0,1 @@

/**

@@ -10,11 +9,11 @@ * Calculate the molecular formula in 'chemcalc' notation taking into account fragments, isotopes and charges

let entries = molecule.getFragments();
const atoms = {}
const atoms = {};
const result = { atoms, parts: [] };
entries.forEach((entry) => {
const part = {}
result.parts.push(part)
const part = {};
result.parts.push(part);
appendAtomPart(entry, atoms, part);
});
return result
return result;
}

@@ -28,7 +27,7 @@

}
atoms[label] += 1
atoms[label] += 1;
if (!part[label]) {
part[label] = 0;
}
part[label] += 1
part[label] += 1;
let implicitHydrogens = molecule.getImplicitHydrogens(i);

@@ -39,10 +38,9 @@ if (implicitHydrogens) {

}
atoms.H += implicitHydrogens
atoms.H += implicitHydrogens;
if (!part.H) {
part.H = 0;
}
part.H += implicitHydrogens
part.H += implicitHydrogens;
}
}
}

@@ -5,3 +5,3 @@ import { atomSorter } from 'atom-sorter';

* Calculate the molecular formula in 'chemcalc' notation taking into account fragments, isotopes and charges
* @param {OCL.Molecule} [molecule] an instance of OCL.Molecule
* @param {import('openchemlib').Molecule} molecule an instance of OCL.Molecule
* @returns {object}

@@ -8,0 +8,0 @@ */

/**
*
* @param {import('openchemlib').Molecule} [molecule] An instance of a molecule
* @param {import('openchemlib').Molecule} molecule An instance of a molecule
* @param {object} [options={}]

@@ -5,0 +5,0 @@ * @param {object} [options.OCL] openchemlib library

@@ -14,3 +14,3 @@ /**

if (atomicNumbers.includes(molecule.getAtomicNo(i))) {
counter += molecule.getAllHydrogens(i)
counter += molecule.getAllHydrogens(i);
}

@@ -17,0 +17,0 @@ }

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc