@iktos-oss/rdkit-provider
Version:
exports an initialized RDKit instance, with helper functions
181 lines (177 loc) • 7.75 kB
JavaScript
;
/*
MIT License
Copyright (c) 2023 Iktos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStereoTags = exports.getNewCoords = exports.addHs = exports.removeHs = exports.convertMolNotation = exports.isValidMolBlock = exports.getMatchingSubstructure = exports.hasMatchingSubstructure = exports.isValidSmarts = exports.isValidSmiles = exports.getMorganFp = exports.isChiral = exports.getCanonicalFormForStructure = exports.getMoleculeDetails = exports.getSvgFromSmarts = exports.getSvg = void 0;
const worker_1 = require("../worker");
const actions_1 = require("../worker/actions");
const getSvg = (worker, { smiles, drawingDetails, alignmentDetails, }) => {
const key = `${smiles}-${JSON.stringify(drawingDetails)}-${JSON.stringify(alignmentDetails)}`;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_SVG,
key: key,
payload: { smiles, drawingDetails, alignmentDetails },
}).then((msg) => msg.payload);
};
exports.getSvg = getSvg;
const getSvgFromSmarts = (worker, { smarts, width, height }) => {
const key = `${smarts}-${width}-${height}`;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_SVG_FROM_SMARTS,
key: key,
payload: { smarts, width, height },
}).then((msg) => msg.payload);
};
exports.getSvgFromSmarts = getSvgFromSmarts;
function getMoleculeDetails(// returnFullDetails = false is deprecated, returnFullDetails will be removed in v3 and returnFullDetails = true will be the default behavior
worker, { smiles, returnFullDetails = false }) {
const key = smiles;
if (!returnFullDetails) {
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.DEPRECATED_GET_MOLECULE_DETAILS,
key,
payload: { smiles },
}).then((msg) => msg.payload);
}
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_MOLECULE_DETAILS,
key,
payload: { smiles },
}).then((msg) => msg.payload);
}
exports.getMoleculeDetails = getMoleculeDetails;
const getCanonicalFormForStructure = (worker, { structure, molNotation, useQMol }) => {
const key = structure;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_CANONICAL_FORM_FOR_STRUCTURE,
key: key,
payload: { structure, molNotation, useQMol },
}).then((msg) => msg.payload);
};
exports.getCanonicalFormForStructure = getCanonicalFormForStructure;
const isChiral = (worker, { smiles }) => {
const key = smiles;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.IS_CHIRAL,
key: key,
payload: { smiles },
}).then((msg) => msg.payload);
};
exports.isChiral = isChiral;
const getMorganFp = (worker, params) => {
const key = params.smiles;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_MORGAN_FP,
key: key,
payload: params,
}).then((msg) => msg.payload);
};
exports.getMorganFp = getMorganFp;
const isValidSmiles = (worker, { smiles }) => {
const key = smiles;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.IS_VALID_SMILES,
key: key,
payload: { smiles },
}).then((msg) => msg.payload);
};
exports.isValidSmiles = isValidSmiles;
const isValidSmarts = (worker, { smarts }) => {
const key = smarts;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.IS_VALID_SMARTS,
key: key,
payload: { smarts },
}).then((msg) => msg.payload);
};
exports.isValidSmarts = isValidSmarts;
const hasMatchingSubstructure = (worker, { smiles, substructure }) => {
const key = `${smiles}-${substructure}`;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.HAS_MATCHING_SUBSTRUCTURE,
key: key,
payload: { smiles, substructure },
}).then((msg) => msg.payload);
};
exports.hasMatchingSubstructure = hasMatchingSubstructure;
const getMatchingSubstructure = (worker, { structure, substructure }) => {
const key = `${structure}-${substructure}`;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_SUBSTRUCTURE_MATCH,
key: key,
payload: { structure, substructure },
}).then((msg) => msg.payload);
};
exports.getMatchingSubstructure = getMatchingSubstructure;
const isValidMolBlock = (worker, { mdl }) => {
const key = mdl;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.IS_VALID_MOLBLOCK,
key,
payload: { mdl },
}).then((msg) => msg.payload);
};
exports.isValidMolBlock = isValidMolBlock;
const convertMolNotation = (worker, { moleculeString, targetNotation, sourceNotation, useQMol, }) => {
const key = `${moleculeString}-to-${targetNotation}`;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.CONVERT_MOL_NOTATION,
key,
payload: { moleculeString, targetNotation, sourceNotation, useQMol },
}).then((msg) => msg.payload);
};
exports.convertMolNotation = convertMolNotation;
const removeHs = (worker, { structure }) => {
const key = structure;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.REMOVE_HS,
key,
payload: { structure },
}).then((msg) => msg.payload);
};
exports.removeHs = removeHs;
const addHs = (worker, { structure }) => {
const key = structure;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.ADD_HS,
key,
payload: { structure },
}).then((msg) => msg.payload);
};
exports.addHs = addHs;
const getNewCoords = (worker, { structure, useCoordGen }) => {
const key = structure;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_NEW_COORDS,
key,
payload: { structure, useCoordGen },
}).then((msg) => msg.payload);
};
exports.getNewCoords = getNewCoords;
const getStereoTags = (worker, { structure }) => {
const key = structure;
return (0, worker_1.postWorkerJob)(worker, {
actionType: actions_1.RDKIT_WORKER_ACTIONS.GET_STEREO_TAGS,
key,
payload: { structure },
}).then((msg) => msg.payload);
};
exports.getStereoTags = getStereoTags;
//# sourceMappingURL=actions.js.map