rdkit-esm 0.4.2 → 0.4.3

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +215 -17
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -266,11 +266,60 @@ interface JSMol {
266
266
  */
267
267
  get_maccs_fp_as_uint8array(): Uint8Array;
268
268
 
269
+ /**
270
+ * Returns the Avalon fingerprint as string.
271
+ * Requires RDKit to be built with Avalon support (RDK_BUILD_AVALON_SUPPORT).
272
+ */
273
+ get_avalon_fp(): string;
274
+
275
+ /**
276
+ * Returns the Avalon fingerprint as string.
277
+ * Requires RDKit to be built with Avalon support (RDK_BUILD_AVALON_SUPPORT).
278
+ * @param options stringified JSON with fingerprint options (nBits, isQuery, bitFlags)
279
+ */
280
+ get_avalon_fp(options: JSONString): string;
281
+
282
+ /**
283
+ * Returns the Avalon fingerprint as an unsigned integer array.
284
+ * Requires RDKit to be built with Avalon support (RDK_BUILD_AVALON_SUPPORT).
285
+ */
286
+ get_avalon_fp_as_uint8array(): Uint8Array;
287
+
288
+ /**
289
+ * Returns the Avalon fingerprint as an unsigned integer array.
290
+ * Requires RDKit to be built with Avalon support (RDK_BUILD_AVALON_SUPPORT).
291
+ * @param options stringified JSON with fingerprint options (nBits, isQuery, bitFlags)
292
+ */
293
+ get_avalon_fp_as_uint8array(options: JSONString): Uint8Array;
294
+
269
295
  // abbreviation methods
270
296
 
271
297
  condense_abbreviations(): string;
272
298
  condense_abbreviations(maxCoverage: number, useLinkers: boolean): string;
273
299
 
300
+ /**
301
+ * Condense abbreviations using custom definitions.
302
+ *
303
+ * @param definitions Plain text string (NOT JSON). Each line defines one abbreviation as
304
+ * tab/space-separated columns:
305
+ * `label SMARTS [displayLabel [displayLabelW]]`
306
+ * - `label` — abbreviation identifier (e.g. `tBu`)
307
+ * - `SMARTS` — SMARTS pattern; first atom is the attachment point (e.g. `C(C)(C)C`)
308
+ * - `displayLabel` — label shown on the right side; may include HTML tags like `<sub>` (optional)
309
+ * - `displayLabelW` — label shown on the left/west side (optional)
310
+ * @example
311
+ * ```
312
+ * const defs = [
313
+ * "tBu C(C)(C)C tBu",
314
+ * "CF3 C(F)(F)F CF<sub>3</sub> F<sub>3</sub>C",
315
+ * ].join("\n");
316
+ * mol.condense_abbreviations_from_defs(defs, 0.4, false);
317
+ * ```
318
+ * @param maxCoverage maximum fraction of the molecule that can be covered by abbreviations
319
+ * @param areLinkers if true, definitions are treated as linker abbreviations (first atom must be a dummy `*`)
320
+ */
321
+ condense_abbreviations_from_defs(definitions: string, maxCoverage: number, areLinkers: boolean): string;
322
+
274
323
  // coord generation
275
324
 
276
325
  /**
@@ -285,7 +334,14 @@ interface JSMol {
285
334
 
286
335
  /** Returns true if the molecule's structure is valid */
287
336
  is_valid(): boolean;
337
+
338
+ /** Returns the total number of atoms in the molecule */
288
339
  get_num_atoms(): number;
340
+ /**
341
+ * Returns the number of atoms in the molecule
342
+ * @param heavyOnly if true, only heavy (non-hydrogen) atoms are counted
343
+ */
344
+ get_num_atoms(heavyOnly: boolean): number;
289
345
  get_num_bonds(): number;
290
346
 
291
347
  /** Check is the molecule has any 2D coordinates generated */
@@ -482,6 +538,29 @@ interface SubstructLibrary {
482
538
  */
483
539
  add_trusted_smiles(smi: string): number;
484
540
 
541
+ /**
542
+ * Add a molecule to the library with a pre-computed pattern fingerprint.
543
+ * Skips fingerprint computation — use when you already have the fingerprint.
544
+ *
545
+ * @param smi SMILES string (trusted to be valid)
546
+ * @param patternFp pre-computed pattern fingerprint as Uint8Array
547
+ */
548
+ add_trusted_smiles_and_pattern_fp(smi: string, patternFp: Uint8Array): number;
549
+
550
+ /**
551
+ * Get the stored SMILES string for a molecule in the library
552
+ *
553
+ * @param i index of the molecule
554
+ */
555
+ get_trusted_smiles(i: number): string;
556
+
557
+ /**
558
+ * Get the pattern fingerprint for a molecule in the library
559
+ *
560
+ * @param i index of the molecule
561
+ */
562
+ get_pattern_fp(i: number): Uint8Array;
563
+
485
564
  /**
486
565
  * Get a molecule from the library
487
566
  *
@@ -699,8 +778,8 @@ interface RDKitModule {
699
778
  * @param value
700
779
  */
701
780
  use_legacy_stereo_perception(value: boolean): void;
702
- enable_logging(): void;
703
- disable_logging(): void;
781
+ enable_logging(logName?: string): boolean;
782
+ disable_logging(logName?: string): boolean;
704
783
  /**
705
784
  * Create a JSLog handle object and log messages to its buffer and the browser console
706
785
  *
@@ -720,6 +799,7 @@ interface RDKitModule {
720
799
  */
721
800
 
722
801
  set_log_capture(logLevel: LogLevel): RDKitJSLog;
802
+ allow_non_tetrahedral_chirality: (allow: boolean) => boolean;
723
803
  }
724
804
  type LogLevel = 'rdApp.debug' | 'rdApp.info' | 'rdApp.warning' | 'rdApp.error' | 'rdApp.*';
725
805
  type RDKitJSLog = {
@@ -753,7 +833,7 @@ declare global {
753
833
 
754
834
  type RDKitDescriptorNames = 'exactmw' | 'amw' | 'lipinskiHBA' | 'lipinskiHBD' | 'NumRotatableBonds' | 'NumHBD' | 'NumHBA' | 'NumHeavyAtoms' | 'NumAtoms' | 'NumHeteroatoms' | 'NumAmideBonds' | 'FractionCSP3' | 'NumRings' | 'NumAromaticRings' | 'NumAliphaticRings' | 'NumSaturatedRings' | 'NumHeterocycles' | 'NumAromaticHeterocycles' | 'NumSaturatedHeterocycles' | 'NumAliphaticHeterocycles' | 'NumSpiroAtoms' | 'NumBridgeheadAtoms' | 'NumAtomStereoCenters' | 'NumUnspecifiedAtomStereoCenters' | 'labuteASA' | 'tpsa' | 'CrippenClogP' | 'CrippenMR' | 'chi0v' | 'chi1v' | 'chi2v' | 'chi3v' | 'chi4v' | 'chi0n' | 'chi1n' | 'chi2n' | 'chi3n' | 'chi4n' | 'hallKierAlpha' | 'kappa1' | 'kappa2' | 'kappa3' | 'Phi';
755
835
  type RDKitDescriptors = Record<RDKitDescriptorNames, number>;
756
- type RDKitAtom = {
836
+ type RDKitJsonAtom = {
757
837
  chg: number;
758
838
  /** Implicit Hydrogens count */
759
839
  impHs: number;
@@ -762,14 +842,14 @@ type RDKitAtom = {
762
842
  stereo: 'unspecified' | 'cw' | 'ccw' | 'other';
763
843
  z: number;
764
844
  };
765
- type RDKitBond = {
845
+ type RDKitJsonBond = {
766
846
  /** Bond order */
767
847
  bo: number;
768
848
  stereo: 'unspecified' | 'cis' | 'trans' | 'either';
769
849
  stereoAtoms: [number, number];
770
850
  atoms: [number, number];
771
851
  };
772
- type RDKitExtension = {
852
+ type RDKitJsonExtension = {
773
853
  aromaticAtoms?: number[];
774
854
  aromaticBonds?: number[];
775
855
  atomRings?: number[][];
@@ -779,102 +859,212 @@ type RDKitExtension = {
779
859
  name: 'rdkitRepresentation';
780
860
  toolkitVersion: string;
781
861
  };
782
- type RDKitConformer2D = {
862
+ type RDKitJsonConformer2D = {
783
863
  dim: 2;
784
864
  coords: [number, number][];
785
865
  };
786
- type RDKitConformer3D = {
866
+ type RDKitJsonConformer3D = {
787
867
  dim: 3;
788
868
  coords: [number, number, number][];
789
869
  };
790
- type RDKitMolecule = {
791
- atoms: Partial<RDKitAtom>[];
792
- bonds: (Partial<RDKitBond> & Pick<RDKitBond, 'atoms'>)[];
793
- conformers?: RDKitConformer2D[] | RDKitConformer3D[];
794
- extensions: RDKitExtension[];
870
+ type RDKitJsonMolecule = {
871
+ atoms: Partial<RDKitJsonAtom>[];
872
+ bonds: (Partial<RDKitJsonBond> & Pick<RDKitJsonBond, 'atoms'>)[];
873
+ conformers?: RDKitJsonConformer2D[] | RDKitJsonConformer3D[];
874
+ extensions: RDKitJsonExtension[];
795
875
  name: string;
796
876
  };
797
877
  type RDKitJson = {
798
878
  defaults: {
799
- atom: RDKitAtom;
800
- bond: RDKitBond;
879
+ atom: RDKitJsonAtom;
880
+ bond: RDKitJsonBond;
801
881
  };
802
- molecules: RDKitMolecule[];
882
+ molecules: RDKitJsonMolecule[];
803
883
  };
804
884
  type DrawColour = [number, number, number, number?];
805
885
  type ColourPalette = {
806
886
  [k: number]: DrawColour;
807
887
  };
808
888
  type RDKitDepictionDetails = {
889
+ /** Drawing width in pixels */
809
890
  width: number;
891
+ /** Drawing height in pixels */
810
892
  height: number;
893
+ /** X offset for drawing origin in pixels */
811
894
  offsetx: number;
895
+ /** Y offset for drawing origin in pixels */
812
896
  offsety: number;
897
+ /** Toggles replacing 2H with D and 3H with T */
813
898
  atomLabelDeuteriumTritium: boolean;
899
+ /** Draws "breaks" at dummy atoms */
814
900
  dummiesAreAttachments: boolean;
901
+ /** Draws circles under highlighted atoms */
815
902
  circleAtoms: boolean;
903
+ /** Split bonds into per-atom segments; most useful for dynamic manipulation of drawing, especially for SVG */
816
904
  splitBonds: boolean;
905
+ /** Default highlight color */
817
906
  highlightColour: DrawColour;
907
+ /** Highlight by drawing an outline *underneath* the molecule */
818
908
  continuousHighlight: boolean;
909
+ /** Fill the areas used to highlight atoms and atom regions */
819
910
  fillHighlights: boolean;
911
+ /** Default highlight radius if nothing given for a particular atom; units are Angstrom */
820
912
  highlightRadius: number;
913
+ /** If positive, used as a cutoff (in pixels) for highlighting close contacts */
821
914
  flagCloseContactsDist: number;
915
+ /** Toggles inclusion of atom tags in the output; does not make sense for all renderers */
822
916
  includeAtomTags: boolean;
917
+ /** Toggles clearing the background before drawing a molecule */
823
918
  clearBackground: boolean;
919
+ /** Color to be used while clearing the background */
824
920
  backgroundColour: DrawColour;
921
+ /** Color to be used for query bonds */
922
+ queryColour: DrawColour;
923
+ /** Font size (in pixels) to be used for the legend (if present) */
825
924
  legendFontSize: number;
925
+ /** Fraction of the draw panel to be used for the legend if present */
826
926
  legendFraction: number;
927
+ /** Maximum size in pixels for font in drawn molecule; -1 means no max */
827
928
  maxFontSize: number;
929
+ /** Minimum size in pixels for font in drawn molecule; -1 means no min */
828
930
  minFontSize: number;
931
+ /** Font size to use, in pixels; default -1 means not fixed. If set, always used irrespective of scale, minFontSize and maxFontSize */
829
932
  fixedFontSize: number;
933
+ /** Scales font relative to atom labels for atom and bond annotation */
830
934
  annotationFontScale: number;
935
+ /** Name of font file for freetype rendering; if given, over-rides default (BuiltinTelexRegular). Can also be BuiltinRobotoRegular */
831
936
  fontFile: string;
937
+ /** Color to be used for the legend (if present) */
832
938
  legendColour: DrawColour;
939
+ /** Offset for the extra lines in a multiple bond, as a fraction of mean bond length */
833
940
  multipleBondOffset: number;
941
+ /** Fraction of empty space to leave around the molecule */
834
942
  padding: number;
943
+ /** Fraction of empty space to leave around each component in a reaction drawing */
944
+ componentPadding: number;
945
+ /** Additional padding to leave around atom labels; expressed as a fraction of the font size */
835
946
  additionalAtomLabelPadding: number;
947
+ /** Replacement labels for atoms */
836
948
  atomLabels: Record<number, string>;
949
+ /** Disables inclusion of atom labels in the rendering */
837
950
  noAtomLabels: boolean;
951
+ /** Atom regions */
838
952
  atomRegions: number[][];
953
+ /** Color to be used for the symbols and arrows in reactions */
839
954
  symbolColour: DrawColour;
955
+ /** Color to be used for annotations */
840
956
  annotationColour: DrawColour;
957
+ /** Color to be used for atom indices and notes */
958
+ atomNoteColour: DrawColour;
959
+ /** Color to be used for bond indices and notes */
960
+ bondNoteColour: DrawColour;
961
+ /** Default line width when drawing bonds */
841
962
  bondLineWidth: number;
842
- scaleBondWidth: number;
963
+ /** Whether to apply scale() to the bond width */
964
+ scaleBondWidth: boolean;
965
+ /** Whether to apply scale() to bond highlight widths */
843
966
  scaleHighlightBondWidth: boolean;
967
+ /** Multiplier for standard bond width used for highlighting */
844
968
  highlightBondWidthMultiplier: number;
969
+ /** Call prepareMolForDrawing() on each molecule passed to drawMolecules() */
845
970
  prepareMolsBeforeDrawing: boolean;
971
+ /** Defines 10 default colors for highlighting atoms and bonds or reactants in reactions */
846
972
  highlightColourPalette: DrawColour[];
973
+ /** The palette used to assign colors to atoms based on atomic number */
847
974
  atomColourPalette: ColourPalette;
975
+ /** Fixes scale to this fraction of draw window width so an average bond is this fraction of the width; -1.0 means no fix */
848
976
  fixedScale: number;
977
+ /** 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 */
849
978
  fixedBondLength: number;
979
+ /** Angle in degrees to rotate coords by about centre before drawing */
850
980
  rotate: number;
981
+ /** Adds atom indices to drawings */
851
982
  addAtomIndices: boolean;
983
+ /** Adds bond indices to drawings */
852
984
  addBondIndices: boolean;
985
+ /** Adds isotope labels to non-dummy atoms */
853
986
  isotopeLabels: boolean;
987
+ /** Adds isotope labels to dummy atoms */
854
988
  dummyIsotopeLabels: boolean;
989
+ /** Adds E/Z and R/S stereo annotations to drawings */
855
990
  addStereoAnnotation: boolean;
991
+ /** Show CIP codes for 'or' and 'and' StereoGroups that are normally hidden */
992
+ showAllCIPCodes: boolean;
993
+ /** Forces atom highlights always to be circles; default (false) puts ellipses round longer labels */
856
994
  atomHighlightsAreCircles: boolean;
995
+ /** Highlight style for multi-colour highlights */
996
+ multiColourHighlightStyle: 'CIRCLEANDLINE' | 'LASSO';
997
+ /** Moves the centre of the drawn molecule to (0,0) */
857
998
  centreMoleculesBeforeDrawing: boolean;
999
+ /** Which elements should be included when computing drawing extents; bitmask of DrawElement flags (PRESHAPES=1, BONDS=2, ATOMLABELS=4, HIGHLIGHTS=8, ANNOTATIONS=16, RADICALS=32, POSTSHAPES=64, ALL=0x7fffffff) */
1000
+ drawingExtentsInclude: number;
1001
+ /** Draw terminal methyl and related groups as CH3 */
858
1002
  explicitMethyl: boolean;
1003
+ /** Include radicals in the drawing; can be useful to turn off for reactions and queries */
859
1004
  includeRadicals: boolean;
1005
+ /** When possible, include metadata about molecules and reactions in the output to allow them to be reconstructed */
860
1006
  includeMetadata: boolean;
1007
+ /** Simulate hand-drawn lines for bonds; when combined with a font like Comic-Sans or Comic-Neue, gives xkcd-like drawings */
861
1008
  comicMode: boolean;
1009
+ /** Multiplier for standard bond width used for variable attachment points */
862
1010
  variableBondWidthMultiplier: number;
1011
+ /** Radius value to use for atoms involved in variable attachment points */
863
1012
  variableAtomRadius: number;
1013
+ /** Colour to use for variable attachment points */
864
1014
  variableAttachmentColour: DrawColour;
1015
+ /** Add a molecule annotation with "ABS" if the chiral flag is set */
865
1016
  includeChiralFlagLabel: boolean;
1017
+ /** If all specified stereocenters are in a single StereoGroup, show a molecule-level annotation instead of the individual labels */
866
1018
  simplifiedStereoGroupLabel: boolean;
1019
+ /** If true, double bonds with unspecified stereo are drawn crossed; potential stereocenters with unspecified stereo are drawn with a wavy bond */
867
1020
  unspecifiedStereoIsUnknown: boolean;
1021
+ /** If true, wedged and dashed bonds are drawn using symbolColour rather than inheriting their colour from the atoms */
868
1022
  singleColourWedgeBonds: boolean;
1023
+ /** If the molecule came from a MolBlock, prefer the wedging information it provides; if false, use RDKit rules */
869
1024
  useMolBlockWedging: boolean;
1025
+ /** Scaling factor used for pixels-to-angstrom conversion when auto scaling is being used */
870
1026
  scalingFactor: number;
1027
+ /** When > 0, sets the baseFontSize for text drawing; reference: default DrawText::baseFontSize is 0.6 */
871
1028
  baseFontSize: number;
1029
+ /** When drawing multiple molecules with DrawMolecules, forces them to use the same scale */
872
1030
  drawMolsSameScale: boolean;
1031
+ /** Replace any-atom, any-hetero, any-halo queries with complex query symbols A, Q, X, M, optionally followed by H if hydrogen is included (except for AH, which stays *) */
1032
+ useComplexQueryAtomSymbols: boolean;
1033
+ /** If true, puts brackets round atom lists in query atoms */
1034
+ bracketsAroundAtomLists: boolean;
1035
+ /** Atom indices to highlight */
873
1036
  atoms: number[];
1037
+ /** Bond indices to highlight */
874
1038
  bonds: number[];
1039
+ /** Per-atom highlight colors, keyed by atom index */
875
1040
  highlightAtomColors: Record<number, DrawColour>;
1041
+ /** Per-bond highlight colors, keyed by bond index */
876
1042
  highlightBondColors: Record<number, DrawColour>;
1043
+ /** If true, highlighted hetero atoms are drawn in standard colours rather than black */
877
1044
  standardColoursForHighlightedAtoms: boolean;
1045
+ // Drawing call parameters (parsed from the details JSON by common.h, not part of MolDrawOptions)
1046
+ /** Caption text to display below the molecule (distinct from legendFontSize/legendColour which control its appearance) */
1047
+ legend: string;
1048
+ /** Panel width in pixels for multi-panel or grid drawings */
1049
+ panelWidth: number;
1050
+ /** Panel height in pixels for multi-panel or grid drawings */
1051
+ panelHeight: number;
1052
+ /** Disable freetype font rendering and use the built-in font instead */
1053
+ noFreetype: boolean;
1054
+ /** Pre-kekulize the molecule before drawing */
1055
+ kekulize: boolean;
1056
+ /** Add chiral hydrogen atoms before drawing */
1057
+ addChiralHs: boolean;
1058
+ /** Control bond wedging in the drawing */
1059
+ wedgeBonds: boolean;
1060
+ /** Force use of existing coordinates rather than generating new ones */
1061
+ forceCoords: boolean;
1062
+ /** Draw wavy bonds for double bonds with unspecified stereo */
1063
+ wavyBonds: boolean;
1064
+ /** Return atom drawing coordinates in the output JSON
1065
+ * IMPORTANT: this changes the output format in the case of get_svg...()
1066
+ */
1067
+ returnDrawCoords: boolean;
878
1068
  };
879
1069
  type RDKitRxnDepictionDetails = RDKitDepictionDetails & {
880
1070
  highlightByReactant: boolean;
@@ -905,6 +1095,14 @@ type RDKitGetMolOpt = {
905
1095
  removeHs: boolean;
906
1096
  assignStereo: boolean;
907
1097
  mergeQueryHs: boolean;
1098
+ /** Assign chiral types from molfile parity flags */
1099
+ assignChiralTypesFromMolParity: boolean;
1100
+ /** Convert mapped dummy atoms to query atoms */
1101
+ makeDummiesQueries: boolean;
1102
+ /** Apply strict parsing rules to CXSMILES input */
1103
+ strictCXSMILES: boolean;
1104
+ /** Apply strict parsing rules to Molfile input */
1105
+ strictParsing: boolean;
908
1106
  };
909
1107
  type RDKitGetMolBlockOptions = {
910
1108
  /** @default true */
@@ -1641,4 +1839,4 @@ interface InitRDKitOptions {
1641
1839
  declare function initRDKit(options?: Partial<InitRDKitOptions>): Promise<RDKit>;
1642
1840
  declare function initRDKit<T extends typeof RDKit>(options: Partial<InitRDKitOptions> | undefined, constructor: T): Promise<InstanceType<T>>;
1643
1841
  //#endregion
1644
- export { Fingerprint, type InitRDKitOptions, type JSMol, type JSReaction, type MCSResult, Mol, MolArray, type MolList, RDKit, type RDKitAlignedCoordsOptions, type RDKitAtomPairFPOptions, type RDKitDepictionDetails, type RDKitDescriptors, type RDKitGetMCSOptions, type RDKitGetMolBlockOptions, type RDKitGetMolOpt, type RDKitGetRgdOptions, type RDKitGetSmilesOptions, type RDKitJson, type RDKitMCSResult, type RDKitModule, type RDKitMorganFPOptions, type RDKitPatternFPOptions, type RDKitRdkitFpOptions, type RDKitRemoveHsOptions, type RDKitRxnDetails, type RDKitStereoTags, type RDKitSubstructMatch, type RDKitTopologicalTorsionFPOptions, type RGDRow, Reaction, initRDKit };
1842
+ export { type ColourPalette, type DrawColour, Fingerprint, type InitRDKitOptions, type JSMol, type JSReaction, type MCSResult, Mol, MolArray, type MolList, RDKit, type RDKitAlignedCoordsOptions, type RDKitAtomPairFPOptions, type RDKitDepictionDetails, type RDKitDescriptors, type RDKitGetMCSOptions, type RDKitGetMolBlockOptions, type RDKitGetMolOpt, type RDKitGetRgdOptions, type RDKitGetSmilesOptions, type RDKitJson, type RDKitJsonAtom, type RDKitJsonBond, type RDKitJsonConformer2D, type RDKitJsonConformer3D, type RDKitJsonExtension, type RDKitJsonMolecule, type RDKitMCSResult, type RDKitModule, type RDKitMorganFPOptions, type RDKitPatternFPOptions, type RDKitRdkitFpOptions, type RDKitRemoveHsOptions, type RDKitRxnDetails, type RDKitStereoTags, type RDKitSubstructMatch, type RDKitTopologicalTorsionFPOptions, type RGDRow, Reaction, initRDKit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdkit-esm",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "RDKit minimal lib for the modern web.",
5
5
  "homepage": "https://github.com/tandemai/rdkit-esm#readme",
6
6
  "bugs": {