openchemlib-utils
Advanced tools
Comparing version 5.19.1 to 5.20.0
@@ -57,3 +57,3 @@ // this page allows to debug the hints: https://my.cheminfo.org/?viewURL=https%3A%2F%2Fmyviews.cheminfo.org%2Fdb%2Fvisualizer%2Fentry%2F108024089da99d0cb70a57724486d0c6%2Fview.json | ||
idCode: 'eMB@HRZCBKSFXXJt{?Y@', | ||
message: 'You should consider an thiol.', | ||
message: 'You should consider a thiol.', | ||
}, | ||
@@ -60,0 +60,0 @@ { |
import type { Molecule } from 'openchemlib'; | ||
export interface GetMoleculeWithHOptions { | ||
/** | ||
* @default 250 | ||
* Maximum number of atoms with hydrogens | ||
*/ | ||
maxNbAtoms?: number; | ||
} | ||
/** | ||
@@ -7,3 +14,3 @@ * Expand all the implicit hydrogens and ensure chiral bonds on heterotopic bonds | ||
*/ | ||
export declare function getMoleculeWithH(molecule: Molecule): Molecule; | ||
export declare function getMoleculeWithH(molecule: Molecule, options?: GetMoleculeWithHOptions): Molecule; | ||
//# sourceMappingURL=getMoleculeWithH.d.ts.map |
import { ensureHeterotopicChiralBonds } from '../diastereotopic/ensureHeterotopicChiralBonds.js'; | ||
const MAX_NB_ATOMS = 250; | ||
/** | ||
@@ -8,7 +7,8 @@ * Expand all the implicit hydrogens and ensure chiral bonds on heterotopic bonds | ||
*/ | ||
export function getMoleculeWithH(molecule) { | ||
export function getMoleculeWithH(molecule, options = {}) { | ||
const { maxNbAtoms = 250 } = options; | ||
const moleculeWithH = molecule.getCompactCopy(); | ||
moleculeWithH.addImplicitHydrogens(); | ||
if (moleculeWithH.getAllAtoms() > MAX_NB_ATOMS) { | ||
throw new Error(`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${MAX_NB_ATOMS}`); | ||
if (moleculeWithH.getAllAtoms() > maxNbAtoms) { | ||
throw new Error(`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${maxNbAtoms}`); | ||
} | ||
@@ -15,0 +15,0 @@ ensureHeterotopicChiralBonds(moleculeWithH); |
import type { Molecule } from 'openchemlib'; | ||
import { AtomPath } from '../path/getAllAtomsPaths.js'; | ||
import { HoseCodesOptions } from './HoseCodesOptions.js'; | ||
import { GetMoleculeWithHOptions } from './getMoleculeWithH'; | ||
interface ToMolfileOptions { | ||
version?: 2 | 3; | ||
} | ||
interface TopicMoleculeOptions extends HoseCodesOptions { | ||
interface TopicMoleculeOptions extends HoseCodesOptions, GetMoleculeWithHOptions { | ||
/** | ||
@@ -13,2 +14,3 @@ * The maximum path length to consider when calculating the paths between atoms | ||
maxPathLength?: number; | ||
maxNbAtoms?: number; | ||
} | ||
@@ -15,0 +17,0 @@ type TopicMoleculeInternalOptions = Omit<TopicMoleculeOptions, 'maxPathLength'> & Required<Pick<TopicMoleculeOptions, 'maxPathLength'>>; |
@@ -158,3 +158,5 @@ import { getAllAtomsPaths } from '../path/getAllAtomsPaths.js'; | ||
return this.cache.moleculeWithH; | ||
this.cache.moleculeWithH = getMoleculeWithH(this.molecule); | ||
this.cache.moleculeWithH = getMoleculeWithH(this.molecule, { | ||
maxNbAtoms: this.options.maxNbAtoms, | ||
}); | ||
return this.cache.moleculeWithH; | ||
@@ -161,0 +163,0 @@ } |
@@ -60,3 +60,3 @@ "use strict"; | ||
idCode: 'eMB@HRZCBKSFXXJt{?Y@', | ||
message: 'You should consider an thiol.', | ||
message: 'You should consider a thiol.', | ||
}, | ||
@@ -63,0 +63,0 @@ { |
import type { Molecule } from 'openchemlib'; | ||
export interface GetMoleculeWithHOptions { | ||
/** | ||
* @default 250 | ||
* Maximum number of atoms with hydrogens | ||
*/ | ||
maxNbAtoms?: number; | ||
} | ||
/** | ||
@@ -7,3 +14,3 @@ * Expand all the implicit hydrogens and ensure chiral bonds on heterotopic bonds | ||
*/ | ||
export declare function getMoleculeWithH(molecule: Molecule): Molecule; | ||
export declare function getMoleculeWithH(molecule: Molecule, options?: GetMoleculeWithHOptions): Molecule; | ||
//# sourceMappingURL=getMoleculeWithH.d.ts.map |
@@ -5,3 +5,2 @@ "use strict"; | ||
const ensureHeterotopicChiralBonds_js_1 = require("../diastereotopic/ensureHeterotopicChiralBonds.js"); | ||
const MAX_NB_ATOMS = 250; | ||
/** | ||
@@ -12,7 +11,8 @@ * Expand all the implicit hydrogens and ensure chiral bonds on heterotopic bonds | ||
*/ | ||
function getMoleculeWithH(molecule) { | ||
function getMoleculeWithH(molecule, options = {}) { | ||
const { maxNbAtoms = 250 } = options; | ||
const moleculeWithH = molecule.getCompactCopy(); | ||
moleculeWithH.addImplicitHydrogens(); | ||
if (moleculeWithH.getAllAtoms() > MAX_NB_ATOMS) { | ||
throw new Error(`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${MAX_NB_ATOMS}`); | ||
if (moleculeWithH.getAllAtoms() > maxNbAtoms) { | ||
throw new Error(`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${maxNbAtoms}`); | ||
} | ||
@@ -19,0 +19,0 @@ (0, ensureHeterotopicChiralBonds_js_1.ensureHeterotopicChiralBonds)(moleculeWithH); |
import type { Molecule } from 'openchemlib'; | ||
import { AtomPath } from '../path/getAllAtomsPaths.js'; | ||
import { HoseCodesOptions } from './HoseCodesOptions.js'; | ||
import { GetMoleculeWithHOptions } from './getMoleculeWithH'; | ||
interface ToMolfileOptions { | ||
version?: 2 | 3; | ||
} | ||
interface TopicMoleculeOptions extends HoseCodesOptions { | ||
interface TopicMoleculeOptions extends HoseCodesOptions, GetMoleculeWithHOptions { | ||
/** | ||
@@ -13,2 +14,3 @@ * The maximum path length to consider when calculating the paths between atoms | ||
maxPathLength?: number; | ||
maxNbAtoms?: number; | ||
} | ||
@@ -15,0 +17,0 @@ type TopicMoleculeInternalOptions = Omit<TopicMoleculeOptions, 'maxPathLength'> & Required<Pick<TopicMoleculeOptions, 'maxPathLength'>>; |
@@ -161,3 +161,5 @@ "use strict"; | ||
return this.cache.moleculeWithH; | ||
this.cache.moleculeWithH = (0, getMoleculeWithH_1.getMoleculeWithH)(this.molecule); | ||
this.cache.moleculeWithH = (0, getMoleculeWithH_1.getMoleculeWithH)(this.molecule, { | ||
maxNbAtoms: this.options.maxNbAtoms, | ||
}); | ||
return this.cache.moleculeWithH; | ||
@@ -164,0 +166,0 @@ } |
{ | ||
"name": "openchemlib-utils", | ||
"version": "5.19.1", | ||
"version": "5.20.0", | ||
"description": "Various utilities that extends openchemlib-js like HOSE codes or diastereotopic IDs", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -60,3 +60,3 @@ // this page allows to debug the hints: https://my.cheminfo.org/?viewURL=https%3A%2F%2Fmyviews.cheminfo.org%2Fdb%2Fvisualizer%2Fentry%2F108024089da99d0cb70a57724486d0c6%2Fview.json | ||
idCode: 'eMB@HRZCBKSFXXJt{?Y@', | ||
message: 'You should consider an thiol.', | ||
message: 'You should consider a thiol.', | ||
}, | ||
@@ -63,0 +63,0 @@ { |
@@ -5,3 +5,9 @@ import type { Molecule } from 'openchemlib'; | ||
const MAX_NB_ATOMS = 250; | ||
export interface GetMoleculeWithHOptions { | ||
/** | ||
* @default 250 | ||
* Maximum number of atoms with hydrogens | ||
*/ | ||
maxNbAtoms?: number; | ||
} | ||
@@ -13,8 +19,12 @@ /** | ||
*/ | ||
export function getMoleculeWithH(molecule: Molecule) { | ||
export function getMoleculeWithH( | ||
molecule: Molecule, | ||
options: GetMoleculeWithHOptions = {}, | ||
) { | ||
const { maxNbAtoms = 250 } = options; | ||
const moleculeWithH = molecule.getCompactCopy(); | ||
moleculeWithH.addImplicitHydrogens(); | ||
if (moleculeWithH.getAllAtoms() > MAX_NB_ATOMS) { | ||
if (moleculeWithH.getAllAtoms() > maxNbAtoms) { | ||
throw new Error( | ||
`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${MAX_NB_ATOMS}`, | ||
`too many atoms to add hydrogens: ${moleculeWithH.getAllAtoms()} > ${maxNbAtoms}`, | ||
); | ||
@@ -21,0 +31,0 @@ } |
@@ -15,3 +15,3 @@ import type { Molecule } from 'openchemlib'; | ||
} from './getHeterotopicSymmetryRanks'; | ||
import { getMoleculeWithH } from './getMoleculeWithH'; | ||
import { getMoleculeWithH, GetMoleculeWithHOptions } from './getMoleculeWithH'; | ||
import { getXMolecule } from './getXMolecule'; | ||
@@ -23,3 +23,5 @@ | ||
interface TopicMoleculeOptions extends HoseCodesOptions { | ||
interface TopicMoleculeOptions | ||
extends HoseCodesOptions, | ||
GetMoleculeWithHOptions { | ||
/** | ||
@@ -30,2 +32,3 @@ * The maximum path length to consider when calculating the paths between atoms | ||
maxPathLength?: number; | ||
maxNbAtoms?: number; | ||
} | ||
@@ -245,3 +248,5 @@ | ||
if (this.cache.moleculeWithH) return this.cache.moleculeWithH; | ||
this.cache.moleculeWithH = getMoleculeWithH(this.molecule); | ||
this.cache.moleculeWithH = getMoleculeWithH(this.molecule, { | ||
maxNbAtoms: this.options.maxNbAtoms, | ||
}); | ||
return this.cache.moleculeWithH; | ||
@@ -248,0 +253,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1130553
17033