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 0.7.1 to 1.0.0

17

CHANGELOG.md
# Changelog
## [1.0.0](https://www.github.com/cheminfo/openchemlib-utils/compare/v0.7.1...v1.0.0) (2021-03-24)
### ⚠ BREAKING CHANGES
*
### Features
* combineSmiles requires to pass OCL ([aa9218a](https://www.github.com/cheminfo/openchemlib-utils/commit/aa9218ad530d5a1a98d90d7215c97e7ed4e35edb))
* getHoseCodesFromDiastereotopicID requires an OCL.Molecule ([00b8845](https://www.github.com/cheminfo/openchemlib-utils/commit/00b8845682c86dfb45cafc3c195840f285c783c4))
### Bug Fixes
* add openchemlib to peer dependencies ([c856127](https://www.github.com/cheminfo/openchemlib-utils/commit/c8561273dc0a224a03949853ace5067c03ecc0e9))
### [0.7.1](https://www.github.com/cheminfo/openchemlib-utils/compare/v0.7.0...v0.7.1) (2021-03-24)

@@ -4,0 +21,0 @@

54

lib/index.js

@@ -252,26 +252,3 @@ 'use strict';

let OCL;
function getOCL() {
if (!OCL) {
throw new Error('OCL has to be initialized using initOCL(OCL)');
}
return OCL;
}
/**
*
* @param {OCL} newOCL
* @param {object} [options={}]
* @param {boolean} [options.keepExisting=false] Will keep current OCL if we initialize more than once
*/
function initOCL(newOCL, options = {}) {
const { keepExisting = false } = options;
if (OCL && keepExisting) return;
if (OCL && OCL !== newOCL) {
throw new Error('OCL-utils was already initialized with a different OCL');
}
OCL = newOCL;
}
/**
* Check if a specific atom is a sp3 carbon

@@ -383,12 +360,7 @@ * @param {OCL.Molecule} molecule

* Returns the hose code for a specific marked atom
* @param {string} diastereotopicID
* @param {OCL.Molecule} diastereotopicID
* @param {object} options
*/
function getHoseCodesFromDiastereotopicID(
diastereotopicID,
options = {},
) {
const OCL = getOCL();
const molecule = OCL.Molecule.fromIDCode(diastereotopicID);
function getHoseCodesFromDiastereotopicID(molecule, options = {}) {
molecule.addImplicitHydrogens();

@@ -425,5 +397,9 @@ molecule.addMissingChirality();

}));
const OCL = molecule.getOCL();
// TODO: seems like a very slow approach
diaIDs.forEach(function (diaID) {
const hoses = getHoseCodesFromDiastereotopicID(diaID.oclID, options);
const hoses = getHoseCodesFromDiastereotopicID(
OCL.Molecule.fromIDCode(diaID.oclID),
options,
);
diaID.hoses = [];

@@ -452,3 +428,3 @@ let sphere = 0;

*/
async function combineSmiles(coreSmiles, fragments, options = {}) {
async function combineSmiles(coreSmiles, fragments, OCL, options = {}) {
const { complexity = false } = options;

@@ -460,3 +436,3 @@ const core = getCore(coreSmiles);

}
return generate(core, rGroups, options);
return generate(core, rGroups, OCL, options);
}

@@ -472,3 +448,3 @@

async function generate(core, rGroups, options = {}) {
async function generate(core, rGroups, OCL, options = {}) {
const { onStep } = options;

@@ -492,3 +468,3 @@ const molecules = {};

}
appendMolecule(molecules, core, rGroups, currents);
appendMolecule(molecules, core, rGroups, currents, OCL);
currents[position]++;

@@ -507,3 +483,3 @@ for (let i = 0; i < position; i++) {

}
appendMolecule(molecules, core, rGroups, currents);
appendMolecule(molecules, core, rGroups, currents, OCL);
break;

@@ -517,3 +493,3 @@ }

function appendMolecule(molecules, core, rGroups, currents) {
function appendMolecule(molecules, core, rGroups, currents, OCL) {
let newSmiles = core.smiles;

@@ -524,4 +500,2 @@ for (let i = 0; i < currents.length; i++) {

const OCL = getOCL();
const currentMol = OCL.Molecule.fromSmiles(newSmiles);

@@ -1111,6 +1085,4 @@ const idCode = currentMol.getIDCode();

exports.getMF = getMF;
exports.getOCL = getOCL;
exports.getPathsInfo = getPathsInfo;
exports.getShortestPaths = getShortestPaths;
exports.initOCL = initOCL;
exports.isCsp3 = isCsp3;

@@ -1117,0 +1089,0 @@ exports.makeRacemic = makeRacemic;

{
"name": "openchemlib-utils",
"version": "0.7.1",
"version": "1.0.0",
"description": "",

@@ -48,3 +48,3 @@ "main": "lib/index.js",

"jest": "^26.6.3",
"openchemlib": "^7.4.0",
"openchemlib": "7.4.0",
"prettier": "^2.2.1",

@@ -57,3 +57,6 @@ "rollup": "^2.42.3"

"ml-matrix": "^6.7.0"
},
"peerDependencies": {
"openchemlib": ">=7.4.0"
}
}

@@ -16,3 +16,3 @@ # openchemlib-utils

```js
import OCL from 'openchemlib';
import OCL from 'openchemlib'; // version should be greater than 7.4

@@ -36,3 +36,2 @@ import { getPathsInfo, initOCL } from 'openchemlib-utils';

## [API Documentation](https://cheminfo.github.io/openchemlib-utils/)

@@ -39,0 +38,0 @@

import OCL from 'openchemlib';
import { initOCL } from '../../OCL';
import { addDiastereotopicMissingChirality } from '../addDiastereotopicMissingChirality';
initOCL(OCL);
describe('addDiastereotopicMissingChirality', () => {

@@ -8,0 +6,0 @@ it('CC(Cl)CC', () => {

import OCL from 'openchemlib';
import { initOCL } from '../../OCL';
import { getDiastereotopicAtomIDs } from '../getDiastereotopicAtomIDs';
initOCL(OCL);
describe('getDiastereotopicAtomIDs', () => {

@@ -8,0 +6,0 @@ it('CC(Cl)CC', () => {

import OCL from 'openchemlib';
import { initOCL } from '../../OCL';
import { getDiastereotopicAtomIDsAndH } from '../getDiastereotopicAtomIDsAndH';
initOCL(OCL);
describe('getDiastereotopicAtomIDsAndH', () => {

@@ -8,0 +6,0 @@ it('propane', () => {

import OCL from 'openchemlib';
import { initOCL } from '../../OCL';
import { getGroupedDiastereotopicAtomIDs } from '../getGroupedDiastereotopicAtomIDs';
initOCL(OCL);
describe('getGroupedDiastereotopicIDs test propane', () => {

@@ -9,0 +6,0 @@ it('should yield the right table for all atoms', () => {

import OCL from 'openchemlib';
import { initOCL } from '../../OCL';
import { toDiastereotopicSVG } from '../toDiastereotopicSVG';
initOCL(OCL);
describe('toDiastereotopicSVG', () => {

@@ -8,0 +6,0 @@ it('CCC', () => {

@@ -15,5 +15,9 @@ import { getDiastereotopicAtomIDs } from '../diastereotopic/getDiastereotopicAtomIDs';

}));
const OCL = molecule.getOCL();
// TODO: seems like a very slow approach
diaIDs.forEach(function (diaID) {
const hoses = getHoseCodesFromDiastereotopicID(diaID.oclID, options);
const hoses = getHoseCodesFromDiastereotopicID(
OCL.Molecule.fromIDCode(diaID.oclID),
options,
);
diaID.hoses = [];

@@ -20,0 +24,0 @@ let sphere = 0;

@@ -1,16 +0,9 @@

import { getOCL } from '../OCL';
import { getHoseCodesForAtom } from './getHoseCodesForAtom';
/**
* Returns the hose code for a specific marked atom
* @param {string} diastereotopicID
* @param {OCL.Molecule} diastereotopicID
* @param {object} options
*/
export function getHoseCodesFromDiastereotopicID(
diastereotopicID,
options = {},
) {
const OCL = getOCL();
const molecule = OCL.Molecule.fromIDCode(diastereotopicID);
export function getHoseCodesFromDiastereotopicID(molecule, options = {}) {
molecule.addImplicitHydrogens();

@@ -17,0 +10,0 @@ molecule.addMissingChirality();

@@ -21,3 +21,1 @@ export * from './diastereotopic/addDiastereotopicMissingChirality';

export * from './path/getShortestPaths';
export * from './OCL';

@@ -1,3 +0,1 @@

import { getOCL } from '../OCL';
const MAX_R = 10;

@@ -14,3 +12,3 @@

*/
export async function combineSmiles(coreSmiles, fragments, options = {}) {
export async function combineSmiles(coreSmiles, fragments, OCL, options = {}) {
const { complexity = false } = options;

@@ -22,3 +20,3 @@ const core = getCore(coreSmiles);

}
return generate(core, rGroups, options);
return generate(core, rGroups, OCL, options);
}

@@ -34,3 +32,3 @@

async function generate(core, rGroups, options = {}) {
async function generate(core, rGroups, OCL, options = {}) {
const { onStep } = options;

@@ -54,3 +52,3 @@ const molecules = {};

}
appendMolecule(molecules, core, rGroups, currents);
appendMolecule(molecules, core, rGroups, currents, OCL);
currents[position]++;

@@ -69,3 +67,3 @@ for (let i = 0; i < position; i++) {

}
appendMolecule(molecules, core, rGroups, currents);
appendMolecule(molecules, core, rGroups, currents, OCL);
break;

@@ -79,3 +77,3 @@ }

function appendMolecule(molecules, core, rGroups, currents) {
function appendMolecule(molecules, core, rGroups, currents, OCL) {
let newSmiles = core.smiles;

@@ -86,4 +84,2 @@ for (let i = 0; i < currents.length; i++) {

const OCL = getOCL();
const currentMol = OCL.Molecule.fromSmiles(newSmiles);

@@ -90,0 +86,0 @@ const idCode = currentMol.getIDCode();

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