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 1.1.0 to 1.2.0

src/diastereotopic/__tests/getExtendedDiastereotopicAtomIDs.test.js

7

CHANGELOG.md
# Changelog
## [1.2.0](https://www.github.com/cheminfo/openchemlib-utils/compare/v1.1.0...v1.2.0) (2021-05-11)
### Features
* add toVisualizerMolfile ([3d8ee95](https://www.github.com/cheminfo/openchemlib-utils/commit/3d8ee950fa281c64b01d14c4adbd21fed7726e39))
## [1.1.0](https://www.github.com/cheminfo/openchemlib-utils/compare/v1.0.0...v1.1.0) (2021-05-10)

@@ -4,0 +11,0 @@

@@ -1477,2 +1477,86 @@ 'use strict';

/**
* Get diastereotopicAtomIDs of the molecule as well as information about connected hydrogens
* @param {OCL.Molecule}} molecule
* @returns
*/
function getExtendedDiastereotopicAtomIDs(molecule) {
const OCL = molecule.getOCL();
molecule = molecule.getCompactCopy();
molecule.addImplicitHydrogens();
// TODO Temporary code ???
molecule.ensureHelperArrays(OCL.Molecule.cHelperNeighbours);
const diaIDs = molecule.getDiastereotopicAtomIDs();
const newDiaIDs = [];
for (let i = 0; i < diaIDs.length; i++) {
const diaID = diaIDs[i];
const newDiaID = {
oclID: diaID,
hydrogenOCLIDs: [],
nbHydrogens: 0,
};
for (let j = 0; j < molecule.getAllConnAtoms(i); j++) {
const atom = molecule.getConnAtom(i, j);
if (molecule.getAtomicNo(atom) === 1) {
newDiaID.nbHydrogens++;
if (newDiaID.hydrogenOCLIDs.indexOf(diaIDs[atom]) === -1) {
newDiaID.hydrogenOCLIDs.push(diaIDs[atom]);
}
}
}
newDiaIDs.push(newDiaID);
}
return newDiaIDs;
}
function toVisualizerMolfile(molecule, options = {}) {
const { diastereotopic, heavyAtomHydrogen } = options;
let highlight = [];
let atoms = {};
if (diastereotopic) {
let hydrogenInfo = {};
let extendedIDs = getExtendedDiastereotopicAtomIDs(molecule);
for (let line of extendedIDs) {
hydrogenInfo[line.oclID] = line;
}
let diaIDs = getGroupedDiastereotopicAtomIDs(molecule);
for (const diaID of diaIDs) {
atoms[diaID.oclID] = diaID.atoms;
highlight.push(diaID.oclID);
if (heavyAtomHydrogen) {
if (
hydrogenInfo[diaID.oclID] &&
hydrogenInfo[diaID.oclID].nbHydrogens > 0
) {
for (let id of hydrogenInfo[diaID.oclID].hydrogenOCLIDs) {
highlight.push(id);
atoms[id] = diaID.atoms;
}
}
}
}
} else {
let size = this.getAllAtoms();
highlight = new Array(size).fill(0).map((a, index) => index);
atoms = highlight.map((a) => [a]);
}
let molfile = {
type: 'mol2d',
value: molecule.toMolfile(),
_highlight: highlight,
_atoms: atoms,
};
return molfile;
}
exports.FULL_HOSE_CODE = FULL_HOSE_CODE;

@@ -1498,1 +1582,2 @@ exports.HOSE_CODE_CUT_C_SP3_SP3 = HOSE_CODE_CUT_C_SP3_SP3;

exports.toDiastereotopicSVG = toDiastereotopicSVG;
exports.toVisualizerMolfile = toVisualizerMolfile;

2

package.json
{
"name": "openchemlib-utils",
"version": "1.1.0",
"version": "1.2.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

export * from './db/MoleculesDB';
export * from './misc/toVisualizerMolfile';
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