openchemlib-utils
Advanced tools
Comparing version 1.9.0 to 1.10.0
@@ -1226,2 +1226,26 @@ 'use strict'; | ||
/** | ||
* Calculates the path between 2 atoms | ||
* @param {OCL.Molecule} molecule | ||
* @param {number} from - index of the first atom | ||
* @param {number} to - index of the end atom | ||
* @param {number} maxLength - maximal length of the path | ||
*/ | ||
function getPathAndTorsion(molecule, from, to, maxLength) { | ||
let originalAtoms = []; // path before renumbering | ||
molecule.getPath(originalAtoms, from, to, maxLength + 1); | ||
let torsion; | ||
if (originalAtoms.length === 4) { | ||
torsion = molecule.calculateTorsion(originalAtoms); | ||
} | ||
return { | ||
atoms: originalAtoms, | ||
from, | ||
to, | ||
torsion, | ||
length: originalAtoms.length - 1, | ||
}; | ||
} | ||
let fragment; | ||
@@ -1233,6 +1257,7 @@ | ||
* @param {object} [options={}] | ||
* @param {string} [opions.fromLabel='H'] | ||
* @param {string} [opions.toLabel='H'] | ||
* @param {string} [opions.minLength=1] | ||
* @param {string} [opions.maxLength=4] | ||
* @param {string} [options.fromLabel='H'] | ||
* @param {string} [options.toLabel='H'] | ||
* @param {number} [options.minLength=1] | ||
* @param {number} [options.maxLength=4] | ||
* @param {boolean} [options.withHOSES=false] | ||
@@ -1246,2 +1271,3 @@ */ | ||
maxLength = 4, | ||
withHOSES = false, | ||
} = options; | ||
@@ -1273,11 +1299,11 @@ | ||
if (pathLength >= minLength && pathLength <= maxLength) { | ||
atomsInfo[from].paths.push( | ||
getHoseCodesForPath( | ||
molecule, | ||
from, | ||
to, | ||
pathLength, | ||
atomsInfo[to].oclID, | ||
), | ||
); | ||
if (withHOSES) { | ||
atomsInfo[from].paths.push( | ||
getHoseCodesForPath(molecule, from, to, pathLength), | ||
); | ||
} else { | ||
atomsInfo[from].paths.push( | ||
getPathAndTorsion(molecule, from, to, pathLength), | ||
); | ||
} | ||
} | ||
@@ -2013,2 +2039,3 @@ } | ||
exports.getMF = getMF; | ||
exports.getPathAndTorsion = getPathAndTorsion; | ||
exports.getPathsInfo = getPathsInfo; | ||
@@ -2015,0 +2042,0 @@ exports.getShortestPaths = getShortestPaths; |
{ | ||
"name": "openchemlib-utils", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Various utilities that extends openchemlib-js like HOSE codes or diastereotopic IDs", | ||
@@ -50,2 +50,3 @@ "main": "lib/index.js", | ||
"jest": "^27.5.0", | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"openchemlib": "7.4.0", | ||
@@ -52,0 +53,0 @@ "prettier": "^2.5.1", |
@@ -27,2 +27,3 @@ export * from './diastereotopic/addDiastereotopicMissingChirality'; | ||
export * from './path/getPathsInfo'; | ||
export * from './path/getPathAndTorsion'; | ||
export * from './path/getShortestPaths'; | ||
@@ -29,0 +30,0 @@ |
@@ -5,2 +5,4 @@ import { getHoseCodesForPath } from '../hose/getHoseCodesForPath'; | ||
import { getPathAndTorsion } from './getPathAndTorsion.js'; | ||
let fragment; | ||
@@ -12,6 +14,7 @@ | ||
* @param {object} [options={}] | ||
* @param {string} [opions.fromLabel='H'] | ||
* @param {string} [opions.toLabel='H'] | ||
* @param {string} [opions.minLength=1] | ||
* @param {string} [opions.maxLength=4] | ||
* @param {string} [options.fromLabel='H'] | ||
* @param {string} [options.toLabel='H'] | ||
* @param {number} [options.minLength=1] | ||
* @param {number} [options.maxLength=4] | ||
* @param {boolean} [options.withHOSES=false] | ||
@@ -25,2 +28,3 @@ */ | ||
maxLength = 4, | ||
withHOSES = false, | ||
} = options; | ||
@@ -52,11 +56,11 @@ | ||
if (pathLength >= minLength && pathLength <= maxLength) { | ||
atomsInfo[from].paths.push( | ||
getHoseCodesForPath( | ||
molecule, | ||
from, | ||
to, | ||
pathLength, | ||
atomsInfo[to].oclID, | ||
), | ||
); | ||
if (withHOSES) { | ||
atomsInfo[from].paths.push( | ||
getHoseCodesForPath(molecule, from, to, pathLength), | ||
); | ||
} else { | ||
atomsInfo[from].paths.push( | ||
getPathAndTorsion(molecule, from, to, pathLength), | ||
); | ||
} | ||
} | ||
@@ -63,0 +67,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
135888
49
3866
12