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/dist/index.d.ts
CHANGED
|
@@ -272,7 +272,10 @@ interface JSMol {
|
|
|
272
272
|
* @param {boolean} acceptFailure
|
|
273
273
|
*/
|
|
274
274
|
generate_aligned_coords(templateMol: JSMol, options: JSONString): string;
|
|
275
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Returns true if the molecule's structure is valid
|
|
277
|
+
* @deprecated An invalid molecule is `null`. Kept for backward compatibility.
|
|
278
|
+
*/
|
|
276
279
|
is_valid(): boolean;
|
|
277
280
|
/** Returns the total number of atoms in the molecule */
|
|
278
281
|
get_num_atoms(): number;
|
|
@@ -291,7 +294,7 @@ interface JSMol {
|
|
|
291
294
|
/** Returns the V2000 Molfile representation of the kekule form of the molecule */
|
|
292
295
|
get_kekule_form(): string;
|
|
293
296
|
/** Returns the disconnected fragments of the molecule */
|
|
294
|
-
get_frags(): {
|
|
297
|
+
get_frags(details_json?: string): {
|
|
295
298
|
mappings: JSONString;
|
|
296
299
|
molList: MolList;
|
|
297
300
|
};
|
|
@@ -548,6 +551,8 @@ interface SubstructLibrary {
|
|
|
548
551
|
* @param maxResults maximum number of results
|
|
549
552
|
*/
|
|
550
553
|
get_matches_as_uint32array(q: JSMol, useChirality: boolean, numThreads: number, maxResults: number): Uint32Array;
|
|
554
|
+
delete(): void;
|
|
555
|
+
isDeleted(): boolean;
|
|
551
556
|
}
|
|
552
557
|
interface MolList {
|
|
553
558
|
/**
|
|
@@ -608,7 +613,7 @@ interface StringList extends EmscriptenVector<string> {}
|
|
|
608
613
|
/** Returns a new SubstructLibrary instance */
|
|
609
614
|
interface SubstructLibraryConstructor {
|
|
610
615
|
new (): SubstructLibrary;
|
|
611
|
-
new (
|
|
616
|
+
new (numBits: number): SubstructLibrary;
|
|
612
617
|
}
|
|
613
618
|
interface MolListConstructor {
|
|
614
619
|
new (): MolList;
|
|
@@ -616,12 +621,8 @@ interface MolListConstructor {
|
|
|
616
621
|
interface RGroupDecomposition {
|
|
617
622
|
add(mol: JSMol): number;
|
|
618
623
|
process(): boolean;
|
|
619
|
-
get_rgroups_as_columns(): {
|
|
620
|
-
|
|
621
|
-
};
|
|
622
|
-
get_rgroups_as_rows(): {
|
|
623
|
-
[key: 'Core' | `R${number}`]: JSMol;
|
|
624
|
-
}[];
|
|
624
|
+
get_rgroups_as_columns(): { [key in 'Core' | `R${number}`]: MolList };
|
|
625
|
+
get_rgroups_as_rows(): { [key in 'Core' | `R${number}`]: JSMol }[];
|
|
625
626
|
delete(): void;
|
|
626
627
|
}
|
|
627
628
|
/** The main RDKit module */
|
|
@@ -802,6 +803,11 @@ type DrawColour = [number, number, number, number?];
|
|
|
802
803
|
type ColourPalette = {
|
|
803
804
|
[k: number]: DrawColour;
|
|
804
805
|
};
|
|
806
|
+
type ColourPaletteName = 'default' | 'avalon' | 'cdk' | 'darkmode' | 'bw';
|
|
807
|
+
/** Flags controlling which elements are included when computing drawing extents.
|
|
808
|
+
* Each key corresponds to a DrawElement enum value; `true` includes it, `false` excludes it.
|
|
809
|
+
* Example: `{ ALL: true, HIGHLIGHTS: false }` includes everything except highlights. */
|
|
810
|
+
type DrawingExtentsInclude = Partial<Record<'NONE' | 'PRESHAPES' | 'BONDS' | 'ATOMLABELS' | 'HIGHLIGHTS' | 'ANNOTATIONS' | 'RADICALS' | 'POSTSHAPES' | 'ALL', boolean>>;
|
|
805
811
|
type RDKitDepictionDetails = {
|
|
806
812
|
/** Drawing width in pixels */width: number; /** Drawing height in pixels */
|
|
807
813
|
height: number; /** X offset for drawing origin in pixels */
|
|
@@ -845,7 +851,7 @@ type RDKitDepictionDetails = {
|
|
|
845
851
|
highlightBondWidthMultiplier: number; /** Call prepareMolForDrawing() on each molecule passed to drawMolecules() */
|
|
846
852
|
prepareMolsBeforeDrawing: boolean; /** Defines 10 default colors for highlighting atoms and bonds or reactants in reactions */
|
|
847
853
|
highlightColourPalette: DrawColour[]; /** The palette used to assign colors to atoms based on atomic number */
|
|
848
|
-
atomColourPalette: ColourPalette; /** Fixes scale to this fraction of draw window width so an average bond is this fraction of the width; -1.0 means no fix */
|
|
854
|
+
atomColourPalette: ColourPalette | ColourPaletteName; /** Fixes scale to this fraction of draw window width so an average bond is this fraction of the width; -1.0 means no fix */
|
|
849
855
|
fixedScale: number; /** Fixes the bond length (and hence the scale) to always be this number of pixels; -1.0 means no fix. If both fixedScale and fixedBondLength are > 0, fixedScale wins */
|
|
850
856
|
fixedBondLength: number; /** Angle in degrees to rotate coords by about centre before drawing */
|
|
851
857
|
rotate: number; /** Adds atom indices to drawings */
|
|
@@ -857,8 +863,11 @@ type RDKitDepictionDetails = {
|
|
|
857
863
|
showAllCIPCodes: boolean; /** Forces atom highlights always to be circles; default (false) puts ellipses round longer labels */
|
|
858
864
|
atomHighlightsAreCircles: boolean; /** Highlight style for multi-colour highlights */
|
|
859
865
|
multiColourHighlightStyle: 'CIRCLEANDLINE' | 'LASSO'; /** Moves the centre of the drawn molecule to (0,0) */
|
|
860
|
-
centreMoleculesBeforeDrawing: boolean;
|
|
861
|
-
|
|
866
|
+
centreMoleculesBeforeDrawing: boolean;
|
|
867
|
+
/** Which elements should be included when computing drawing extents.
|
|
868
|
+
* Pass an object with DrawElement flag names as keys and boolean values.
|
|
869
|
+
* Example: `{ ALL: true, HIGHLIGHTS: false }` = include everything except highlights. */
|
|
870
|
+
drawingExtentsInclude: DrawingExtentsInclude; /** Draw terminal methyl and related groups as CH3 */
|
|
862
871
|
explicitMethyl: boolean; /** Include radicals in the drawing; can be useful to turn off for reactions and queries */
|
|
863
872
|
includeRadicals: boolean; /** When possible, include metadata about molecules and reactions in the output to allow them to be reconstructed */
|
|
864
873
|
includeMetadata: boolean; /** Simulate hand-drawn lines for bonds; when combined with a font like Comic-Sans or Comic-Neue, gives xkcd-like drawings */
|
|
@@ -879,7 +888,8 @@ type RDKitDepictionDetails = {
|
|
|
879
888
|
atoms: number[]; /** Bond indices to highlight */
|
|
880
889
|
bonds: number[]; /** Per-atom highlight colors, keyed by atom index */
|
|
881
890
|
highlightAtomColors: Record<number, DrawColour>; /** Per-bond highlight colors, keyed by bond index */
|
|
882
|
-
highlightBondColors: Record<number, DrawColour>; /**
|
|
891
|
+
highlightBondColors: Record<number, DrawColour>; /** Per-atom highlight radii, keyed by atom index */
|
|
892
|
+
highlightAtomRadii: Record<number, number>; /** If true, highlighted hetero atoms are drawn in standard colours rather than black */
|
|
883
893
|
standardColoursForHighlightedAtoms: boolean; // Drawing call parameters (parsed from the details JSON by common.h, not part of MolDrawOptions)
|
|
884
894
|
/** Caption text to display below the molecule (distinct from legendFontSize/legendColour which control its appearance) */
|
|
885
895
|
legend: string; /** Panel width in pixels for multi-panel or grid drawings */
|
|
@@ -916,19 +926,36 @@ type RDKitSubstructMatch = {
|
|
|
916
926
|
atoms: number[];
|
|
917
927
|
bonds: number[];
|
|
918
928
|
};
|
|
929
|
+
/**
|
|
930
|
+
* Flags controlling which sanitization steps are run when `sanitize` is an object.
|
|
931
|
+
* Each key corresponds to a `MolOps::SanitizeFlags` enum value; `true` enables it,
|
|
932
|
+
* `false` disables it. Omitted keys are left at their default (all enabled).
|
|
933
|
+
* Example: `{ SANITIZE_KEKULIZE: false }` runs all steps except kekulization.
|
|
934
|
+
*/
|
|
935
|
+
type RDKitSanitizeFlags = Partial<Record<'SANITIZE_NONE' | 'SANITIZE_CLEANUP' | 'SANITIZE_PROPERTIES' | 'SANITIZE_SYMMRINGS' | 'SANITIZE_KEKULIZE' | 'SANITIZE_FINDRADICALS' | 'SANITIZE_SETAROMATICITY' | 'SANITIZE_SETCONJUGATION' | 'SANITIZE_SETHYBRIDIZATION' | 'SANITIZE_CLEANUPCHIRALITY' | 'SANITIZE_ADJUSTHS' | 'SANITIZE_CLEANUP_ORGANOMETALLICS' | 'SANITIZE_CLEANUPATROPISOMERS' | 'SANITIZE_ALL', boolean>>;
|
|
919
936
|
type RDKitGetMolOpt = {
|
|
920
937
|
kekulize: boolean;
|
|
921
938
|
setAromaticity: boolean;
|
|
922
939
|
fastFindRings: boolean;
|
|
923
940
|
mappedDummiesAreRGroups: boolean;
|
|
924
|
-
|
|
941
|
+
/**
|
|
942
|
+
* `true`/`false` to fully enable/disable sanitization, or a `RDKitSanitizeFlags`
|
|
943
|
+
* object for partial sanitization (selectively enable/disable individual steps).
|
|
944
|
+
* @default true
|
|
945
|
+
*/
|
|
946
|
+
sanitize: boolean | RDKitSanitizeFlags;
|
|
925
947
|
removeHs: boolean;
|
|
926
948
|
assignStereo: boolean;
|
|
927
|
-
mergeQueryHs: boolean;
|
|
949
|
+
mergeQueryHs: boolean;
|
|
950
|
+
assignCIPLabels: boolean; /** Assign chiral types from molfile parity flags */
|
|
928
951
|
assignChiralTypesFromMolParity: boolean; /** Convert mapped dummy atoms to query atoms */
|
|
929
952
|
makeDummiesQueries: boolean; /** Apply strict parsing rules to CXSMILES input */
|
|
930
|
-
strictCXSMILES: boolean; /** Apply strict parsing rules to Molfile input */
|
|
931
|
-
strictParsing: boolean;
|
|
953
|
+
strictCXSMILES: boolean; /** Apply strict parsing rules to Molfile input (molblock input only) */
|
|
954
|
+
strictParsing: boolean; /** Parse aromatic bond type from RDKit JSON input (RDKit JSON input only) */
|
|
955
|
+
setAromaticBonds: boolean; /** Apply strict valence check when parsing RDKit JSON input (RDKit JSON input only) */
|
|
956
|
+
strictValenceCheck: boolean; /** Parse molecule properties from RDKit JSON input (RDKit JSON input only) */
|
|
957
|
+
parseProperties: boolean; /** Parse conformers from RDKit JSON input (RDKit JSON input only) */
|
|
958
|
+
parseConformers: boolean;
|
|
932
959
|
};
|
|
933
960
|
type RDKitGetMolBlockOptions = {
|
|
934
961
|
/** @default true */includeStereo: boolean; /** @default true */
|
|
@@ -986,10 +1013,6 @@ type RDKitGetMCSOptions = {
|
|
|
986
1013
|
AtomRingMatchesRingOnly: boolean;
|
|
987
1014
|
BondRingMatchesRingOnly: boolean;
|
|
988
1015
|
MaxDistance: number;
|
|
989
|
-
/**
|
|
990
|
-
* @alias BondCompleteRingsOnly
|
|
991
|
-
*/
|
|
992
|
-
CompleteRingsOnly: boolean;
|
|
993
1016
|
AtomCompleteRingsOnly: boolean;
|
|
994
1017
|
BondCompleteRingsOnly: boolean;
|
|
995
1018
|
/**
|
|
@@ -1107,6 +1130,10 @@ type RDKitGetRgdOptions = {
|
|
|
1107
1130
|
timeout: number;
|
|
1108
1131
|
chunkSize: number;
|
|
1109
1132
|
};
|
|
1133
|
+
type RDKitGetFragsOptions = {
|
|
1134
|
+
/** Whether to sanitize the fragment molecules. @default true */sanitizeFrags: boolean; /** Whether to copy conformers to the fragment molecules. @default true */
|
|
1135
|
+
copyConformers: boolean;
|
|
1136
|
+
};
|
|
1110
1137
|
//#endregion
|
|
1111
1138
|
//#region src/mol-array.d.ts
|
|
1112
1139
|
/**
|
|
@@ -1167,6 +1194,50 @@ type RDKitGetQMolOptions = {
|
|
|
1167
1194
|
type RDKitGetRxnOptions = RDKitRxnDetails & {
|
|
1168
1195
|
throwOnError: boolean;
|
|
1169
1196
|
};
|
|
1197
|
+
type RDKitMmpaFragsOptions = {
|
|
1198
|
+
/** Minimum number of bonds to simultaneously cut. */minCuts: number; /** Maximum number of bonds to simultaneously cut. */
|
|
1199
|
+
maxCuts: number;
|
|
1200
|
+
/**
|
|
1201
|
+
* Fragmentation is aborted when the molecule has more cuttable bonds
|
|
1202
|
+
* than this limit. Prevents combinatorial explosion on highly connected molecules.
|
|
1203
|
+
*/
|
|
1204
|
+
fragmentableBondLimit: number;
|
|
1205
|
+
};
|
|
1206
|
+
type SubstructLibraryOptions = {
|
|
1207
|
+
/**
|
|
1208
|
+
* Pattern fingerprint bit size for pre-screening.
|
|
1209
|
+
* Larger values reduce false positives at the cost of memory.
|
|
1210
|
+
* Ignored if `disableFingerprints` is true.
|
|
1211
|
+
* Default: WASM default (2048).
|
|
1212
|
+
*/
|
|
1213
|
+
nBits?: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* Disable fingerprint pre-screening (brute-force matching only).
|
|
1216
|
+
* Overrides `nBits`. Useful for tiny libraries or testing.
|
|
1217
|
+
* Internally passes `numBits=0` to the WASM constructor.
|
|
1218
|
+
*/
|
|
1219
|
+
disableFingerprints?: boolean;
|
|
1220
|
+
};
|
|
1221
|
+
type SubstructLibraryAddOptions = {
|
|
1222
|
+
/**
|
|
1223
|
+
* Skip SMILES validation and sanitization.
|
|
1224
|
+
* Use only with RDKit-canonical SMILES strings (e.g. from a previous `getSmiles()` call).
|
|
1225
|
+
* Improves add performance on large libraries.
|
|
1226
|
+
*/
|
|
1227
|
+
trusted?: boolean;
|
|
1228
|
+
};
|
|
1229
|
+
type SubstructLibrarySearchOptions = {
|
|
1230
|
+
/**
|
|
1231
|
+
* Enable chiral substructure searching.
|
|
1232
|
+
* Default: false
|
|
1233
|
+
*/
|
|
1234
|
+
useChirality?: boolean;
|
|
1235
|
+
/**
|
|
1236
|
+
* Stop after finding this many matches.
|
|
1237
|
+
* Default: no limit.
|
|
1238
|
+
*/
|
|
1239
|
+
maxResults?: number;
|
|
1240
|
+
};
|
|
1170
1241
|
type RDKitCondenseAbbreviationsOptions = {
|
|
1171
1242
|
/** @default 0.4 */maxCoverage: number; /** @default false */
|
|
1172
1243
|
useLinkers: boolean;
|
|
@@ -1174,7 +1245,12 @@ type RDKitCondenseAbbreviationsOptions = {
|
|
|
1174
1245
|
//#endregion
|
|
1175
1246
|
//#region src/fingerprints/fingerprints.types.d.ts
|
|
1176
1247
|
type FingerprintType = 'Morgan' | 'Pattern' | 'AtomPair' | 'TopologicalTorsion' | 'RDKit' | 'MACCS';
|
|
1177
|
-
type SimilarityMetric = 'tanimoto';
|
|
1248
|
+
type SimilarityMetric = 'tanimoto' | 'dice' | 'cosine' | 'tversky' | 'asymmetric';
|
|
1249
|
+
/** Options for Tversky similarity. `alpha` weights molecule A's unique bits, `beta` weights molecule B's. */
|
|
1250
|
+
type TverskySimilarityOptions = {
|
|
1251
|
+
alpha: number;
|
|
1252
|
+
beta: number;
|
|
1253
|
+
};
|
|
1178
1254
|
//#endregion
|
|
1179
1255
|
//#region src/fingerprints/fingerprint.d.ts
|
|
1180
1256
|
declare class Fingerprint {
|
|
@@ -1190,6 +1266,32 @@ declare class Fingerprint {
|
|
|
1190
1266
|
}
|
|
1191
1267
|
//#endregion
|
|
1192
1268
|
//#region src/mol.d.ts
|
|
1269
|
+
type MMPAFragmentation = {
|
|
1270
|
+
/**
|
|
1271
|
+
* Core fragment with dummy atoms ([*:n]) at cut points.
|
|
1272
|
+
*
|
|
1273
|
+
* @remarks For single-cut fragmentations, this is the largest fragment
|
|
1274
|
+
* after splitting the combined sidechains mol. This differs from the
|
|
1275
|
+
* raw RDKit result, which returns no core for single-cut pairs.
|
|
1276
|
+
*/
|
|
1277
|
+
core: Mol;
|
|
1278
|
+
/**
|
|
1279
|
+
* Sidechains fragment with dummy atoms ([*:n]) at cut points.
|
|
1280
|
+
* For 2+ cut, this is the combined sidechains mol returned by RDKit.
|
|
1281
|
+
* For single-cut, this is the smallest fragment after splitting.
|
|
1282
|
+
* Distinct sidechains can be obtained with `sidechains.getFrags()`.
|
|
1283
|
+
* `molzip(core, sidechains)` reconstructs the original molecule.
|
|
1284
|
+
*/
|
|
1285
|
+
sidechains: Mol;
|
|
1286
|
+
};
|
|
1287
|
+
type RDKitMmpaFragsResult = {
|
|
1288
|
+
/** Core fragments. */cores: MolArray; /** Sidechains fragments. */
|
|
1289
|
+
sidechains: MolArray; /** Number of fragmentations. */
|
|
1290
|
+
readonly length: number; /** Iterate over fragmentations by index. */
|
|
1291
|
+
[Symbol.iterator](): Iterator<MMPAFragmentation>;
|
|
1292
|
+
delete(): void;
|
|
1293
|
+
[Symbol.dispose](): void;
|
|
1294
|
+
};
|
|
1193
1295
|
/**
|
|
1194
1296
|
* A wrapper around RDKit's JSMol object providing a typed, camelCase API.
|
|
1195
1297
|
*
|
|
@@ -1205,7 +1307,8 @@ declare class Fingerprint {
|
|
|
1205
1307
|
* ```
|
|
1206
1308
|
*/
|
|
1207
1309
|
declare class Mol implements Disposable {
|
|
1208
|
-
|
|
1310
|
+
protected _jsMol: JSMol | null;
|
|
1311
|
+
protected module: RDKitModule;
|
|
1209
1312
|
constructor(jsMol: JSMol, module: RDKitModule);
|
|
1210
1313
|
/**
|
|
1211
1314
|
* The underlying JSMol object for direct access to the raw API.
|
|
@@ -1220,11 +1323,11 @@ declare class Mol implements Disposable {
|
|
|
1220
1323
|
*/
|
|
1221
1324
|
private resolveQuery;
|
|
1222
1325
|
/** Returns the canonical SMILES string */
|
|
1223
|
-
getSmiles(options?: RDKitGetSmilesOptions): string;
|
|
1326
|
+
getSmiles(options?: Partial<RDKitGetSmilesOptions>): string;
|
|
1224
1327
|
/** Returns the Chemaxon Extended SMILES string */
|
|
1225
1328
|
getCxSmiles(options?: Partial<RDKitGetCxSmilesOptions>): string;
|
|
1226
1329
|
/** Returns the SMARTS string */
|
|
1227
|
-
getSmarts(options?: RDKitGetSmilesOptions): string;
|
|
1330
|
+
getSmarts(options?: Partial<RDKitGetSmilesOptions>): string;
|
|
1228
1331
|
/** Returns the Chemaxon Extended SMARTS string */
|
|
1229
1332
|
getCxSmarts(options?: Partial<RDKitGetCxSmilesOptions>): string;
|
|
1230
1333
|
/**
|
|
@@ -1277,7 +1380,13 @@ declare class Mol implements Disposable {
|
|
|
1277
1380
|
* // With atom highlighting
|
|
1278
1381
|
* const svg = mol.getSVG({ atoms: [0, 1, 2], highlightColour: [1, 0, 0, 1] });
|
|
1279
1382
|
*/
|
|
1280
|
-
getSVG(options?: Partial<RDKitDepictionDetails>
|
|
1383
|
+
getSVG(options?: Partial<Exclude<RDKitDepictionDetails, 'returnDrawCoords'> & {
|
|
1384
|
+
returnDrawCoords: never;
|
|
1385
|
+
}>): string;
|
|
1386
|
+
getSVGWithDrawCoords(options?: Partial<RDKitDepictionDetails>): {
|
|
1387
|
+
svg: string;
|
|
1388
|
+
drawCoords: [number, number, number][];
|
|
1389
|
+
};
|
|
1281
1390
|
/**
|
|
1282
1391
|
* Returns the first substructure match
|
|
1283
1392
|
*
|
|
@@ -1345,8 +1454,6 @@ declare class Mol implements Disposable {
|
|
|
1345
1454
|
includePrivate?: boolean;
|
|
1346
1455
|
includeComputed?: boolean;
|
|
1347
1456
|
}): Map<string, any>;
|
|
1348
|
-
/** Returns true if the molecule's structure is valid */
|
|
1349
|
-
isValid(): boolean;
|
|
1350
1457
|
/** Returns the number of atoms in the molecule */
|
|
1351
1458
|
get numAtoms(): number;
|
|
1352
1459
|
/** Returns the number of heavy atoms in the molecule (excluding hydrogens and dummy atoms) */
|
|
@@ -1426,7 +1533,7 @@ declare class Mol implements Disposable {
|
|
|
1426
1533
|
* manually deleted by the caller to avoid memory leaks.
|
|
1427
1534
|
* @returns An object with atom/fragment mappings and a `MolArray` of fragments
|
|
1428
1535
|
*/
|
|
1429
|
-
getFrags(): {
|
|
1536
|
+
getFrags(options?: Partial<RDKitGetFragsOptions>): {
|
|
1430
1537
|
mappings: {
|
|
1431
1538
|
atomToFrag: number[];
|
|
1432
1539
|
fragToAtoms: number[][];
|
|
@@ -1435,6 +1542,19 @@ declare class Mol implements Disposable {
|
|
|
1435
1542
|
delete: () => void;
|
|
1436
1543
|
[Symbol.dispose](): void;
|
|
1437
1544
|
};
|
|
1545
|
+
/**
|
|
1546
|
+
* Performs MMPA (Matched Molecular Pairs Analysis) fragmentation.
|
|
1547
|
+
*
|
|
1548
|
+
* Each fragmentation yields a `core` and `sidechains` mol, both with dummy
|
|
1549
|
+
* atoms ([*:n]) at cut points. `mol.zipWith(fragmentation.sidechain, fragmentation.core)`
|
|
1550
|
+
* reconstructs the original molecule.
|
|
1551
|
+
*
|
|
1552
|
+
* @throws If `minCuts < 1` or `maxCuts < minCuts`.
|
|
1553
|
+
*
|
|
1554
|
+
* @warning The returned `RDKitMmpaFragsResult` contains new `Mol` instances
|
|
1555
|
+
* that must be deleted by the caller to avoid memory leaks.
|
|
1556
|
+
*/
|
|
1557
|
+
getMmpaFrags(options: RDKitMmpaFragsOptions): RDKitMmpaFragsResult;
|
|
1438
1558
|
/** Returns a copy of the molecule */
|
|
1439
1559
|
copy(): Mol;
|
|
1440
1560
|
/** Returns true if the underlying C++ object has been deleted */
|
|
@@ -1463,7 +1583,8 @@ declare class Mol implements Disposable {
|
|
|
1463
1583
|
* ```
|
|
1464
1584
|
*/
|
|
1465
1585
|
declare class Reaction implements Disposable {
|
|
1466
|
-
|
|
1586
|
+
protected _jsReaction: JSReaction | null;
|
|
1587
|
+
protected module: RDKitModule;
|
|
1467
1588
|
constructor(jsReaction: JSReaction, module: RDKitModule);
|
|
1468
1589
|
/**
|
|
1469
1590
|
* The underlying JSReaction object for direct access to the raw API.
|
|
@@ -1509,15 +1630,171 @@ declare class Reaction implements Disposable {
|
|
|
1509
1630
|
[Symbol.dispose](): void;
|
|
1510
1631
|
}
|
|
1511
1632
|
//#endregion
|
|
1633
|
+
//#region src/substruct-library.d.ts
|
|
1634
|
+
type SubstructLibraryEntry = {
|
|
1635
|
+
/** Index in the library */index: number; /** RDKit-canonical SMILES */
|
|
1636
|
+
smiles: string; /** Pattern fingerprint used for pre-screening */
|
|
1637
|
+
patternFp: Fingerprint;
|
|
1638
|
+
/**
|
|
1639
|
+
* Lazily creates a Mol from the stored SMILES.
|
|
1640
|
+
* Returns null if the molecule is invalid.
|
|
1641
|
+
*
|
|
1642
|
+
* **WARNING:** The caller is responsible for explicitly deleting this
|
|
1643
|
+
* object (via `.delete()` or `using`) to avoid memory leaks.
|
|
1644
|
+
*/
|
|
1645
|
+
get mol(): Mol | null;
|
|
1646
|
+
delete(): void;
|
|
1647
|
+
[Symbol.dispose](): void;
|
|
1648
|
+
};
|
|
1649
|
+
/** Result of a {@link SubstructLibraryWrapper.getMatches} call */
|
|
1650
|
+
type SubstructLibrarySearchResult = {
|
|
1651
|
+
/** Matching molecule indices */readonly indices: Uint32Array; /** Number of matches (same as `indices.length`) */
|
|
1652
|
+
readonly count: number; /** Iterate over the matching library entries */
|
|
1653
|
+
[Symbol.iterator](): Iterator<SubstructLibraryEntry>;
|
|
1654
|
+
};
|
|
1655
|
+
/**
|
|
1656
|
+
* A collection of molecules for efficient batch substructure searching.
|
|
1657
|
+
*
|
|
1658
|
+
* Molecules are stored as canonical SMILES with pre-computed pattern
|
|
1659
|
+
* fingerprints used to pre-screen candidates before full substructure matching.
|
|
1660
|
+
*
|
|
1661
|
+
* @example
|
|
1662
|
+
* ```ts
|
|
1663
|
+
* using lib = rdkit.createSubstructLibrary();
|
|
1664
|
+
* for (const smi of smilesList) lib.add(smi);
|
|
1665
|
+
* const result = lib.getMatches('C1CCCCN1');
|
|
1666
|
+
* console.log(result.count, Array.from(result.indices));
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
declare class SubstructLibraryWrapper implements Disposable {
|
|
1670
|
+
protected readonly lib: SubstructLibrary;
|
|
1671
|
+
protected readonly module: RDKitModule;
|
|
1672
|
+
/** use {@link RDKit.createSubstructLibraryWrapper} */
|
|
1673
|
+
constructor(module: RDKitModule, options?: SubstructLibraryOptions);
|
|
1674
|
+
/**
|
|
1675
|
+
* Add a molecule to the library.
|
|
1676
|
+
* - `Mol` instance: added via `add_mol` (already parsed and sanitized)
|
|
1677
|
+
* - `string`: treated as SMILES; validated unless `options.trusted` is set
|
|
1678
|
+
*
|
|
1679
|
+
* @returns the index of the added molecule, or -1 on failure
|
|
1680
|
+
*/
|
|
1681
|
+
add(mol: Mol | string, options?: SubstructLibraryAddOptions): number;
|
|
1682
|
+
/**
|
|
1683
|
+
* Add a molecule with a pre-computed pattern fingerprint.
|
|
1684
|
+
* Skips both SMILES validation and fingerprint computation.
|
|
1685
|
+
*
|
|
1686
|
+
* @param smiles RDKit-canonical SMILES string
|
|
1687
|
+
* @param fp pre-computed pattern fingerprint (a `Fingerprint` object)
|
|
1688
|
+
* @returns the index of the added molecule
|
|
1689
|
+
*/
|
|
1690
|
+
addPrecomputed(smiles: string, fp: Fingerprint): number;
|
|
1691
|
+
/**
|
|
1692
|
+
* Returns the entry at index `i`: stored SMILES, pattern fingerprint, and a lazy mol getter.
|
|
1693
|
+
*
|
|
1694
|
+
* The `mol` getter lazily allocates a WASM object on first access.
|
|
1695
|
+
* **WARNING:** The caller is responsible for deleting it via `.delete()` or `using`.
|
|
1696
|
+
*
|
|
1697
|
+
* @example Iterate for serialization:
|
|
1698
|
+
* ```ts
|
|
1699
|
+
* for (let i = 0; i < lib.size; i++) {
|
|
1700
|
+
* const { smiles, patternFp } = lib.at(i);
|
|
1701
|
+
* }
|
|
1702
|
+
* ```
|
|
1703
|
+
*/
|
|
1704
|
+
at(i: number): SubstructLibraryEntry;
|
|
1705
|
+
/**
|
|
1706
|
+
* Runs a substructure search and returns a result object with `count`,
|
|
1707
|
+
* `indices`, and an iterator that yields {@link SubstructLibraryEntry} objects.
|
|
1708
|
+
*
|
|
1709
|
+
* @param query `Mol` instance or SMARTS string
|
|
1710
|
+
*/
|
|
1711
|
+
getMatches(query: Mol | string, options?: SubstructLibrarySearchOptions): SubstructLibrarySearchResult;
|
|
1712
|
+
/** Number of molecules in the library */
|
|
1713
|
+
get size(): number;
|
|
1714
|
+
delete(): void;
|
|
1715
|
+
[Symbol.dispose](): void;
|
|
1716
|
+
/** SMARTS strings resolve to a QueryMol that must be deleted internally */
|
|
1717
|
+
private resolveQuery;
|
|
1718
|
+
}
|
|
1719
|
+
//#endregion
|
|
1512
1720
|
//#region src/rgd.d.ts
|
|
1513
1721
|
/**
|
|
1514
1722
|
* A row from R-Group Decomposition, mapping labels like `Core`, `R1`, `R2`, …
|
|
1515
1723
|
* to Mol instances.
|
|
1516
1724
|
*/
|
|
1517
1725
|
type RGDRow = Record<string, Mol>;
|
|
1726
|
+
/**
|
|
1727
|
+
* The result of an R-Group Decomposition, as an array of {@link RGDRow} with
|
|
1728
|
+
* batch lifecycle management.
|
|
1729
|
+
*
|
|
1730
|
+
* Call {@link delete} (or use the `using` keyword) to delete every `Mol`
|
|
1731
|
+
* in all rows at once.
|
|
1732
|
+
*/
|
|
1733
|
+
declare class RGDResult extends Array<RGDRow> implements Disposable {
|
|
1734
|
+
/** Deletes every non-deleted Mol across all rows */
|
|
1735
|
+
delete(): void;
|
|
1736
|
+
/** Disposable support — allows use with the `using` keyword */
|
|
1737
|
+
[Symbol.dispose](): void;
|
|
1738
|
+
}
|
|
1518
1739
|
//#endregion
|
|
1519
1740
|
//#region src/fingerprints/bitops.d.ts
|
|
1520
|
-
declare const computeFingerprintSimilarity: (a: Fingerprint, b: Fingerprint, metric?: SimilarityMetric) => number;
|
|
1741
|
+
declare const computeFingerprintSimilarity: (a: Fingerprint, b: Fingerprint, metric?: SimilarityMetric, options?: TverskySimilarityOptions) => number;
|
|
1742
|
+
//#endregion
|
|
1743
|
+
//#region src/logger.d.ts
|
|
1744
|
+
declare class RDKitParseError extends Error {
|
|
1745
|
+
readonly input: string | Uint8Array;
|
|
1746
|
+
readonly rdkitMessage: string;
|
|
1747
|
+
constructor(input: string | Uint8Array, rdkitMessage: string);
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Type guard for RDKitParseError.
|
|
1751
|
+
* @param error The error to check.
|
|
1752
|
+
* @returns True if the error is an instance of RDKitParseError, false otherwise.
|
|
1753
|
+
* @example
|
|
1754
|
+
* ```ts
|
|
1755
|
+
* try {
|
|
1756
|
+
* rdkit.getMol('invalid input', { throwOnError: true });
|
|
1757
|
+
* } catch (e) {
|
|
1758
|
+
* if (isRDKitParseError(e)) {
|
|
1759
|
+
* console.error('Parsing failed for input:', e.input);
|
|
1760
|
+
* console.error('RDKit message:', e.rdkitMessage);
|
|
1761
|
+
* } else {
|
|
1762
|
+
* console.error('Unexpected error:', e);
|
|
1763
|
+
* }
|
|
1764
|
+
* }
|
|
1765
|
+
* ```
|
|
1766
|
+
*/
|
|
1767
|
+
declare const isRDKitParseError: (error: unknown) => error is RDKitParseError;
|
|
1768
|
+
/**
|
|
1769
|
+
* RDKitLogger manages RDKit error capture and dispatch to listeners, as well as optional console logging.
|
|
1770
|
+
*/
|
|
1771
|
+
declare class RDKitLogger {
|
|
1772
|
+
private readonly mod;
|
|
1773
|
+
private capture;
|
|
1774
|
+
private callback;
|
|
1775
|
+
private enableLogging;
|
|
1776
|
+
private throwOnError;
|
|
1777
|
+
constructor(mod: RDKitModule);
|
|
1778
|
+
private activate;
|
|
1779
|
+
/**
|
|
1780
|
+
* Called from configure({ enableLogging }). Switches between tee and capture
|
|
1781
|
+
* if already active; otherwise applies enable/disable_logging for the no-capture case.
|
|
1782
|
+
*/
|
|
1783
|
+
setEnableLogging(enable: boolean): void;
|
|
1784
|
+
/** Single callback slot — replaces any previous. Returns cleanup function. */
|
|
1785
|
+
addCallback(fn: RDKitFailCallback): () => void;
|
|
1786
|
+
/**
|
|
1787
|
+
* Call before each WASM parse operation.
|
|
1788
|
+
* Stores throwOnError state, activates capture if needed, clears the buffer.
|
|
1789
|
+
* Fast path: no-op when neither throwOnError nor capture is active.
|
|
1790
|
+
*/
|
|
1791
|
+
reset(throwOnError: boolean): void;
|
|
1792
|
+
/**
|
|
1793
|
+
* Call on null return from WASM. Reads buffer, fires callback, throws if throwOnError.
|
|
1794
|
+
* No-op when reset() took the fast path (capture still null).
|
|
1795
|
+
*/
|
|
1796
|
+
handleError(input: string | Uint8Array, operation: RDKitParseOperation): void;
|
|
1797
|
+
}
|
|
1521
1798
|
//#endregion
|
|
1522
1799
|
//#region src/rdkit.d.ts
|
|
1523
1800
|
/** Result of a Maximum Common Substructure (MCS) computation */
|
|
@@ -1549,7 +1826,8 @@ interface MCSResult extends Disposable {
|
|
|
1549
1826
|
* ```
|
|
1550
1827
|
*/
|
|
1551
1828
|
declare class RDKit {
|
|
1552
|
-
|
|
1829
|
+
protected readonly mod: RDKitModule;
|
|
1830
|
+
protected readonly logger: RDKitLogger;
|
|
1553
1831
|
readonly events: RDKitEvents;
|
|
1554
1832
|
/** @internal */
|
|
1555
1833
|
constructor(mod: RDKitModule);
|
|
@@ -1561,7 +1839,8 @@ declare class RDKit {
|
|
|
1561
1839
|
* @returns A Mol instance, or null if the input is invalid.
|
|
1562
1840
|
* Pass `{ throwOnError: true }` to throw a {@link RDKitParseError} instead.
|
|
1563
1841
|
*/
|
|
1564
|
-
getMol(input: string | Uint8Array
|
|
1842
|
+
getMol(input: string | Uint8Array): Mol | null;
|
|
1843
|
+
getMol(input: string | Uint8Array, options: Partial<RDKitGetMolOptions> & {
|
|
1565
1844
|
throwOnError: true;
|
|
1566
1845
|
}): Mol;
|
|
1567
1846
|
getMol(input: string | Uint8Array, options?: Partial<RDKitGetMolOptions>): Mol | null;
|
|
@@ -1572,7 +1851,8 @@ declare class RDKit {
|
|
|
1572
1851
|
* @returns A Mol instance, or null if the input is invalid.
|
|
1573
1852
|
* Pass `{ throwOnError: true }` to throw a {@link RDKitParseError} instead.
|
|
1574
1853
|
*/
|
|
1575
|
-
getQMol(input: string
|
|
1854
|
+
getQMol(input: string): Mol | null;
|
|
1855
|
+
getQMol(input: string, options: Partial<RDKitGetQMolOptions> & {
|
|
1576
1856
|
throwOnError: true;
|
|
1577
1857
|
}): Mol;
|
|
1578
1858
|
getQMol(input: string, options?: Partial<RDKitGetQMolOptions>): Mol | null;
|
|
@@ -1609,8 +1889,20 @@ declare class RDKit {
|
|
|
1609
1889
|
* @returns An array of rows, one per molecule. Each row maps R-group labels
|
|
1610
1890
|
* (`Core`, `R1`, `R2`, …) to Mol instances.
|
|
1611
1891
|
*/
|
|
1612
|
-
getRGD(core: string | string[] | Mol | Mol[], molecules: string[] | Mol[], options?: Partial<RDKitGetRgdOptions>):
|
|
1613
|
-
|
|
1892
|
+
getRGD(core: string | string[] | Mol | Mol[], molecules: string[] | Mol[], options?: Partial<RDKitGetRgdOptions>): RGDResult | null;
|
|
1893
|
+
/**
|
|
1894
|
+
* Creates an empty {@link SubstructLibraryWrapper} for batch substructure searching.
|
|
1895
|
+
*
|
|
1896
|
+
* @example
|
|
1897
|
+
* ```ts
|
|
1898
|
+
* using lib = rdkit.createSubstructLibrary();
|
|
1899
|
+
* for (const smi of smilesList) lib.add(smi);
|
|
1900
|
+
* const result = lib.getMatches('C1CCCCN1'); // SMARTS query
|
|
1901
|
+
* console.log(result.count, Array.from(result.indices));
|
|
1902
|
+
* ```
|
|
1903
|
+
*/
|
|
1904
|
+
createSubstructLibrary(options?: SubstructLibraryOptions): SubstructLibraryWrapper;
|
|
1905
|
+
molzip(mol1: Mol, mol2: Mol, options?: Partial<RDKitMolZipOptions>): Mol | null;
|
|
1614
1906
|
computeFingerprintsSimilarity(...args: Parameters<typeof computeFingerprintSimilarity>): number;
|
|
1615
1907
|
/**
|
|
1616
1908
|
* Applies global configuration options to the RDKit module.
|
|
@@ -1665,30 +1957,4 @@ interface InitRDKitOptions {
|
|
|
1665
1957
|
declare function initRDKit(options?: Partial<InitRDKitOptions>): Promise<RDKit>;
|
|
1666
1958
|
declare function initRDKit<T extends typeof RDKit>(options: Partial<InitRDKitOptions> | undefined, constructor: T): Promise<InstanceType<T>>;
|
|
1667
1959
|
//#endregion
|
|
1668
|
-
|
|
1669
|
-
declare class RDKitParseError extends Error {
|
|
1670
|
-
readonly input: string | Uint8Array;
|
|
1671
|
-
readonly rdkitMessage: string;
|
|
1672
|
-
constructor(input: string | Uint8Array, rdkitMessage: string);
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* Type guard for RDKitParseError.
|
|
1676
|
-
* @param error The error to check.
|
|
1677
|
-
* @returns True if the error is an instance of RDKitParseError, false otherwise.
|
|
1678
|
-
* @example
|
|
1679
|
-
* ```ts
|
|
1680
|
-
* try {
|
|
1681
|
-
* rdkit.getMol('invalid input', { throwOnError: true });
|
|
1682
|
-
* } catch (e) {
|
|
1683
|
-
* if (isRDKitParseError(e)) {
|
|
1684
|
-
* console.error('Parsing failed for input:', e.input);
|
|
1685
|
-
* console.error('RDKit message:', e.rdkitMessage);
|
|
1686
|
-
* } else {
|
|
1687
|
-
* console.error('Unexpected error:', e);
|
|
1688
|
-
* }
|
|
1689
|
-
* }
|
|
1690
|
-
* ```
|
|
1691
|
-
*/
|
|
1692
|
-
declare const isRDKitParseError: (error: unknown) => error is RDKitParseError;
|
|
1693
|
-
//#endregion
|
|
1694
|
-
export { type ColourPalette, type DrawColour, Fingerprint, type InitRDKitOptions, type JSMol, type JSReaction, type MCSResult, Mol, MolArray, type MolList, RDKit, type RDKitAlignedCoordsOptions, type RDKitAtomPairFPOptions, type RDKitConfigureOptions, type RDKitDepictionDetails, type RDKitDescriptors, type RDKitEvents, type RDKitFailCallback, type RDKitGetMCSOptions, type RDKitGetMolBlockOptions, type RDKitGetMolOpt, type RDKitGetMolOptions, type RDKitGetQMolOptions, type RDKitGetRgdOptions, type RDKitGetRxnOptions, type RDKitGetSmilesOptions, type RDKitJson, type RDKitJsonAtom, type RDKitJsonBond, type RDKitJsonConformer2D, type RDKitJsonConformer3D, type RDKitJsonExtension, type RDKitJsonMolecule, type RDKitMCSResult, type RDKitModule, type RDKitMorganFPOptions, RDKitParseError, type RDKitParseErrorEvent, type RDKitParseOperation, type RDKitPatternFPOptions, type RDKitRdkitFpOptions, type RDKitRemoveHsOptions, type RDKitRxnDetails, type RDKitStereoTags, type RDKitSubstructMatch, type RDKitTopologicalTorsionFPOptions, type RGDRow, Reaction, initRDKit, isRDKitParseError };
|
|
1960
|
+
export { type ColourPalette, type ColourPaletteName, type DrawColour, type DrawingExtentsInclude, Fingerprint, type InitRDKitOptions, type JSMol, type JSReaction, type MCSResult, type MMPAFragmentation, Mol, MolArray, type MolList, RDKit, type RDKitAlignedCoordsOptions, type RDKitAtomPairFPOptions, type RDKitConfigureOptions, type RDKitDepictionDetails, type RDKitDescriptors, type RDKitEvents, type RDKitFailCallback, type RDKitGetFragsOptions, type RDKitGetMCSOptions, type RDKitGetMolBlockOptions, type RDKitGetMolOpt, type RDKitGetMolOptions, type RDKitGetQMolOptions, type RDKitGetRgdOptions, type RDKitGetRxnOptions, type RDKitGetSmilesOptions, type RDKitJson, type RDKitJsonAtom, type RDKitJsonBond, type RDKitJsonConformer2D, type RDKitJsonConformer3D, type RDKitJsonExtension, type RDKitJsonMolecule, type RDKitMCSResult, type RDKitMmpaFragsOptions, type RDKitMmpaFragsResult, type RDKitModule, type RDKitMorganFPOptions, RDKitParseError, type RDKitParseErrorEvent, type RDKitParseOperation, type RDKitPatternFPOptions, type RDKitRdkitFpOptions, type RDKitRemoveHsOptions, type RDKitRxnDetails, type RDKitSanitizeFlags, type RDKitStereoTags, type RDKitSubstructMatch, type RDKitTopologicalTorsionFPOptions, type RGDRow, Reaction, type SimilarityMetric, type SubstructLibraryAddOptions, type SubstructLibraryEntry, type SubstructLibraryOptions, type SubstructLibrarySearchOptions, type SubstructLibrarySearchResult, SubstructLibraryWrapper, type TverskySimilarityOptions, initRDKit, isRDKitParseError };
|