2.6.3 • Published 28 days ago

@iktos-oss/rdkit-provider v2.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
28 days ago

rdkit-provider

Initialises a web worker with RDKitModule instance from @rdkit/rdkit and exposes it via a react context

Setup

Assets

The project using this package needs to provide it with RDKit package assets

After installing @rdkit/rdkit copy to your public folder node_modules/@iktos-oss/rdkit-provider/lib/rdkit-worker*.js node_modules/@rdkit/rdkit/dist/RDKit_minimal.js node_modules/@rdkit/rdkit/dist/RDKit_minimal.wasm

Usage

Wrap your components/App with RDKitProvider

import { RDKitProvider } from '@iktos/rdkit-provider';
<RDKitProvider>
  <Component />
</RDKitProvider>

you can also enable caching for molecule, which would enhance performance

import { RDKitProvider } from '@iktos/rdkit-provider';
<RDKitProvider cache={{ enableJsMolCaching: true, maxJsMolsCached: 50 }}>
  <Component />
</RDKitProvider>

Options that can be passed to RDKitProvider:

proptypefunctionalityrequired/optional
cacheRDKitProviderCacheOptions = { enableJsMolCaching?: boolean; maxJsMolsCached?: number; }enables JSMol caching for better performanceoptional
preferCoordgenbooleanwill be passed to @rdkit/rdkitjs prefer_coordgen to use Schrodinger’s open-source Coordgen library to generate 2D coordinates of moleculesoptional
removeHsbooleantoggles removing hydrogens molecules. Defaults to trueoptional
initialWorkerInstanceWorker instance of rdkit-worker.jspass an rdkit worker instance, if not passed rdkit-provider creates one for youoptional
rdkitPathstring default to /RDKit_minimal.js in initRDKit.tspass a custom path to rdkit moduleoptional
rdkitWorkerPublicFolderstring, default is '', meaning the file is at the root level of the public folderpath to the folder containing the rdkit-worker-version.js relative to the public folderoptional

You can make use of a set of helper functions exposed by the package

import { useRDKitUtils, useRDKit } from '@iktos/rdkit-provider';

const Component = () => {
  const { worker } = useRDKit();
  const { isValidSmiles } = useRDKitUtils();
  const submit = useCallback(
    async (smiles) => {
      const { isValid } = await isValidSmiles({ smiles });
      if (!isValid) return;
      // ...
    },
    [isValidSmiles],
  );

  if (!worker) return 'loading ...';
  return <>...</>;
  //...
};

Example of usage can be found in github.com/iktos/molecule-representation

2.6.3

28 days ago

2.6.1

2 months ago

2.6.2

2 months ago

2.6.1-beta.0

2 months ago

2.6.1-beta.1

2 months ago

2.7.0-beta.3

2 months ago

2.7.0-beta.2

3 months ago

2.7.0-beta.1

3 months ago

2.6.0

4 months ago

2.6.0-beta.2

4 months ago

2.5.0

6 months ago

2.6.0-beta.1

6 months ago

2.5.0-beta-1

7 months ago

2.4.3-beta.2

9 months ago

2.4.3-beta.5

8 months ago

2.4.3-beta.4

9 months ago

2.4.1

12 months ago

2.4.2

11 months ago

2.0.1-beta.8

1 year ago

2.3.0

1 year ago

2.4.0-beta0

1 year ago

2.2.0

1 year ago

2.4.0-beta1

1 year ago

2.4.0

1 year ago

2.4.0-beta2

1 year ago

2.3.1

1 year ago

2.0.1-beta.2

1 year ago

2.0.1-beta.3

1 year ago

2.0.0-beta.1

1 year ago

2.0.0-beta.0

1 year ago

2.0.1-beta.1

1 year ago

2.0.1-beta.6

1 year ago

2.1.0

1 year ago

2.0.1-beta.4

1 year ago

2.0.1-beta.5

1 year ago

2.0.0

1 year ago

2.1.1-beta.2

1 year ago

2.1.0-beta.0

1 year ago

2.1.1-beta.3

1 year ago

2.1.0-beta.2

1 year ago

2.2.1-beta.2

1 year ago

2.2.1-beta.1

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.1-beta.3

1 year ago

1.2.1-beta.2

1 year ago

1.2.1-beta.1

1 year ago

1.2.0

1 year ago

1.2.0-beta.5

1 year ago

1.2.0-beta.4

1 year ago

1.2.0-beta.3

1 year ago

1.2.0-beta.2

1 year ago

1.2.0-beta.1

1 year ago

1.1.0

1 year ago