nmr-processing 19.0.3 → 19.2.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.
@@ -41,7 +41,6 @@ import type { ForwardLP1DOptions } from '@zakodium/nmr-types';
41
41
  import type { ForwardLPOptions } from '@zakodium/nmr-types';
42
42
  import { FromTo } from 'cheminfo-types';
43
43
  import type { GaussianOptions } from '@zakodium/nmr-types';
44
- import { GeneralAssignment as GeneralAssignment_2 } from './utils/generalAssignment/buildAssignments.js';
45
44
  import type { GenerateSpectrumOptions } from 'spectrum-generator';
46
45
  import type { GroupedDiaID } from 'openchemlib-utils';
47
46
  import type { GSDOptions } from 'ml-gsd';
@@ -57,7 +56,6 @@ import type { JoinBroadPeaksOptions } from 'ml-gsd';
57
56
  import type { LevenbergMarquardtOptions } from 'ml-levenberg-marquardt';
58
57
  import type { LightLogger } from 'cheminfo-types';
59
58
  import type { Logger } from 'cheminfo-types';
60
- import { MatchingMultiplicity as MatchingMultiplicity_2 } from '../index.ts';
61
59
  import { Matrix } from 'ml-matrix';
62
60
  import type { MatrixOptions } from '@zakodium/nmr-types';
63
61
  import type { Molecule } from 'openchemlib';
@@ -68,13 +66,9 @@ import type { NmrData2DFt } from 'cheminfo-types';
68
66
  import type { NMRPeak1D } from '@zakodium/nmr-types';
69
67
  import { NMRRange } from '@zakodium/nmr-types';
70
68
  import type { NMRSignal1D } from '@zakodium/nmr-types';
71
- import { NMRZoneWithID as NMRZoneWithID_2 } from './xyzAutoZonesPicking.ts';
72
69
  import type { NumberArray } from 'cheminfo-types';
73
70
  import type { NUSDimension2Options } from '@zakodium/nmr-types';
74
71
  import type { OCLMolecule } from 'cheminfo-types';
75
- import { OneDimensionalAssignment as OneDimensionalAssignment_2 } from './utils/oneDimensionalAssignment/buildAssignments.js';
76
- import { OneDimensionalAssignment as OneDimensionalAssignment_3 } from '../index.js';
77
- import { OneLetterMultiplet as OneLetterMultiplet_2 } from './MultiplicityPatterns.js';
78
72
  import type { OptimizePeaksOptions } from 'ml-gsd';
79
73
  import type { OptionsSG1D } from 'spectrum-generator';
80
74
  import type { Peak1D } from '@zakodium/nmr-types';
@@ -100,7 +94,6 @@ import type { SineBellOptions } from '@zakodium/nmr-types';
100
94
  import type { SymmetrizeCosyLikeOptions } from '@zakodium/nmr-types';
101
95
  import type { TopicMolecule } from 'openchemlib-utils';
102
96
  import type { TrafOptions } from '@zakodium/nmr-types';
103
- import type { XDistributionStats } from 'ml-spectra-processing';
104
97
  import type { XRobustDistributionStats } from 'ml-spectra-processing';
105
98
  import type { XYNumber } from 'spectrum-generator';
106
99
  import type { ZeroFillingDimension1Options } from '@zakodium/nmr-types';
@@ -120,8 +113,8 @@ declare type ApodizationDimension2 = FilterFactory<Entry2D, Apodization2D2Option
120
113
 
121
114
  export declare function apodizationXReIm(data: Required<NmrData1D>, options: Apodization1DOptions): {
122
115
  x: Float64Array<ArrayBufferLike>;
123
- re: Float64Array<ArrayBufferLike>;
124
- im: Float64Array<ArrayBufferLike>;
116
+ re: Float64Array<ArrayBuffer>;
117
+ im: Float64Array<ArrayBuffer>;
125
118
  };
126
119
 
127
120
  /**
@@ -129,7 +122,7 @@ export declare function apodizationXReIm(data: Required<NmrData1D>, options: Apo
129
122
  * @param data
130
123
  * @param options
131
124
  */
132
- export declare function apodize(data: DoubleArray, options: ApplyWindowOptions): Float64Array<ArrayBufferLike>;
125
+ export declare function apodize(data: DoubleArray, options: ApplyWindowOptions): Float64Array<ArrayBuffer>;
133
126
 
134
127
  declare function applyFilter(datum: Entry1D, filter: Filter1DOptions, logger?: Logger): void;
135
128
 
@@ -309,6 +302,21 @@ export declare interface CalculateDiffussionCoefficientOptions {
309
302
  timeCorrection: number;
310
303
  }
311
304
 
305
+ /**
306
+ * Calculates the frequencies (in MHz) for a pair of nuclei based on the observed spectrometer frequency.
307
+ *
308
+ * - The first element of the `nucleus` array is the observed nucleus.
309
+ * - The second element is the indirect nucleus.
310
+ * - Returns an array: [frequency of observed nucleus, frequency of indirect nucleus].
311
+ *
312
+ * @param nucleus - Array of two nuclei (e.g., ['1H', '13C']).
313
+ * - The first element is the observed nucleus.
314
+ * - The second element is the indirect nucleus.
315
+ * @param frequency - The spectrometer frequency (in MHz) of the observed nucleus (first element of the nucleus array).
316
+ * @returns Array of frequencies in MHz: [frequency of observed nucleus, frequency of indirect nucleus].
317
+ */
318
+ export declare function calculateRelativeFrequency(nucleus: string[], frequency: number): number[];
319
+
312
320
  declare interface CalculateT1Options {
313
321
  optimization?: CalculateT1OptionsOptimization;
314
322
  }
@@ -365,7 +373,7 @@ declare interface CouplingInput {
365
373
  s: [ID, ID];
366
374
  }
367
375
 
368
- export declare const couplingPatterns: OneLetterMultiplet_2[];
376
+ export declare const couplingPatterns: OneLetterMultiplet[];
369
377
 
370
378
  export declare function createApodizationWindowData(options: {
371
379
  windowOptions: {
@@ -452,10 +460,6 @@ declare interface CTSignal {
452
460
  atoms: number[];
453
461
  }
454
462
 
455
- export declare type DataBaseLevelEntry = number | [number] | [number, number, number, number | null, number] | undefined | XDistributionStats;
456
-
457
- export declare type DataBaseLevelStructure = Record<string, DataBaseLevelEntry>;
458
-
459
463
  export declare interface DatabaseNMREntry {
460
464
  id: string;
461
465
  ocl?: OCLMolecule;
@@ -469,8 +473,6 @@ export declare interface DatabaseNMREntry {
469
473
  signals?: NMRSignal1D[];
470
474
  }
471
475
 
472
- export declare type DataBaseStructure = DataBaseLevelStructure[];
473
-
474
476
  export declare interface DataResurrect {
475
477
  info: {
476
478
  solvent?: string;
@@ -686,7 +688,7 @@ declare type FilterSymbols = (typeof Filters)[keyof typeof Filters];
686
688
  * Look for a multiplet based on the pattern name or abbreviation.
687
689
  * @param name - pattern name or abbreviation.
688
690
  */
689
- export declare function findMultiplet(name: string): MatchingMultiplicity_2 | undefined;
691
+ export declare function findMultiplet(name: string): MatchingMultiplicity | undefined;
690
692
 
691
693
  /**
692
694
  * Finds a peak that can serve as a pivot point within specified boundaries.
@@ -715,9 +717,41 @@ export declare interface GeneralAssignment {
715
717
  assignment: SpectraDataWithIds[];
716
718
  }
717
719
 
718
- export declare function get13CAssignments(ranges: NMRRange[], molecule: Molecule, options?: Get13CAssignmentsOptions): Promise<OneDimensionalAssignment_3[]>;
720
+ /**
721
+ * Generate possible 13C assignments for the provided 1D ranges using
722
+ * predicted carbon shifts for the given molecule. It is based on the paper
723
+ * Fully automatic assignment of small molecules' NMR spectra without relying
724
+ * on chemical shift predictions {@link https://doi.org/10.1002/mrc.4272}
725
+ *
726
+ * The function:
727
+ * - Predicts 13C spectra for the provided molecule.
728
+ * - Ensures signals include atoms, diaIDs and nbAtoms (throws otherwise).
729
+ * - Normalizes range integrations (missing integration values become 0).
730
+ * - Builds assignments using buildAssignments and the provided options.
731
+ *
732
+ * @param ranges - Array of NMR ranges to assign. Missing integration values are set to 0.
733
+ * @param molecule - openchemlib Molecule used for shift prediction.
734
+ * @param {Get13CAssignmentsOptions} options - to control assignment behavior.
735
+ * @returns Promise resolving to the assignment results produced by buildAssignments.
736
+ *
737
+ * @throws If predicted signals do not include required atoms/diaIDs/nbAtoms properties.
738
+ */
739
+ export declare function get13CAssignments(ranges: NMRRange[], molecule: Molecule, options?: Get13CAssignmentsOptions): Promise<OneDimensionalAssignment[]>;
719
740
 
741
+ /**
742
+ * Options for get13CAssignments.
743
+ *
744
+ * restrictionByCS: Partial restrictions applied to chemical-shift matching when building assignments.
745
+ * minScore: Minimum score to accept an assignment (default: 1).
746
+ * maxSolutions: Maximum number of assignment solutions to return (default: 10).
747
+ * nbAllowedUnAssigned: Number of allowed unassigned signals in a solution (default: 0).
748
+ * timeout: Time limit in milliseconds to finish the assignment procedure (default: 6000).
749
+ * predictionOptions: Options forwarded to the carbon prediction routine.
750
+ */
720
751
  export declare interface Get13CAssignmentsOptions {
752
+ /**
753
+ * Partial restrictions applied to chemical-shift matching.
754
+ */
721
755
  restrictionByCS?: Partial<RestrictionByCS1D>;
722
756
  /**
723
757
  * min score to accept an assignment
@@ -740,14 +774,33 @@ export declare interface Get13CAssignmentsOptions {
740
774
  */
741
775
  timeout?: number;
742
776
  /**
743
- * prediction options
777
+ * prediction options forwarded to the carbon prediction.
744
778
  */
745
779
  predictionOptions?: PredictCarbonOptions;
746
780
  }
747
781
 
748
782
  export declare function get1DErrorFactor(spectrum: Entry1D): number;
749
783
 
750
- export declare function get1HAssignments(ranges: NMRRange[], molecule: Molecule, options?: Get1HAssignmentsOptions): Promise<OneDimensionalAssignment_2[]>;
784
+ /**
785
+ * Generate possible 1H assignments for the provided 1D ranges using
786
+ * predicted proton shifts and integration values for the given molecule. It is based on the paper
787
+ * Fully automatic assignment of small molecules' NMR spectra without relying
788
+ * on chemical shift predictions {@link https://doi.org/10.1002/mrc.4272}
789
+ *
790
+ * The function:
791
+ * - Predicts 1H spectra for the provided molecule.
792
+ * - Ensures signals include atoms, diaIDs and nbAtoms (throws otherwise).
793
+ * - Normalizes range integrations (missing integration values become 0).
794
+ * - Builds assignments using buildAssignments and the provided options.
795
+ *
796
+ * @param ranges - Array of NMR ranges to assign. Missing integration values are set to 0.
797
+ * @param molecule - openchemlib Molecule used for shift prediction.
798
+ * @param {Get1HAssignmentsOptions} options - to control assignment behavior.
799
+ * @returns Promise resolving to the assignment results produced by buildAssignments.
800
+ *
801
+ * @throws If predicted signals do not include required atoms/diaIDs/nbAtoms properties.
802
+ */
803
+ export declare function get1HAssignments(ranges: NMRRange[], molecule: Molecule, options?: Get1HAssignmentsOptions): Promise<OneDimensionalAssignment[]>;
751
804
 
752
805
  export declare interface Get1HAssignmentsOptions {
753
806
  restrictionByCS?: Partial<RestrictionByCS1D>;
@@ -779,7 +832,7 @@ export declare interface Get1HAssignmentsOptions {
779
832
 
780
833
  export declare function get2DErrorFactor(spectrum: Entry2D): Zone2DError;
781
834
 
782
- export declare function getAssignments(input: GetAutoAssignmentInput, options?: GetAssignmentsOptions): Promise<GeneralAssignment_2[]>;
835
+ export declare function getAssignments(input: GetAutoAssignmentInput, options?: GetAssignmentsOptions): Promise<GeneralAssignment[]>;
783
836
 
784
837
  export declare interface GetAssignmentsOptions {
785
838
  justAssign?: AtomTypes[][];
@@ -891,15 +944,9 @@ export declare function getDatabase(url?: string, options?: {
891
944
  declare function getDiaIDs(range: Range): string[];
892
945
 
893
946
  /**
894
- * calculate the frequency of a nucleus with respect to a reference nucleus
895
- * @param nucleus
896
- * @param observedNucleusData
897
- */
898
- export declare function getFrequency(
899
- /**
900
- * nucleus to calculate the frequency
947
+ * @deprecated use getRelativeFrequency instead
901
948
  */
902
- nucleus: string, observedNucleusData: ObservedNucleusData): number;
949
+ export declare const getFrequency: typeof getRelativeFrequency;
903
950
 
904
951
  declare interface GetKernelOptions {
905
952
  sigma?: number;
@@ -917,6 +964,7 @@ export declare function getPeakDelta(peak: Peak1D | NMRPeak1D, shiftTarget: Shif
917
964
  };
918
965
 
919
966
  export declare interface GetPeakListOptions extends GSDOptions, OptimizePeaksOptions, JoinBroadPeaksOptions {
967
+ smoothedY: NumberArray;
920
968
  /**
921
969
  * If it is true, the peaks parameters will be optimized.
922
970
  * @default false
@@ -935,6 +983,17 @@ export declare interface GetPeakListOptions extends GSDOptions, OptimizePeaksOpt
935
983
 
936
984
  declare function getPopulations(p: PopulationInput[]): PopulationOutput[];
937
985
 
986
+ /**
987
+ * calculate the frequency of a nucleus with respect to a reference nucleus
988
+ * @param nucleus
989
+ * @param observedNucleusData
990
+ */
991
+ export declare function getRelativeFrequency(
992
+ /**
993
+ * nucleus to calculate the frequency
994
+ */
995
+ nucleus: string, observedNucleusData: ObservedNucleusData): number;
996
+
938
997
  declare function getShiftGroups(sg: ShiftGroupEntry[]): {
939
998
  id: string;
940
999
  parentID: string;
@@ -1456,6 +1515,13 @@ export declare interface OptionsXYAutoPeaksPicking extends Partial<GetPeakListOp
1456
1515
  * frequency used to convert width and fwhm to Hz
1457
1516
  */
1458
1517
  frequency: number;
1518
+ /**
1519
+ * Controls the degree of baseline smoothing applied to the data before peak picking.
1520
+ * Higher values (closer to 100) mean less smoothing, while lower values (closer to 1) increase smoothing.
1521
+ * Useful for reducing noise and improving peak detection in spectra with varying baseline quality.
1522
+ * @default 100
1523
+ */
1524
+ sensitivity?: number;
1459
1525
  }
1460
1526
 
1461
1527
  declare interface OptionsXYAutoRangesPicking {
@@ -1629,21 +1695,15 @@ declare interface PredictAllSpectraOptions {
1629
1695
 
1630
1696
  export declare interface PredictCarbonOptions {
1631
1697
  /**
1632
- * Custom database. Each entry in the levels should have
1633
- * an array as value [median] or [median, mean, sd, min, max, nb] for statistic purpose.
1634
- */
1635
- database?: DataBaseStructure;
1636
- /**
1637
- * Max level to take into account in the query. If is not specified
1638
- * the max level in the database will be used.
1639
- * @default 'maximum level in the database'
1640
- */
1641
- maxSphereSize?: number;
1642
- /**
1643
- * Predictor function that will use by default: 'https://nmr-prediction.service.zakodium.com/v1/predict/carbon'
1698
+ * Predictor function. Will use by default webservice: https://nmr-prediction.service.zakodium.com/v1/predict/carbon
1644
1699
  * @default defaultCarbonPredictor
1645
1700
  */
1646
1701
  predictor?: PredictorFn;
1702
+ /**
1703
+ * Options to pass to the predictor function.
1704
+ * @default {}
1705
+ */
1706
+ predictorOptions?: Record<string, unknown>;
1647
1707
  /**
1648
1708
  * Prediction cache handler.
1649
1709
  */
@@ -1855,7 +1915,7 @@ export declare interface PredictionOptionsByExperiment {
1855
1915
  /**
1856
1916
  * A function that should make a prediction for the given molecule and return the result.
1857
1917
  */
1858
- declare type PredictorFn = (topicMolecule: TopicMolecule) => Promise<PredictionBase1D> | PredictionBase1D;
1918
+ declare type PredictorFn = (topicMolecule: TopicMolecule, options?: Record<string, unknown>) => Promise<PredictionBase1D> | PredictionBase1D;
1859
1919
 
1860
1920
  export declare interface PredictProtonOptions {
1861
1921
  /**
@@ -1863,6 +1923,11 @@ export declare interface PredictProtonOptions {
1863
1923
  * @default defaultProtonPredictor
1864
1924
  */
1865
1925
  predictor?: PredictorFn;
1926
+ /**
1927
+ * Options to pass to the predictor function.
1928
+ * @default {}
1929
+ */
1930
+ predictorOptions?: Record<string, unknown>;
1866
1931
  /**
1867
1932
  * Prediction cache handler.
1868
1933
  */
@@ -1871,7 +1936,7 @@ export declare interface PredictProtonOptions {
1871
1936
 
1872
1937
  export declare function predictSpectra(molecule: Molecule, options?: PredictAllSpectraOptions): Promise<PredictSpectraResult>;
1873
1938
 
1874
- declare interface PredictSpectraResult {
1939
+ export declare interface PredictSpectraResult {
1875
1940
  spectra: Array<PredictedSpectrum1D | PredictedSpectrum2D>;
1876
1941
  molecules: Array<{
1877
1942
  molfile: string;
@@ -1908,37 +1973,67 @@ export declare function rangesToACS(ranges: NMRRange[], options?: RangesToACSOpt
1908
1973
 
1909
1974
  export declare interface RangesToACSOptions {
1910
1975
  /**
1911
- * nucleus
1976
+ * Nucleus type for the NMR experiment (e.g., '1H', '13C', '19F').
1977
+ * Determines default formatting and frequency values.
1912
1978
  * @default '1H'
1913
1979
  */
1914
1980
  nucleus?: string;
1915
1981
  /**
1916
- * Sort the chemical shift values in ascending order
1982
+ * If true, sorts the chemical shift values in ascending order (low to high ppm).
1983
+ * If false, sorts in descending order (high to low ppm).
1917
1984
  * @default false
1918
1985
  */
1919
1986
  ascending?: boolean;
1987
+ /**
1988
+ * Specifies which types of information to include for each range or signal in the ACS string output.
1989
+ * Each character in the string represents a data type:
1990
+ *
1991
+ * - 'I': Integral value (e.g., number of protons or integration value)
1992
+ * - 'M': Multiplicity (e.g., singlet, doublet, triplet)
1993
+ * - 'J': Coupling constants (J values in Hz)
1994
+ * - 'A': Assignment (atom or group assignment)
1995
+ *
1996
+ * The order of characters determines the order of information in the output. Any combination or subset is allowed, e.g.:
1997
+ * 'IMJ' (integral, multiplicity, coupling constants)
1998
+ * 'MA' (multiplicity, assignment)
1999
+ * 'I' (only integral)
2000
+ *
2001
+ * Example: 'IMJA' includes all available information in the order: Integral, Multiplicity, Assignment, Coupling constants.
2002
+ *
2003
+ * @default 'IMJA'
2004
+ */
1920
2005
  format?: string;
1921
2006
  /**
1922
- * default value depends of nucleus
1923
- * @default '0.00'
2007
+ * Format string for chemical shift (delta) values, using [numeral.js](https://numeraljs.com/) syntax.
2008
+ * The default value depends on the nucleus type:
2009
+ * - '1H' and '19F': '0.00'
2010
+ * - '13C': '0.0'
2011
+ * @default '0.00' for '1H' and '19F', '0.0' for '13C'
1924
2012
  */
1925
2013
  deltaFormat?: string;
1926
2014
  /**
1927
- * Number of decimals to round the scalar coupling value
2015
+ * Format string for scalar coupling constants (J values), using [numeral.js](https://numeraljs.com/) syntax.
2016
+ * Controls the number of decimals for J values in Hz.
1928
2017
  * @default '0.0'
1929
2018
  */
1930
2019
  couplingFormat?: string;
1931
2020
  /**
1932
- * default value depends of nucleus
1933
- * @default 400|100
2021
+ * Observed frequency of the NMR experiment in MHz.
2022
+ * The default value depends on the nucleus type:
2023
+ * - '1H' and '19F': 400
2024
+ * - '13C': 100
2025
+ * @default 400 for '1H' and '19F', 100 for '13C'
1934
2026
  */
1935
2027
  observedFrequency?: number;
1936
2028
  /**
2029
+ * If true, filters out ranges or signals with kind 'impurity' or 'solvent'.
2030
+ * If false, includes all ranges and signals.
1937
2031
  * @default true
1938
2032
  */
1939
2033
  filter?: boolean;
1940
2034
  /**
1941
- * solvent name
2035
+ * Name of the solvent used in the NMR experiment (e.g., 'CDCl3', 'DMSO').
2036
+ * If provided, it will be included in the ACS string output.
1942
2037
  */
1943
2038
  solvent?: string;
1944
2039
  }
@@ -1946,7 +2041,7 @@ export declare interface RangesToACSOptions {
1946
2041
  export declare function rangesToTSV(ranges: NMRRange[]): string;
1947
2042
 
1948
2043
  export declare function rangesToXY(ranges: NMRRange[], options?: RangesToXYOptions): {
1949
- x: Float64Array<ArrayBufferLike>;
2044
+ x: Float64Array<ArrayBuffer>;
1950
2045
  y: Float64Array<ArrayBuffer>;
1951
2046
  };
1952
2047
 
@@ -2171,7 +2266,7 @@ export declare function signals2DToZ(signals: NMRSignal2D[], options?: Signals2D
2171
2266
  maxY: number;
2172
2267
  minZ: number;
2173
2268
  maxZ: number;
2174
- z: Float64Array<ArrayBufferLike>[];
2269
+ z: Float64Array<ArrayBuffer>[];
2175
2270
  };
2176
2271
 
2177
2272
  declare interface Signals2DToZOptions {
@@ -2488,10 +2583,28 @@ declare interface Traf<ShapeOption = TrafOptions> {
2488
2583
  */
2489
2584
  export declare function translateMultiplet(name: string): string;
2490
2585
 
2586
+ /**
2587
+ * Options for specifying the region and resolution of the 2D spectrum
2588
+ */
2491
2589
  declare interface TwoDOptions {
2492
- from: PointXY;
2493
- to: PointXY;
2590
+ /**
2591
+ * Defines the chemical shift range for proton and carbon axes
2592
+ */
2593
+ fromTo: {
2594
+ proton: FromTo;
2595
+ carbon: FromTo;
2596
+ };
2597
+ /**
2598
+ * Number of points in each dimension (x and y)
2599
+ */
2494
2600
  nbPoints: PointXY;
2601
+ /**
2602
+ * Optional peak width in each dimension (x and y), in Hz
2603
+ */
2604
+ width?: {
2605
+ x: number;
2606
+ y: number;
2607
+ };
2495
2608
  }
2496
2609
 
2497
2610
  declare function unlink(range: Range, options?: UnlinkOptions): Range;
@@ -2753,7 +2866,7 @@ declare function unlink(range: Range, options?: UnlinkOptions): Range;
2753
2866
  kernel?: GetKernelOptions;
2754
2867
  }
2755
2868
 
2756
- export declare function xyzJResAnalyzer(signals: NMRSignal2D[], options?: XYZJResAnalyzerOptions): NMRZoneWithID_2[] | (NMRSignal2D<Peak2D> & {
2869
+ export declare function xyzJResAnalyzer(signals: NMRSignal2D[], options?: XYZJResAnalyzerOptions): NMRZoneWithID[] | (NMRSignal2D<Peak2D> & {
2757
2870
  id: string;
2758
2871
  })[];
2759
2872