nmr-processing 19.1.0 → 19.3.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';
@@ -380,7 +373,7 @@ declare interface CouplingInput {
380
373
  s: [ID, ID];
381
374
  }
382
375
 
383
- export declare const couplingPatterns: OneLetterMultiplet_2[];
376
+ export declare const couplingPatterns: OneLetterMultiplet[];
384
377
 
385
378
  export declare function createApodizationWindowData(options: {
386
379
  windowOptions: {
@@ -467,10 +460,6 @@ declare interface CTSignal {
467
460
  atoms: number[];
468
461
  }
469
462
 
470
- export declare type DataBaseLevelEntry = number | [number] | [number, number, number, number | null, number] | undefined | XDistributionStats;
471
-
472
- export declare type DataBaseLevelStructure = Record<string, DataBaseLevelEntry>;
473
-
474
463
  export declare interface DatabaseNMREntry {
475
464
  id: string;
476
465
  ocl?: OCLMolecule;
@@ -484,8 +473,6 @@ export declare interface DatabaseNMREntry {
484
473
  signals?: NMRSignal1D[];
485
474
  }
486
475
 
487
- export declare type DataBaseStructure = DataBaseLevelStructure[];
488
-
489
476
  export declare interface DataResurrect {
490
477
  info: {
491
478
  solvent?: string;
@@ -701,7 +688,7 @@ declare type FilterSymbols = (typeof Filters)[keyof typeof Filters];
701
688
  * Look for a multiplet based on the pattern name or abbreviation.
702
689
  * @param name - pattern name or abbreviation.
703
690
  */
704
- export declare function findMultiplet(name: string): MatchingMultiplicity_2 | undefined;
691
+ export declare function findMultiplet(name: string): MatchingMultiplicity | undefined;
705
692
 
706
693
  /**
707
694
  * Finds a peak that can serve as a pivot point within specified boundaries.
@@ -730,9 +717,41 @@ export declare interface GeneralAssignment {
730
717
  assignment: SpectraDataWithIds[];
731
718
  }
732
719
 
733
- 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[]>;
734
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
+ */
735
751
  export declare interface Get13CAssignmentsOptions {
752
+ /**
753
+ * Partial restrictions applied to chemical-shift matching.
754
+ */
736
755
  restrictionByCS?: Partial<RestrictionByCS1D>;
737
756
  /**
738
757
  * min score to accept an assignment
@@ -755,14 +774,33 @@ export declare interface Get13CAssignmentsOptions {
755
774
  */
756
775
  timeout?: number;
757
776
  /**
758
- * prediction options
777
+ * prediction options forwarded to the carbon prediction.
759
778
  */
760
779
  predictionOptions?: PredictCarbonOptions;
761
780
  }
762
781
 
763
782
  export declare function get1DErrorFactor(spectrum: Entry1D): number;
764
783
 
765
- 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[]>;
766
804
 
767
805
  export declare interface Get1HAssignmentsOptions {
768
806
  restrictionByCS?: Partial<RestrictionByCS1D>;
@@ -794,7 +832,7 @@ export declare interface Get1HAssignmentsOptions {
794
832
 
795
833
  export declare function get2DErrorFactor(spectrum: Entry2D): Zone2DError;
796
834
 
797
- export declare function getAssignments(input: GetAutoAssignmentInput, options?: GetAssignmentsOptions): Promise<GeneralAssignment_2[]>;
835
+ export declare function getAssignments(input: GetAutoAssignmentInput, options?: GetAssignmentsOptions): Promise<GeneralAssignment[]>;
798
836
 
799
837
  export declare interface GetAssignmentsOptions {
800
838
  justAssign?: AtomTypes[][];
@@ -926,6 +964,7 @@ export declare function getPeakDelta(peak: Peak1D | NMRPeak1D, shiftTarget: Shif
926
964
  };
927
965
 
928
966
  export declare interface GetPeakListOptions extends GSDOptions, OptimizePeaksOptions, JoinBroadPeaksOptions {
967
+ smoothedY: NumberArray;
929
968
  /**
930
969
  * If it is true, the peaks parameters will be optimized.
931
970
  * @default false
@@ -1476,6 +1515,13 @@ export declare interface OptionsXYAutoPeaksPicking extends Partial<GetPeakListOp
1476
1515
  * frequency used to convert width and fwhm to Hz
1477
1516
  */
1478
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;
1479
1525
  }
1480
1526
 
1481
1527
  declare interface OptionsXYAutoRangesPicking {
@@ -1649,21 +1695,15 @@ declare interface PredictAllSpectraOptions {
1649
1695
 
1650
1696
  export declare interface PredictCarbonOptions {
1651
1697
  /**
1652
- * Custom database. Each entry in the levels should have
1653
- * an array as value [median] or [median, mean, sd, min, max, nb] for statistic purpose.
1654
- */
1655
- database?: DataBaseStructure;
1656
- /**
1657
- * Max level to take into account in the query. If is not specified
1658
- * the max level in the database will be used.
1659
- * @default 'maximum level in the database'
1660
- */
1661
- maxSphereSize?: number;
1662
- /**
1663
- * 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
1664
1699
  * @default defaultCarbonPredictor
1665
1700
  */
1666
1701
  predictor?: PredictorFn;
1702
+ /**
1703
+ * Options to pass to the predictor function.
1704
+ * @default {}
1705
+ */
1706
+ predictorOptions?: Record<string, unknown>;
1667
1707
  /**
1668
1708
  * Prediction cache handler.
1669
1709
  */
@@ -1875,7 +1915,7 @@ export declare interface PredictionOptionsByExperiment {
1875
1915
  /**
1876
1916
  * A function that should make a prediction for the given molecule and return the result.
1877
1917
  */
1878
- declare type PredictorFn = (topicMolecule: TopicMolecule) => Promise<PredictionBase1D> | PredictionBase1D;
1918
+ declare type PredictorFn = (topicMolecule: TopicMolecule, options?: Record<string, unknown>) => Promise<PredictionBase1D> | PredictionBase1D;
1879
1919
 
1880
1920
  export declare interface PredictProtonOptions {
1881
1921
  /**
@@ -1883,6 +1923,11 @@ export declare interface PredictProtonOptions {
1883
1923
  * @default defaultProtonPredictor
1884
1924
  */
1885
1925
  predictor?: PredictorFn;
1926
+ /**
1927
+ * Options to pass to the predictor function.
1928
+ * @default {}
1929
+ */
1930
+ predictorOptions?: Record<string, unknown>;
1886
1931
  /**
1887
1932
  * Prediction cache handler.
1888
1933
  */
@@ -1928,37 +1973,67 @@ export declare function rangesToACS(ranges: NMRRange[], options?: RangesToACSOpt
1928
1973
 
1929
1974
  export declare interface RangesToACSOptions {
1930
1975
  /**
1931
- * nucleus
1976
+ * Nucleus type for the NMR experiment (e.g., '1H', '13C', '19F').
1977
+ * Determines default formatting and frequency values.
1932
1978
  * @default '1H'
1933
1979
  */
1934
1980
  nucleus?: string;
1935
1981
  /**
1936
- * 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).
1937
1984
  * @default false
1938
1985
  */
1939
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
+ */
1940
2005
  format?: string;
1941
2006
  /**
1942
- * default value depends of nucleus
1943
- * @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'
1944
2012
  */
1945
2013
  deltaFormat?: string;
1946
2014
  /**
1947
- * 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.
1948
2017
  * @default '0.0'
1949
2018
  */
1950
2019
  couplingFormat?: string;
1951
2020
  /**
1952
- * default value depends of nucleus
1953
- * @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'
1954
2026
  */
1955
2027
  observedFrequency?: number;
1956
2028
  /**
2029
+ * If true, filters out ranges or signals with kind 'impurity' or 'solvent'.
2030
+ * If false, includes all ranges and signals.
1957
2031
  * @default true
1958
2032
  */
1959
2033
  filter?: boolean;
1960
2034
  /**
1961
- * 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.
1962
2037
  */
1963
2038
  solvent?: string;
1964
2039
  }
@@ -2791,7 +2866,7 @@ declare function unlink(range: Range, options?: UnlinkOptions): Range;
2791
2866
  kernel?: GetKernelOptions;
2792
2867
  }
2793
2868
 
2794
- export declare function xyzJResAnalyzer(signals: NMRSignal2D[], options?: XYZJResAnalyzerOptions): NMRZoneWithID_2[] | (NMRSignal2D<Peak2D> & {
2869
+ export declare function xyzJResAnalyzer(signals: NMRSignal2D[], options?: XYZJResAnalyzerOptions): NMRZoneWithID[] | (NMRSignal2D<Peak2D> & {
2795
2870
  id: string;
2796
2871
  })[];
2797
2872