UNPKG

@iktos-oss/rdkit-provider

Version:

exports an initialized RDKit instance, with helper functions

162 lines (158 loc) 6.3 kB
/* 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. */ import { postWorkerJob } from '../worker'; import { RDKIT_WORKER_ACTIONS } from '../worker/actions'; export const getSvg = (worker, { smiles, drawingDetails, alignmentDetails, }) => { const key = `${smiles}-${JSON.stringify(drawingDetails)}-${JSON.stringify(alignmentDetails)}`; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_SVG, key: key, payload: { smiles, drawingDetails, alignmentDetails }, }).then((msg) => msg.payload); }; export const getSvgFromSmarts = (worker, { smarts, width, height }) => { const key = `${smarts}-${width}-${height}`; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_SVG_FROM_SMARTS, key: key, payload: { smarts, width, height }, }).then((msg) => msg.payload); }; export 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 postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.DEPRECATED_GET_MOLECULE_DETAILS, key, payload: { smiles }, }).then((msg) => msg.payload); } return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_MOLECULE_DETAILS, key, payload: { smiles }, }).then((msg) => msg.payload); } export const getCanonicalFormForStructure = (worker, { structure, molNotation, useQMol }) => { const key = structure; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_CANONICAL_FORM_FOR_STRUCTURE, key: key, payload: { structure, molNotation, useQMol }, }).then((msg) => msg.payload); }; export const isChiral = (worker, { smiles }) => { const key = smiles; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.IS_CHIRAL, key: key, payload: { smiles }, }).then((msg) => msg.payload); }; export const getMorganFp = (worker, params) => { const key = params.smiles; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_MORGAN_FP, key: key, payload: params, }).then((msg) => msg.payload); }; export const isValidSmiles = (worker, { smiles }) => { const key = smiles; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.IS_VALID_SMILES, key: key, payload: { smiles }, }).then((msg) => msg.payload); }; export const isValidSmarts = (worker, { smarts }) => { const key = smarts; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.IS_VALID_SMARTS, key: key, payload: { smarts }, }).then((msg) => msg.payload); }; export const hasMatchingSubstructure = (worker, { smiles, substructure }) => { const key = `${smiles}-${substructure}`; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.HAS_MATCHING_SUBSTRUCTURE, key: key, payload: { smiles, substructure }, }).then((msg) => msg.payload); }; export const getMatchingSubstructure = (worker, { structure, substructure }) => { const key = `${structure}-${substructure}`; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_SUBSTRUCTURE_MATCH, key: key, payload: { structure, substructure }, }).then((msg) => msg.payload); }; export const isValidMolBlock = (worker, { mdl }) => { const key = mdl; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.IS_VALID_MOLBLOCK, key, payload: { mdl }, }).then((msg) => msg.payload); }; export const convertMolNotation = (worker, { moleculeString, targetNotation, sourceNotation, useQMol, }) => { const key = `${moleculeString}-to-${targetNotation}`; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.CONVERT_MOL_NOTATION, key, payload: { moleculeString, targetNotation, sourceNotation, useQMol }, }).then((msg) => msg.payload); }; export const removeHs = (worker, { structure }) => { const key = structure; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.REMOVE_HS, key, payload: { structure }, }).then((msg) => msg.payload); }; export const addHs = (worker, { structure }) => { const key = structure; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.ADD_HS, key, payload: { structure }, }).then((msg) => msg.payload); }; export const getNewCoords = (worker, { structure, useCoordGen }) => { const key = structure; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_NEW_COORDS, key, payload: { structure, useCoordGen }, }).then((msg) => msg.payload); }; export const getStereoTags = (worker, { structure }) => { const key = structure; return postWorkerJob(worker, { actionType: RDKIT_WORKER_ACTIONS.GET_STEREO_TAGS, key, payload: { structure }, }).then((msg) => msg.payload); }; //# sourceMappingURL=actions.js.map