-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Molecule } from 'openchemlib'; | ||
|
||
import { getProperties } from '../getProperties'; | ||
|
||
test('getProperties, default options', () => { | ||
let molecule = Molecule.fromSmiles('[NH3+]CC(=O)[O-]'); | ||
let properties = getProperties(molecule); | ||
expect(properties).toStrictEqual({ | ||
acceptorCount: 3, | ||
donorCount: 1, | ||
logP: -6.870399981737137, | ||
logS: -0.027999980375170708, | ||
polarSurfaceArea: 67.76999855041504, | ||
rotatableBondCount: 1, | ||
stereoCenterCount: 0, | ||
mf: 'C2H5NO2', | ||
mw: 75.0667, | ||
}); | ||
}); | ||
|
||
test('getProperties, includeToxicities', () => { | ||
let molecule = Molecule.fromSmiles('[NH3+]CC(=O)[O-]'); | ||
let properties = getProperties(molecule, { includeToxicities: true }); | ||
expect(properties).toStrictEqual({ | ||
acceptorCount: 3, | ||
donorCount: 1, | ||
logP: -6.870399981737137, | ||
logS: -0.027999980375170708, | ||
polarSurfaceArea: 67.76999855041504, | ||
rotatableBondCount: 1, | ||
stereoCenterCount: 0, | ||
mf: 'C2H5NO2', | ||
mw: 75.0667, | ||
mutagenic: 1, | ||
tumorigenic: 1, | ||
irritant: 1, | ||
reproductiveEffective: 1, | ||
}); | ||
}); | ||
|
||
test('getProperties, include all', () => { | ||
let molecule = Molecule.fromSmiles('[NH3+]CC(=O)[O-]'); | ||
let properties = getProperties(molecule, { | ||
includeToxicities: true, | ||
includeDruglikeness: true, | ||
}); | ||
expect(properties).toStrictEqual({ | ||
acceptorCount: 3, | ||
donorCount: 1, | ||
logP: -6.870399981737137, | ||
logS: -0.027999980375170708, | ||
polarSurfaceArea: 67.76999855041504, | ||
rotatableBondCount: 1, | ||
stereoCenterCount: 0, | ||
mf: 'C2H5NO2', | ||
mw: 75.0667, | ||
mutagenic: 1, | ||
tumorigenic: 1, | ||
irritant: 1, | ||
reproductiveEffective: 1, | ||
drugLikeness: -3.0141666666666667, | ||
drugScore: 0.5218060573381611, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
let toxicityPredictor; | ||
let druglikenessPredictor; | ||
|
||
/** | ||
* | ||
* @param {import('openchemlib').Molecule} molecule | ||
* @param {object} [options={}] | ||
* @param {boolean} [options.includeToxicities=false] | ||
* @param {boolean} [options.includeDruglikeness=false] | ||
*/ | ||
export function getProperties(molecule, options = {}) { | ||
const { includeToxicities = false, includeDruglikeness = false } = options; | ||
const OCL = molecule.getOCL(); | ||
if (!OCL.MoleculeProperties) { | ||
throw new Error('OCL.MoleculeProperties is not defined'); | ||
} | ||
const props = new OCL.MoleculeProperties(molecule); | ||
const moleculeFormula = molecule.getMolecularFormula(); | ||
const result = { | ||
acceptorCount: props.acceptorCount, | ||
donorCount: props.donorCount, | ||
logP: props.logP, | ||
logS: props.logS, | ||
polarSurfaceArea: props.polarSurfaceArea, | ||
rotatableBondCount: props.rotatableBondCount, | ||
stereoCenterCount: props.stereoCenterCount, | ||
mw: moleculeFormula.relativeWeight, | ||
mf: moleculeFormula.formula, | ||
}; | ||
|
||
if (includeToxicities) { | ||
const { ToxicityPredictor } = molecule.getOCL(); | ||
if (!ToxicityPredictor) { | ||
throw new Error('OCL.ToxicityPredictor is not defined'); | ||
} | ||
if (!toxicityPredictor) { | ||
toxicityPredictor = new ToxicityPredictor(); | ||
} | ||
result.mutagenic = toxicityPredictor.assessRisk( | ||
molecule, | ||
ToxicityPredictor.TYPE_MUTAGENIC, | ||
); | ||
result.tumorigenic = toxicityPredictor.assessRisk( | ||
molecule, | ||
ToxicityPredictor.TYPE_TUMORIGENIC, | ||
); | ||
result.irritant = toxicityPredictor.assessRisk( | ||
molecule, | ||
ToxicityPredictor.TYPE_IRRITANT, | ||
); | ||
result.reproductiveEffective = toxicityPredictor.assessRisk( | ||
molecule, | ||
ToxicityPredictor.TYPE_REPRODUCTIVE_EFFECTIVE, | ||
); | ||
} | ||
|
||
if (includeDruglikeness) { | ||
const { DruglikenessPredictor } = molecule.getOCL(); | ||
if (!DruglikenessPredictor) { | ||
throw new Error('OCL.DruglikenessPredictor is not defined'); | ||
} | ||
if (!druglikenessPredictor) { | ||
druglikenessPredictor = new DruglikenessPredictor(); | ||
} | ||
result.drugLikeness = druglikenessPredictor.assessDruglikeness(molecule); | ||
} | ||
|
||
if (result.drugLikeness !== undefined && result.mutagenic !== undefined) { | ||
result.drugScore = OCL.DrugScoreCalculator.calculate( | ||
result.logP, | ||
result.polarSurfaceArea, | ||
result.mw, | ||
result.drugLikeness, | ||
[ | ||
result.mutagenic, | ||
result.tumurogenic, | ||
result.irritant, | ||
result.reproductiveEffective, | ||
], | ||
); | ||
} | ||
|
||
return result; | ||
} |