rdkit-esm 0.5.1 → 0.7.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -41
- package/dist/RDKit_minimal.wasm +0 -0
- package/dist/index.d.ts +329 -63
- package/dist/index.js +368 -100
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,23 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
RDKit minimal lib for the modern web.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## About
|
|
8
|
+
|
|
9
|
+
> A scientific library for Cheminformatics (depict, search, compare, process molecular data). Same features as the RDKit.js library, distributed as a standard ES module for modern development environments (install from npm, import in your code). Type safety for every method and parameters, autocomplete and documentation in your IDE.
|
|
10
|
+
|
|
11
|
+
RDKit ESM is a wrapper around [RDKit-js](https://www.rdkitjs.com/), the official JavaScript distribution of RDKit's main functionalities.
|
|
12
|
+
Based on the same MinimalLib Web Assembly (WASM) binary, it simplifies writing code by wrapping all the conversions for the user: no need for manually serializing and deserializing JSON strings to interact with the raw WASM API, you get a direct TypeScript interface with full autocomplete and compile-time validation of every option. No need to build specific object like MolList: regular JS arrays of Mol objects can be used instead.
|
|
13
|
+
|
|
14
|
+

|
|
6
15
|
|
|
7
16
|
**Features:** molecule parsing, substructure search, molecular descriptors, fingerprints (Morgan, MACCS, pattern, ...), reactions, Maximum Common Substructure, R-group decomposition, SVG and Canvas rendering.
|
|
8
17
|
|
|
9
18
|
## Acknowledgment
|
|
10
19
|
|
|
11
|
-
This library is based on the RDKit project and
|
|
12
|
-
in particular Michel Moreau and Paolo Tosco for maintaining the MinimalLib and the RDKit-js distribution. The
|
|
13
|
-
definitions
|
|
20
|
+
This library is based on the RDKit project and its RDKit-js distribution. We thank the RDKit community for their contributions,
|
|
21
|
+
in particular Michel Moreau and Paolo Tosco for maintaining the MinimalLib and the RDKit-js distribution. The original types
|
|
22
|
+
definitions in RDKit-js had been written by Ádám Baróthi.
|
|
23
|
+
|
|
24
|
+
The examples in this repository and the unit-tests are based on the code and the data in the MinimalLib repository, written mostly by Greg Landrum and Paolo Tosco.
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
### Installation
|
|
16
29
|
|
|
17
30
|
```bash
|
|
18
31
|
npm install rdkit-esm
|
|
19
32
|
```
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
### Usage
|
|
22
35
|
|
|
23
36
|
```ts
|
|
24
37
|
import { initRDKit } from 'rdkit-esm';
|
|
@@ -36,6 +49,26 @@ if (mol) {
|
|
|
36
49
|
}
|
|
37
50
|
```
|
|
38
51
|
|
|
52
|
+
### Important note about code bundling
|
|
53
|
+
|
|
54
|
+
If your application deployment involves a build step, the bundler requires a hint about
|
|
55
|
+
the WASM binary file location, so that it gets copied with the other assets (such as images).
|
|
56
|
+
The code will vary depending on your bundler.
|
|
57
|
+
|
|
58
|
+
With Vite.js, the initialization code will look like:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { initRDKit } from 'rdkit-esm';
|
|
62
|
+
import wasmUrl from 'rdkit-esm/dist/RDKit_minimal.wasm?url'; // the `?url` part is a directive for rolldown wasm plugin
|
|
63
|
+
|
|
64
|
+
// Pass the `locateFile` function which returns the path where the WASM is located
|
|
65
|
+
// During the build process, Vite will replace it with the path to the assets directory
|
|
66
|
+
// where the WASM file has been copied to
|
|
67
|
+
const rdkit = await initRDKit({ locateFile: () => wasmUrl });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Note that using a distribution as a WASM file is the most efficient (can be compressed by the server and is processed more rapidly by the browser than a base64 encoded string).
|
|
71
|
+
|
|
39
72
|
## API Overview
|
|
40
73
|
|
|
41
74
|
### `initRDKit(options?): Promise<RDKit>`
|
|
@@ -46,16 +79,17 @@ Loads the WASM module and returns the main interface. **Must be awaited** before
|
|
|
46
79
|
|
|
47
80
|
The main entry point for creating molecules, reactions, and collections.
|
|
48
81
|
|
|
49
|
-
| Method | Description
|
|
50
|
-
| ----------------------------------- |
|
|
51
|
-
| `getMol(input, options?)` | Create a `Mol` from SMILES,
|
|
52
|
-
| `getQMol(input)` | Create a query `Mol` from a SMARTS string or a query
|
|
53
|
-
| `getRxn(input, options?)` | Create a `Reaction` from reaction SMARTS, SMILES, or an RXN block.
|
|
54
|
-
| `getMCS(mols, options?)` | Compute the Maximum Common Substructure across a set of molecules (`Mol[]` or `string[]`).
|
|
55
|
-
| `getRGD(core, molecules, options?)` | R-Group Decomposition against one or more core structures.
|
|
56
|
-
| `molzip(mol1, mol2)` | Combine two molecules
|
|
57
|
-
| `version` | RDKit version string.
|
|
58
|
-
| `
|
|
82
|
+
| Method | Description |
|
|
83
|
+
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
84
|
+
| `getMol(input, options?)` | Create a `Mol` from strings (SMILES, V2000/V3000 Mol, CXSMILES), commonchem/RDKit JSON, RDKit pickle (as a Uint8Array). Returns `null` on invalid input or throws with the reason if `{ throwOnError }` is passed |
|
|
85
|
+
| `getQMol(input)` | Create a query `Mol` from a SMARTS string or a query Mol File. |
|
|
86
|
+
| `getRxn(input, options?)` | Create a `Reaction` from reaction SMARTS, SMILES, or an RXN block. |
|
|
87
|
+
| `getMCS(mols, options?)` | Compute the Maximum Common Substructure across a set of molecules (`Mol[]` or `string[]`). |
|
|
88
|
+
| `getRGD(core, molecules, options?)` | R-Group Decomposition against one or more core structures (`Mol`, `Mol[]`, `string` or `string[]`). |
|
|
89
|
+
| `molzip(mol1, mol2)` | Combine two molecules using matching RGroups, labels, etc... |
|
|
90
|
+
| `version` | RDKit version string. |
|
|
91
|
+
| `createSubstructLibrary` | Returns a Substructure Library wrapper for optimized substructure searches |
|
|
92
|
+
| `configure(options)` | General configuration options for the library, including `enableLogging` |
|
|
59
93
|
|
|
60
94
|
### `Mol`
|
|
61
95
|
|
|
@@ -68,8 +102,8 @@ Wraps a single molecule with a typed, camelCase API.
|
|
|
68
102
|
- **Drawing** — `getSVG(options?)`, `drawToCanvas(canvas, ...)`
|
|
69
103
|
- **Coordinates** — `setNewCoords()`, `generateAlignedCoords(template, options?)`
|
|
70
104
|
- **Mutations** — `addHs()` / `removeHs()`, `convertToAromaticForm()` / `convertToKekuleForm()`, `combineWith()`, `zipWith()`
|
|
71
|
-
- **Properties** — `hasProp()`, `getProp()`, `setProp()`, `clearProp()`, `
|
|
72
|
-
- **Info** — `
|
|
105
|
+
- **Properties** — `hasProp()`, `getProp()`, `setProp()`, `clearProp()`, `getPropMap()`
|
|
106
|
+
- **Info** — `isDeleted`, `numAtoms`, `numHeavyAtoms`, `numBonds`, `hasCoords()`, `getStereoTags()`
|
|
73
107
|
|
|
74
108
|
### `MolArray`
|
|
75
109
|
|
|
@@ -100,29 +134,6 @@ using mol = rdkit.getMol('CCO')!;
|
|
|
100
134
|
// mol is deleted automatically when the scope exits
|
|
101
135
|
```
|
|
102
136
|
|
|
103
|
-
## Development
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
# Install dependencies
|
|
107
|
-
pnpm install
|
|
108
|
-
|
|
109
|
-
# Run the unit tests
|
|
110
|
-
pnpm test
|
|
111
|
-
|
|
112
|
-
# Build for distribution
|
|
113
|
-
pnpm build
|
|
114
|
-
|
|
115
|
-
# Type-check
|
|
116
|
-
pnpm typecheck
|
|
117
|
-
|
|
118
|
-
# Format code
|
|
119
|
-
pnpm fmt
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Upgrading RDKit MinimalLib
|
|
123
|
-
|
|
124
|
-
The `MinimalLib/` directory contains a copy of the RDKit MinimalLib compilation output. To upgrade to a newer RDKit version, replace the contents of `MinimalLib/dist/` with the WASM and JS files from the new build.
|
|
125
|
-
|
|
126
137
|
## License
|
|
127
138
|
|
|
128
139
|
[MIT](LICENSE)
|
package/dist/RDKit_minimal.wasm
CHANGED
|
Binary file
|