openchemlib-utils
Advanced tools
Comparing version 1.6.0 to 1.7.0
# Changelog | ||
## [1.7.0](https://www.github.com/cheminfo/openchemlib-utils/compare/v1.6.0...v1.7.0) (2021-12-14) | ||
### Features | ||
* add getHoseCodesForPath ([3584377](https://www.github.com/cheminfo/openchemlib-utils/commit/358437790716b6dcf7bb2e197d8702956061e9a0)) | ||
### Bug Fixes | ||
* getMF return type ([7ac70ea](https://www.github.com/cheminfo/openchemlib-utils/commit/7ac70ea2a0a4be3296a6f682e87fd082892b1d56)) | ||
* rename SimpleBonds to SingleBonds ([d2ff8ed](https://www.github.com/cheminfo/openchemlib-utils/commit/d2ff8ed4001ded1678e04570219ca408c530962f)) | ||
## [1.6.0](https://www.github.com/cheminfo/openchemlib-utils/compare/v1.5.1...v1.6.0) (2021-10-14) | ||
@@ -4,0 +17,0 @@ |
215
lib/index.js
@@ -418,2 +418,106 @@ 'use strict'; | ||
let fragment$1; | ||
/** | ||
* Returns the hose code for a specific atom number | ||
* @param {OCL.Molecule} molecule | ||
*/ | ||
function getHoseCodesForPath(molecule, from, to, maxLength) { | ||
const OCL = molecule.getOCL(); | ||
const originalFrom = from; | ||
const originalTo = to; | ||
molecule = molecule.getCompactCopy(); | ||
let originalAtoms = []; // path before renumbering | ||
molecule.getPath(originalAtoms, from, to, maxLength + 1); | ||
let torsion; | ||
if (originalAtoms.length === 4) { | ||
torsion = molecule.calculateTorsion(originalAtoms); | ||
} | ||
const tag1 = tagAtom(molecule, from); | ||
const tag2 = tagAtom(molecule, to); | ||
molecule.addImplicitHydrogens(); | ||
molecule.addMissingChirality(); | ||
molecule.ensureHelperArrays(OCL.Molecule.cHelperNeighbours); | ||
from = -1; | ||
to = -1; | ||
for (let i = 0; i < molecule.getAllAtoms(); i++) { | ||
if (tag1 === tag2) { | ||
if (molecule.getAtomCustomLabel(i) === tag1) { | ||
if (from === -1) { | ||
from = i; | ||
} else { | ||
to = i; | ||
} | ||
} | ||
} else { | ||
if (tag1 === molecule.getAtomCustomLabel(i)) { | ||
from = i; | ||
} | ||
if (tag2 === molecule.getAtomCustomLabel(i)) { | ||
to = i; | ||
} | ||
} | ||
} | ||
if (!fragment$1) fragment$1 = new OCL.Molecule(0, 0); | ||
let atoms = []; | ||
molecule.getPath(atoms, from, to, maxLength + 1); | ||
let min = 0; | ||
let max = 0; | ||
let atomMask = new Array(molecule.getAllAtoms()).fill(false); | ||
let atomList = new Array(molecule.getAllAtoms()).fill(-1); | ||
let hoses = []; | ||
for (let sphere = 0; sphere <= 2; sphere++) { | ||
if (max === 0) { | ||
for (let atom of atoms) { | ||
atomMask[atom] = true; | ||
atomList[max++] = atom; | ||
} | ||
} else { | ||
let newMax = max; | ||
for (let i = min; i < max; i++) { | ||
let atom = atomList[i]; | ||
for (let j = 0; j < molecule.getAllConnAtoms(atom); j++) { | ||
let connAtom = molecule.getConnAtom(atom, j); | ||
if (!atomMask[connAtom]) { | ||
atomMask[connAtom] = true; | ||
atomList[newMax++] = connAtom; | ||
} | ||
} | ||
} | ||
min = max; | ||
max = newMax; | ||
} | ||
let atomMap = []; | ||
molecule.copyMoleculeByAtoms(fragment$1, atomMask, true, atomMap); | ||
makeRacemic(fragment$1); | ||
let oclID = fragment$1.getCanonizedIDCode( | ||
OCL.Molecule.CANONIZER_ENCODE_ATOM_CUSTOM_LABELS, | ||
); | ||
hoses.push({ | ||
sphere, | ||
oclID, | ||
}); | ||
} | ||
return { | ||
atoms: originalAtoms, | ||
from: originalFrom, | ||
to: originalTo, | ||
torsion, | ||
hoses, | ||
length: originalAtoms.length - 1, | ||
}; | ||
} | ||
const MAX_R = 10; | ||
@@ -770,3 +874,3 @@ | ||
* {OCL.Molecule} [molecule] an instance of OCL.Molecule | ||
* @returns {String} | ||
* @returns {object} | ||
*/ | ||
@@ -853,106 +957,2 @@ | ||
let fragment$1; | ||
/** | ||
* Returns the hose code for a specific atom number | ||
* @param {OCL.Molecule} molecule | ||
*/ | ||
function getHoseCodesForPath(molecule, from, to, maxLength) { | ||
const OCL = molecule.getOCL(); | ||
const originalFrom = from; | ||
const originalTo = to; | ||
molecule = molecule.getCompactCopy(); | ||
let originalAtoms = []; // path before renumbering | ||
molecule.getPath(originalAtoms, from, to, maxLength + 1); | ||
let torsion; | ||
if (originalAtoms.length === 4) { | ||
torsion = molecule.calculateTorsion(originalAtoms); | ||
} | ||
const tag1 = tagAtom(molecule, from); | ||
const tag2 = tagAtom(molecule, to); | ||
molecule.addImplicitHydrogens(); | ||
molecule.addMissingChirality(); | ||
molecule.ensureHelperArrays(OCL.Molecule.cHelperNeighbours); | ||
from = -1; | ||
to = -1; | ||
for (let i = 0; i < molecule.getAllAtoms(); i++) { | ||
if (tag1 === tag2) { | ||
if (molecule.getAtomCustomLabel(i) === tag1) { | ||
if (from === -1) { | ||
from = i; | ||
} else { | ||
to = i; | ||
} | ||
} | ||
} else { | ||
if (tag1 === molecule.getAtomCustomLabel(i)) { | ||
from = i; | ||
} | ||
if (tag2 === molecule.getAtomCustomLabel(i)) { | ||
to = i; | ||
} | ||
} | ||
} | ||
if (!fragment$1) fragment$1 = new OCL.Molecule(0, 0); | ||
let atoms = []; | ||
molecule.getPath(atoms, from, to, maxLength + 1); | ||
let min = 0; | ||
let max = 0; | ||
let atomMask = new Array(molecule.getAllAtoms()).fill(false); | ||
let atomList = new Array(molecule.getAllAtoms()).fill(-1); | ||
let hoses = []; | ||
for (let sphere = 0; sphere <= 2; sphere++) { | ||
if (max === 0) { | ||
for (let atom of atoms) { | ||
atomMask[atom] = true; | ||
atomList[max++] = atom; | ||
} | ||
} else { | ||
let newMax = max; | ||
for (let i = min; i < max; i++) { | ||
let atom = atomList[i]; | ||
for (let j = 0; j < molecule.getAllConnAtoms(atom); j++) { | ||
let connAtom = molecule.getConnAtom(atom, j); | ||
if (!atomMask[connAtom]) { | ||
atomMask[connAtom] = true; | ||
atomList[newMax++] = connAtom; | ||
} | ||
} | ||
} | ||
min = max; | ||
max = newMax; | ||
} | ||
let atomMap = []; | ||
molecule.copyMoleculeByAtoms(fragment$1, atomMask, true, atomMap); | ||
makeRacemic(fragment$1); | ||
let oclID = fragment$1.getCanonizedIDCode( | ||
OCL.Molecule.CANONIZER_ENCODE_ATOM_CUSTOM_LABELS, | ||
); | ||
hoses.push({ | ||
sphere, | ||
oclID, | ||
}); | ||
} | ||
return { | ||
atoms: originalAtoms, | ||
from: originalFrom, | ||
to: originalTo, | ||
torsion, | ||
hoses, | ||
length: originalAtoms.length - 1, | ||
}; | ||
} | ||
let fragment; | ||
@@ -1654,3 +1654,3 @@ | ||
function fragmentAcyclicSimpleBonds(molecule) { | ||
function fragmentAcyclicSingleBonds(molecule) { | ||
const OCL = molecule.getOCL(); | ||
@@ -1730,3 +1730,3 @@ let atoms = []; | ||
exports.combineSmiles = combineSmiles; | ||
exports.fragmentAcyclicSimpleBonds = fragmentAcyclicSimpleBonds; | ||
exports.fragmentAcyclicSingleBonds = fragmentAcyclicSingleBonds; | ||
exports.getAtomsInfo = getAtomsInfo; | ||
@@ -1739,2 +1739,3 @@ exports.getConnectivityMatrix = getConnectivityMatrix; | ||
exports.getHoseCodesForAtom = getHoseCodesForAtom; | ||
exports.getHoseCodesForPath = getHoseCodesForPath; | ||
exports.getHoseCodesFromDiastereotopicID = getHoseCodesFromDiastereotopicID; | ||
@@ -1741,0 +1742,0 @@ exports.getMF = getMF; |
{ | ||
"name": "openchemlib-utils", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Various utilities that extends openchemlib-js like HOSE codes or diastereotopic IDs", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -10,2 +10,3 @@ export * from './diastereotopic/addDiastereotopicMissingChirality'; | ||
export * from './hose/getHoseCodesFromDiastereotopicID'; | ||
export * from './hose/getHoseCodesForPath'; | ||
@@ -27,2 +28,2 @@ export * from './util/combineSmiles'; | ||
export * from './fragment/fragmentAcyclicSimpleBonds'; | ||
export * from './fragment/fragmentAcyclicSingleBonds'; |
@@ -6,3 +6,3 @@ import atomSorter from 'atom-sorter'; | ||
* {OCL.Molecule} [molecule] an instance of OCL.Molecule | ||
* @returns {String} | ||
* @returns {object} | ||
*/ | ||
@@ -9,0 +9,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122609
3306