rdkit-esm 0.7.0 → 0.8.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  RDKit minimal lib for the modern web.
4
4
 
5
- ![RDKit v2026.03.1](https://img.shields.io/badge/RDKit-v2026--03--1-brightgreen?style=flat)
5
+ ![RDKit v2026.09.1](https://img.shields.io/badge/RDKit-v2026--09--1-brightgreen?style=flat)
6
6
 
7
7
  ## About
8
8
 
Binary file
package/dist/index.d.ts CHANGED
@@ -107,6 +107,14 @@ interface JSMol {
107
107
  * @returns A stringified JSON object containing the matched atoms and bonds of the parent molecule
108
108
  */
109
109
  get_substruct_match(q: JSMol): string;
110
+ /**
111
+ * Returns a substructure match string
112
+ *
113
+ * @param q query molecule
114
+ * @param details stringified JSON of `RDKitSubstructMatchOptions` (e.g. `uniquify`, `maxMatches`, `useChirality`)
115
+ * @returns A stringified JSON object containing the matched atoms and bonds of the parent molecule
116
+ */
117
+ get_substruct_match(q: JSMol, details: string): string;
110
118
  /**
111
119
  * Returns all substructure matches
112
120
  *
@@ -114,6 +122,14 @@ interface JSMol {
114
122
  * @returns A stringified JSON object containing the matched atoms and bonds of the parent molecule
115
123
  */
116
124
  get_substruct_matches(q: JSMol): string;
125
+ /**
126
+ * Returns all substructure matches
127
+ *
128
+ * @param q query molecule
129
+ * @param details stringified JSON of `RDKitSubstructMatchOptions` (e.g. `uniquify`, `maxMatches`, `useChirality`)
130
+ * @returns A stringified JSON object containing the matched atoms and bonds of the parent molecule
131
+ */
132
+ get_substruct_matches(q: JSMol, details: string): string;
117
133
  // molecular descriptors
118
134
  /**
119
135
  * Returns a stringified JSON object of molecular descriptors
@@ -1282,6 +1298,69 @@ type RDKitSubstructMatch = {
1282
1298
  atoms: number[];
1283
1299
  bonds: number[];
1284
1300
  };
1301
+ /**
1302
+ * Substructure matching options, mirroring RDKit's `SubstructMatchParameters` JSON keys
1303
+ * (see `updateSubstructMatchParamsFromJSON` in `SubstructUtils.cpp`).
1304
+ */
1305
+ type RDKitSubstructMatchOptions = {
1306
+ /**
1307
+ * Use chirality in determining whether or not atoms/bonds match
1308
+ * @default false
1309
+ */
1310
+ useChirality: boolean;
1311
+ /**
1312
+ * Use enhanced stereochemistry in determining whether atoms/bonds match
1313
+ * @default false
1314
+ */
1315
+ useEnhancedStereo: boolean;
1316
+ /**
1317
+ * Aromatic and conjugated bonds match each other
1318
+ * @default false
1319
+ */
1320
+ aromaticMatchesConjugated: boolean;
1321
+ /**
1322
+ * Consider query-query matches, not just simple matches
1323
+ * @default false
1324
+ */
1325
+ useQueryQueryMatches: boolean;
1326
+ /**
1327
+ * Allow recursive queries
1328
+ * @default true
1329
+ */
1330
+ recursionPossible: boolean;
1331
+ /**
1332
+ * Uniquify match results by atom indices: matches covering the same set of atoms in a different
1333
+ * order (e.g. a flipped phenyl ring) are collapsed into one. Set to `false` to get every mapping.
1334
+ * @default true
1335
+ */
1336
+ uniquify: boolean;
1337
+ /**
1338
+ * Maximum number of matches to return
1339
+ * @default 1000
1340
+ */
1341
+ maxMatches: number;
1342
+ /**
1343
+ * Maximum number of matches that the recursive substructure matching should return
1344
+ * @default 1000
1345
+ */
1346
+ maxRecursiveMatches: number;
1347
+ /**
1348
+ * Number of threads to use when multi-threading is possible
1349
+ * @default 1
1350
+ */
1351
+ numThreads: number;
1352
+ /**
1353
+ * Atoms and bonds with specified stereochemistry in the query match atoms and bonds with
1354
+ * unspecified stereochemistry in the molecule
1355
+ * @default false
1356
+ */
1357
+ specifiedStereoQueryMatchesUnspecified: boolean;
1358
+ /**
1359
+ * Aromatic bonds match single or double bonds
1360
+ * @default false
1361
+ */
1362
+ aromaticMatchesSingleOrDouble: boolean;
1363
+ };
1285
1364
  /**
1286
1365
  * Flags controlling which sanitization steps are run when `sanitize` is an object.
1287
1366
  * Each key corresponds to a `MolOps::SanitizeFlags` enum value; `true` enables it,
@@ -2090,16 +2169,19 @@ export declare class Mol implements Disposable {
2090
2169
  * Returns the first substructure match
2091
2170
  *
2092
2171
  * @param query - A Mol instance or a SMARTS string to use as query
2172
+ * @param options - Substructure matching options (e.g. `useChirality`)
2093
2173
  * @returns The matched atom and bond indices
2094
2174
  */
2095
- getSubstructMatch(query: Mol | string): RDKitSubstructMatch;
2175
+ getSubstructMatch(query: Mol | string, options?: Partial<RDKitSubstructMatchOptions>): RDKitSubstructMatch;
2096
2176
  /**
2097
2177
  * Returns all substructure matches
2098
2178
  *
2099
2179
  * @param query - A Mol instance or a SMARTS string to use as query
2180
+ * @param options - Substructure matching options. Set `uniquify: false` to also get the
2181
+ * matches covering the same atoms in a different order (e.g. symmetric groups).
2100
2182
  * @returns An array of matched atom and bond indices
2101
2183
  */
2102
- getSubstructMatches(query: Mol | string): RDKitSubstructMatch[];
2184
+ getSubstructMatches(query: Mol | string, options?: Partial<RDKitSubstructMatchOptions>): RDKitSubstructMatch[];
2103
2185
  /** Returns molecular descriptors as a typed object */
2104
2186
  getDescriptors(): RDKitDescriptors | null;
2105
2187
  /**
@@ -2750,4 +2832,4 @@ interface InitRDKitOptions {
2750
2832
  export declare function initRDKit(options?: Partial<InitRDKitOptions>): Promise<RDKit>;
2751
2833
  export declare function initRDKit<T extends typeof RDKit>(options: Partial<InitRDKitOptions> | undefined, constructor: T): Promise<InstanceType<T>>;
2752
2834
  //#endregion
2753
- export type { ColourPalette, ColourPaletteName, DrawColour, DrawingExtentsInclude, InitRDKitOptions, JSMol, JSReaction, MCSResult, MMPAFragmentation, MolList, RDKitAlignedCoordsOptions, RDKitAtomPairFPOptions, RDKitCondenseAbbreviationsOptions, RDKitConfigureOptions, RDKitConformers, RDKitDescriptors, RDKitEvents, RDKitFailCallback, RDKitForceFieldDetails, RDKitForceFieldEnergyDetails, RDKitForceFieldEnergyOptions, RDKitForceFieldEnergyResult, RDKitForceFieldFrame, RDKitForceFieldName, RDKitGenerateConformersDetails, RDKitGenerateConformersOptions, RDKitGenerateConformersResult, RDKitGetCxSmilesOptions, RDKitGetFragsOptions, RDKitGetMCSOptions, RDKitGetMolBlockOptions, RDKitGetMolOpt, RDKitGetMolOptions, RDKitGetQMolOptions, RDKitGetRgdOptions, RDKitGetRxnOptions, RDKitGetSVGOptions, RDKitGetSmilesOptions, RDKitJson, RDKitJsonAtom, RDKitJsonBond, RDKitJsonConformer2D, RDKitJsonConformer3D, RDKitJsonExtension, RDKitJsonMolecule, RDKitMCSResult, RDKitMinimization, RDKitMinimizationFrame, RDKitMinimizeDetails, RDKitMinimizeOptions, RDKitMinimizeResult, RDKitMmpaFragsOptions, RDKitMmpaFragsResult, RDKitModule, RDKitMolOperation, RDKitMorganFPOptions, RDKitOperation, RDKitParseErrorEvent, RDKitParseOperation, RDKitPatternFPOptions, RDKitRdkitFpOptions, RDKitRemoveHsOptions, RDKitRxnDetails, RDKitSanitizeFlags, RDKitStereoTags, RDKitSubstructMatch, RDKitTopologicalTorsionFPOptions, RGDRow, SimilarityMetric, SubstructLibraryAddOptions, SubstructLibraryEntry, SubstructLibraryOptions, SubstructLibrarySearchOptions, SubstructLibrarySearchResult, TverskySimilarityOptions };
2835
+ export type { ColourPalette, ColourPaletteName, DrawColour, DrawingExtentsInclude, InitRDKitOptions, JSMol, JSReaction, MCSResult, MMPAFragmentation, MolList, RDKitAlignedCoordsOptions, RDKitAtomPairFPOptions, RDKitCondenseAbbreviationsOptions, RDKitConfigureOptions, RDKitConformers, RDKitDescriptors, RDKitEvents, RDKitFailCallback, RDKitForceFieldDetails, RDKitForceFieldEnergyDetails, RDKitForceFieldEnergyOptions, RDKitForceFieldEnergyResult, RDKitForceFieldFrame, RDKitForceFieldName, RDKitGenerateConformersDetails, RDKitGenerateConformersOptions, RDKitGenerateConformersResult, RDKitGetCxSmilesOptions, RDKitGetFragsOptions, RDKitGetMCSOptions, RDKitGetMolBlockOptions, RDKitGetMolOpt, RDKitGetMolOptions, RDKitGetQMolOptions, RDKitGetRgdOptions, RDKitGetRxnOptions, RDKitGetSVGOptions, RDKitGetSmilesOptions, RDKitJson, RDKitJsonAtom, RDKitJsonBond, RDKitJsonConformer2D, RDKitJsonConformer3D, RDKitJsonExtension, RDKitJsonMolecule, RDKitMCSResult, RDKitMinimization, RDKitMinimizationFrame, RDKitMinimizeDetails, RDKitMinimizeOptions, RDKitMinimizeResult, RDKitMmpaFragsOptions, RDKitMmpaFragsResult, RDKitModule, RDKitMolOperation, RDKitMorganFPOptions, RDKitOperation, RDKitParseErrorEvent, RDKitParseOperation, RDKitPatternFPOptions, RDKitRdkitFpOptions, RDKitRemoveHsOptions, RDKitRxnDetails, RDKitSanitizeFlags, RDKitStereoTags, RDKitSubstructMatch, RDKitSubstructMatchOptions, RDKitTopologicalTorsionFPOptions, RGDRow, SimilarityMetric, SubstructLibraryAddOptions, SubstructLibraryEntry, SubstructLibraryOptions, SubstructLibrarySearchOptions, SubstructLibrarySearchResult, TverskySimilarityOptions };
package/dist/index.js CHANGED
@@ -4351,13 +4351,14 @@ var Mol = class Mol {
4351
4351
  * Returns the first substructure match
4352
4352
  *
4353
4353
  * @param query - A Mol instance or a SMARTS string to use as query
4354
+ * @param options - Substructure matching options (e.g. `useChirality`)
4354
4355
  * @returns The matched atom and bond indices
4355
4356
  */
4356
- getSubstructMatch(query) {
4357
+ getSubstructMatch(query, options) {
4357
4358
  const mol = this.jsMol;
4358
4359
  const [qmol, shouldDelete] = this.resolveQuery(query);
4359
4360
  try {
4360
- const matchJson = mol.get_substruct_match(qmol);
4361
+ const matchJson = options ? mol.get_substruct_match(qmol, JSON.stringify(options)) : mol.get_substruct_match(qmol);
4361
4362
  if (matchJson === "{}") return {
4362
4363
  atoms: [],
4363
4364
  bonds: []
@@ -4371,13 +4372,15 @@ var Mol = class Mol {
4371
4372
  * Returns all substructure matches
4372
4373
  *
4373
4374
  * @param query - A Mol instance or a SMARTS string to use as query
4375
+ * @param options - Substructure matching options. Set `uniquify: false` to also get the
4376
+ * matches covering the same atoms in a different order (e.g. symmetric groups).
4374
4377
  * @returns An array of matched atom and bond indices
4375
4378
  */
4376
- getSubstructMatches(query) {
4379
+ getSubstructMatches(query, options) {
4377
4380
  const mol = this.jsMol;
4378
4381
  const [qmol, shouldDelete] = this.resolveQuery(query);
4379
4382
  try {
4380
- const matchesJson = mol.get_substruct_matches(qmol);
4383
+ const matchesJson = options ? mol.get_substruct_matches(qmol, JSON.stringify(options)) : mol.get_substruct_matches(qmol);
4381
4384
  if (!matchesJson.startsWith("[")) return [];
4382
4385
  return JSON.parse(matchesJson);
4383
4386
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdkit-esm",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "RDKit minimal lib for the modern web.",
5
5
  "homepage": "https://github.com/tandemai/rdkit-esm#readme",
6
6
  "bugs": {
@@ -22,16 +22,6 @@
22
22
  "./dist/RDKit_minimal.wasm": "./dist/RDKit_minimal.wasm",
23
23
  "./package.json": "./package.json"
24
24
  },
25
- "scripts": {
26
- "build": "tsdown",
27
- "dev": "tsdown --watch",
28
- "fmt": "oxfmt",
29
- "fmt:check": "oxfmt --check",
30
- "test": "vitest --typecheck",
31
- "coverage": "vitest run --coverage",
32
- "typecheck": "tsgo --noEmit",
33
- "prepublishOnly": "pnpm run build"
34
- },
35
25
  "devDependencies": {
36
26
  "@types/node": "^25.9.6",
37
27
  "@vitest/coverage-v8": "^4.1.11",
@@ -41,5 +31,14 @@
41
31
  "tsdown": "^0.23.0",
42
32
  "typescript": "^7.0.2",
43
33
  "vitest": "^4.1.11"
34
+ },
35
+ "scripts": {
36
+ "build": "tsdown",
37
+ "dev": "tsdown --watch",
38
+ "fmt": "oxfmt",
39
+ "fmt:check": "oxfmt --check",
40
+ "test": "vitest --typecheck",
41
+ "coverage": "vitest run --coverage",
42
+ "typecheck": "tsgo --noEmit"
44
43
  }
45
- }
44
+ }