nmr-processing 16.0.1 → 17.1.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.
@@ -1,16 +1,18 @@
1
1
  import { AnalizeMultipletOptions } from 'multiplet-analysis';
2
2
  import { BaseRegression } from 'ml-regression-base';
3
+ import { DataReIm } from 'ml-spectra-processing';
3
4
  import { DataXReIm } from 'ml-spectra-processing';
4
5
  import { DataXY } from 'cheminfo-types';
5
6
  import { DoubleArray } from 'cheminfo-types';
6
7
  import { ExponentialRegression } from 'ml-regression-exponential';
7
8
  import type { FilterXYType } from 'ml-signal-processing';
8
9
  import { FromTo } from 'cheminfo-types';
10
+ import { GroupedDiaID } from 'openchemlib-utils';
9
11
  import { GSDOptions } from 'ml-gsd';
10
12
  import { GSDPeakOptimized } from 'ml-gsd';
11
13
  import { GSDPeakOptimizedID } from 'ml-gsd';
12
14
  import { JoinBroadPeaksOptions } from 'ml-gsd';
13
- import type { LightLogger } from 'cheminfo-types';
15
+ import { LightLogger } from 'cheminfo-types';
14
16
  import { Logger } from 'cheminfo-types';
15
17
  import { Matrix } from 'ml-matrix';
16
18
  import * as matrixPeakFinders from 'ml-matrix-peaks-finder';
@@ -28,7 +30,6 @@ import type { Peak2D as Peak2D_2 } from 'ml-matrix-peaks-finder';
28
30
  import { PeakXYWidth } from 'cheminfo-types';
29
31
  import { PointXY } from 'cheminfo-types';
30
32
  import { Shape1D } from 'ml-peak-shape-generator';
31
- import { Spectrum2D } from 'spectrum-generator';
32
33
  import { TopicMolecule } from 'openchemlib-utils';
33
34
  import { XYEquallySpacedOptions } from 'ml-spectra-processing';
34
35
  import type { XYNumber } from 'spectrum-generator';
@@ -42,6 +43,8 @@ export declare interface AirplsOptions {
42
43
  tolerance: number;
43
44
  }
44
45
 
46
+ declare type AnalysisInfoSection = Record<string, string>;
47
+
45
48
  declare type Apodization1D = FilterFactory<Entry1D, Apodization2DOptions> & Pick<Apodization1DFilterOptions, 'name'>;
46
49
 
47
50
  declare interface Apodization1DFilterOptions extends BaseFilter {
@@ -127,6 +130,11 @@ export declare interface ApplyWindowOptions {
127
130
  output?: DoubleArray;
128
131
  }
129
132
 
133
+ export declare interface AtomMapping {
134
+ label: string;
135
+ atom: number;
136
+ }
137
+
130
138
  declare type AtomTypes = 'H' | 'C';
131
139
 
132
140
  export declare interface AutoPhaseCorrection2D {
@@ -294,24 +302,20 @@ export declare const carbonImpurities: DatabaseNMREntry[];
294
302
  */
295
303
  export declare function checkIntegralKind(integral: Integral): boolean;
296
304
 
297
- /**
298
- * check if the input string corresponds to a multiplet (pattern), it could has a common name, acs or one letter abbreviation.
299
- * @param string - pattern name or abbreviation.
300
- * @param rejected - list of patterns that should not match with the input pattern. e.g 'massive' as input will return false if rejected = ['m'].
301
- */
302
- export declare function checkMultiplet(string: string, rejected?: string[]): boolean | undefined;
303
-
304
- /**
305
- * check the input string corresponds to a composed pattern like dt or dd. it splits into indivitual patterns and use checkMultiplet function.
306
- * @param multiplicity - pattern name or abbreviation.
307
- * @param rejected - list of patterns that should not match with any pattern. e.g 'dt' as input will return false if rejected = ['t'].
308
- */
309
- export declare function checkMultiplicity(multiplicity: string, rejected?: string[]): boolean;
305
+ export declare function checkMultiplicity(multiplicity: string, rejected?: OneLetterMultiplet[]): boolean;
310
306
 
311
307
  declare function checkRangeKind(range: Range_2): boolean;
312
308
 
313
309
  declare function checkSignalKinds(range: Range_2, kinds: string[]): boolean;
314
310
 
311
+ export declare interface ChemicalShift {
312
+ Element: string;
313
+ Shift: string;
314
+ Spincount: string;
315
+ Nucleicount: string;
316
+ Name: string;
317
+ }
318
+
315
319
  declare type CommonField = SelectField | StringField | NumberField | BooleanField | LabelField;
316
320
 
317
321
  declare interface CompilePatternOptions {
@@ -323,9 +327,25 @@ declare interface CompilePatternOptions {
323
327
  };
324
328
  }
325
329
 
330
+ export declare interface Coupling {
331
+ atomFrom: number;
332
+ atomTo: number;
333
+ atomLabelTo: string;
334
+ value: number;
335
+ key: string;
336
+ toDiaID: number;
337
+ pathLength: number;
338
+ }
339
+
326
340
  export declare const couplingACSPatterns: string[];
327
341
 
328
- export declare const couplingPatterns: string[];
342
+ declare interface CouplingConstant {
343
+ Coupling: string;
344
+ Shift1: string;
345
+ Shift2: string;
346
+ }
347
+
348
+ export declare const couplingPatterns: OneLetterMultiplet[];
329
349
 
330
350
  export declare function createApodizationWindowData(options: {
331
351
  windowOptions: {
@@ -355,6 +375,27 @@ export declare interface CreateSignals2DOptions {
355
375
  maxX: number;
356
376
  }
357
377
 
378
+ /**
379
+ * CT results are stored in a CSV file with a specific format and a SDF file.
380
+ * This function will parse the CSV and return an object with the different sections.
381
+ * @param csv
382
+ * @returns
383
+ */
384
+ declare function ctCSVParser(csv: string, options: {
385
+ logger: LightLogger;
386
+ }): CtCSVParserResult;
387
+
388
+ declare interface CtCSVParserResult {
389
+ 'ANALYSIS INFO'?: AnalysisInfoSection;
390
+ SCORES?: ScoreEntry[];
391
+ SPINSYSTEMS?: ParsedRow[];
392
+ 'CHEMICAL SHIFTS (ppm)'?: ParsedRow[];
393
+ 'COUPLING CONSTANTS (Hz)'?: ParsedRow[];
394
+ LINESHAPES?: ParsedRow[];
395
+ QMGI?: ParsedRow[];
396
+ [key: string]: SectionData | undefined;
397
+ }
398
+
358
399
  export declare function ctParser(sdf: string, csv: string, options: {
359
400
  OCL: {
360
401
  Molecule: typeof Molecule_2;
@@ -362,8 +403,8 @@ export declare function ctParser(sdf: string, csv: string, options: {
362
403
  logger?: LightLogger;
363
404
  }): {
364
405
  molecules: ParsedMolecule[];
365
- sections: Record<string, any>;
366
- groups: any[];
406
+ sections: ReturnType<typeof ctCSVParser>;
407
+ groups: GroupData[];
367
408
  };
368
409
 
369
410
  export declare type DataBaseLevelEntry = number | [number] | [number, number, number, number | null, number] | undefined | NMRSignalStatistics;
@@ -644,7 +685,21 @@ export { Filters2DManager }
644
685
  * Look for a multiplet based on the pattern name or abbreviation.
645
686
  * @param name - pattern name or abbreviation.
646
687
  */
647
- export declare function findMultiplet(name: string): MultipletDefinition | undefined;
688
+ export declare function findMultiplet(name: string): MatchingMultiplicity | undefined;
689
+
690
+ /**
691
+ * Finds a peak that can serve as a pivot point within specified boundaries.
692
+ * The pivot is selected based on its y-value being above a threshold and its position
693
+ * being closest to either boundary (minX or maxX).
694
+ *
695
+ * @param peaks - Array of points containing x and y coordinates
696
+ * @param options - Configuration object for finding the pivot
697
+ *
698
+ * @returns The peak that serves as pivot point
699
+ *
700
+ * @throws {Error} If peaks array is empty
701
+ */
702
+ export declare function findPivot(peaks: PointXY[], options: XYObjectSidePointOptions): PointXY;
648
703
 
649
704
  declare type FordwardLPDimension1 = FilterFactory<Entry2D, Partial<BackwardLPOptions>> & Pick<FordwardLPDimension1Options, 'name'>;
650
705
 
@@ -894,6 +949,19 @@ export declare interface GetPeakListOptions extends GSDOptions, OptimizePeaksOpt
894
949
 
895
950
  export declare function getShiftX(spectrum: Entry1D): number;
896
951
 
952
+ export declare interface GroupData {
953
+ id: string;
954
+ molfile: string;
955
+ spinSystem: {
956
+ SSType: string;
957
+ };
958
+ couplingConstants: CouplingConstant[];
959
+ chemicalShifts: ChemicalShift[];
960
+ atomsMapping: AtomMapping[];
961
+ atomsMappingLookup: Record<string, number>;
962
+ signals?: NMRSignal1D[];
963
+ }
964
+
897
965
  export declare const impurities: SolventImpurities;
898
966
 
899
967
  export declare type Impurity = Record<string, ImpuritySignal[]>;
@@ -1131,7 +1199,19 @@ export declare function mapZones(zones: Zone[], datum: Entry2D, options?: MapOpt
1131
1199
  assignment?: string;
1132
1200
  }[];
1133
1201
 
1134
- export declare function markSolventPeaks<T extends NMRRange>(input: T[], solventSignals: NMRSignal1D[], options?: any): T[];
1202
+ export declare function markSolventPeaks<T extends NMRRange>(input: T[], solventSignals: NMRSignal1D[], options?: MarkSolventPeaksOptions): T[];
1203
+
1204
+ declare interface MarkSolventPeaksOptions {
1205
+ /** The NMR spectrometer frequency in MHz
1206
+ * @default 400
1207
+ */
1208
+ frequency?: number;
1209
+ }
1210
+
1211
+ export declare type MatchingMultiplicity = MultipletDefinition & {
1212
+ match: string;
1213
+ isBroad: boolean;
1214
+ };
1135
1215
 
1136
1216
  declare interface MatrixFilter {
1137
1217
  name: FilterXYType['name'];
@@ -1193,9 +1273,19 @@ declare interface MatrixToStocsyOptions {
1193
1273
  colors?: string[];
1194
1274
  }
1195
1275
 
1276
+ declare interface MinMaxContent {
1277
+ z: Float64Array[];
1278
+ minX: number;
1279
+ maxX: number;
1280
+ minY: number;
1281
+ maxY: number;
1282
+ minZ: number;
1283
+ maxZ: number;
1284
+ }
1285
+
1196
1286
  export declare interface MultipletDefinition {
1197
1287
  label: string;
1198
- value: string;
1288
+ value: OneLetterMultiplet;
1199
1289
  acs?: string;
1200
1290
  names: string[];
1201
1291
  multiplicity: number | null;
@@ -1330,12 +1420,6 @@ export declare interface ObservedNucleusData {
1330
1420
  frequency: number;
1331
1421
  }
1332
1422
 
1333
- /**
1334
- * This function will generate an object compatible with NMR-ium
1335
- *
1336
- * @param molecule
1337
- * @param options
1338
- */
1339
1423
  declare interface OneDOptions {
1340
1424
  proton: FromTo;
1341
1425
  carbon: FromTo;
@@ -1343,6 +1427,8 @@ declare interface OneDOptions {
1343
1427
  lineWidth: number;
1344
1428
  }
1345
1429
 
1430
+ export declare type OneLetterMultiplet = 's' | 'd' | 't' | 'q' | 'i' | 'h' | 'p' | 'o' | 'n' | 'm';
1431
+
1346
1432
  export declare function optimizeSignals(data: DataXY, signals: Signal[], options: OptimizeSignalsOptions): {
1347
1433
  delta: number;
1348
1434
  js: Jcoupling[];
@@ -1535,6 +1621,8 @@ declare interface ParsedMolecule {
1535
1621
  id: string;
1536
1622
  }
1537
1623
 
1624
+ declare type ParsedRow = Record<string, string>;
1625
+
1538
1626
  export declare interface Peak1D extends Omit<NMRPeak1D, 'id'>, BasePeak {
1539
1627
  originalX?: number;
1540
1628
  }
@@ -1564,7 +1652,12 @@ export declare interface Peaks {
1564
1652
  }
1565
1653
 
1566
1654
  /**
1567
- * Try to remove peaks of impurities.
1655
+ * Filters impurities from a list of NMR peaks based on the specified options.
1656
+ *
1657
+ * @template T - The type of NMR peaks.
1658
+ * @param {T[]} peakList - The list of NMR peaks to be filtered.
1659
+ * @param {OptionsPeaksFilterImpurities} [options={}] - The options for filtering impurities.
1660
+ * @returns {T[]} The filtered list of NMR peaks.
1568
1661
  */
1569
1662
  export declare function peaksFilterImpurities<T extends NMRPeak1D>(peakList: T[], options?: OptionsPeaksFilterImpurities): T[];
1570
1663
 
@@ -1768,22 +1861,58 @@ declare interface PredictCOSYOptions {
1768
1861
  export declare interface Predicted {
1769
1862
  molfile: string;
1770
1863
  molfileWithH: string;
1771
- hoses: any[];
1772
- diaIDs: any[] | undefined;
1773
- groupedDiaIDs: any[];
1864
+ hoses: string[];
1865
+ diaIDs: string[] | undefined;
1866
+ groupedDiaIDs: GroupedDiaID[];
1774
1867
  moleculeWithHydrogens: Molecule;
1775
- distanceMatrix: any[];
1868
+ distanceMatrix: NumberArray[];
1776
1869
  spectra: PredictedSpectra;
1777
1870
  }
1778
1871
 
1779
- export declare interface PredictedSpectra {
1872
+ export declare interface Predicted1DSpectra {
1780
1873
  proton?: PredictionBase1D;
1781
1874
  carbon?: PredictionBase1D;
1875
+ }
1876
+
1877
+ export declare interface Predicted2DSpectra {
1782
1878
  cosy?: PredictionBase2D;
1783
1879
  hsqc?: PredictionBase2D;
1784
1880
  hmbc?: PredictionBase2D;
1785
1881
  }
1786
1882
 
1883
+ export declare interface PredictedSpectra extends Predicted1DSpectra, Predicted2DSpectra {
1884
+ }
1885
+
1886
+ declare interface PredictedSpectrum1D {
1887
+ data: {
1888
+ x: NumberArray;
1889
+ re: NumberArray;
1890
+ im: null;
1891
+ };
1892
+ info: Spectrum1DInfo;
1893
+ ranges: {
1894
+ values: Array<{
1895
+ from: number;
1896
+ to: number;
1897
+ }>;
1898
+ };
1899
+ }
1900
+
1901
+ declare interface PredictedSpectrum2D {
1902
+ data: {
1903
+ rr: MinMaxContent & {
1904
+ noise: number;
1905
+ };
1906
+ };
1907
+ info: Spectrum2DInfo;
1908
+ zones: {
1909
+ values: Array<{
1910
+ x: FromTo;
1911
+ y: FromTo;
1912
+ }>;
1913
+ };
1914
+ }
1915
+
1787
1916
  /**
1788
1917
  * Generate the correlation bidimensional nmr peaks based on the number of bonds between a pair of atoms
1789
1918
  * @returns {Promise<object>} - object with molfile, diaIDs, 2D signals joined signals and zones.
@@ -1911,12 +2040,14 @@ export declare interface PredictProtonOptions {
1911
2040
  cache?: PredictionCacheFn;
1912
2041
  }
1913
2042
 
1914
- export declare function predictSpectra(molecule: Molecule, options?: PredictAllSpectraOptions): Promise<{
1915
- spectra: any[];
1916
- molecules: {
2043
+ export declare function predictSpectra(molecule: Molecule, options?: PredictAllSpectraOptions): Promise<PredictSpectraResult>;
2044
+
2045
+ declare interface PredictSpectraResult {
2046
+ spectra: Array<PredictedSpectrum1D | PredictedSpectrum2D>;
2047
+ molecules: Array<{
1917
2048
  molfile: string;
1918
- }[];
1919
- }>;
2049
+ }>;
2050
+ }
1920
2051
 
1921
2052
  declare type Properties = ListField | SelectField | StringField | NumberField | BooleanField | LabelField;
1922
2053
 
@@ -2074,6 +2205,11 @@ declare function reapplyFilters_2(datum: Entry2D, options?: {
2074
2205
  logger?: Logger;
2075
2206
  }): void;
2076
2207
 
2208
+ export declare function reimComplexBackwardLinearPrediction(data: DataReIm, options: BackwardLPOptions): {
2209
+ re: Float64Array<ArrayBuffer>;
2210
+ im: Float64Array<ArrayBuffer>;
2211
+ };
2212
+
2077
2213
  declare function resetDiaIDs(range: Range_2): void;
2078
2214
 
2079
2215
  declare interface RestrictionByCS {
@@ -2094,6 +2230,13 @@ export declare interface ResurrectOptions {
2094
2230
  logger?: Logger;
2095
2231
  }
2096
2232
 
2233
+ declare interface ScoreEntry {
2234
+ key: string;
2235
+ value: string;
2236
+ }
2237
+
2238
+ declare type SectionData = AnalysisInfoSection | ScoreEntry[] | ParsedRow[];
2239
+
2097
2240
  declare interface SelectField extends Field<any> {
2098
2241
  type: 'select';
2099
2242
  choices: any[];
@@ -2246,7 +2389,15 @@ declare interface SignalProcessingFilter extends BaseFilter {
2246
2389
  value: MatrixOptions;
2247
2390
  }
2248
2391
 
2249
- export declare function signals2DToZ(signals: NMRSignal2D[], options?: Signals2DToZOptions): Spectrum2D;
2392
+ export declare function signals2DToZ(signals: NMRSignal2D[], options?: Signals2DToZOptions): {
2393
+ minX: number;
2394
+ maxX: number;
2395
+ minY: number;
2396
+ maxY: number;
2397
+ minZ: number;
2398
+ maxZ: number;
2399
+ z: Float64Array<ArrayBufferLike>[];
2400
+ };
2250
2401
 
2251
2402
  declare interface Signals2DToZOptions {
2252
2403
  /**
@@ -2398,6 +2549,12 @@ declare interface Simulate1DOptions {
2398
2549
  shape?: Shape1D;
2399
2550
  }
2400
2551
 
2552
+ /**
2553
+ * This function will generate an object compatible with NMR-ium
2554
+ *
2555
+ * @param molecule
2556
+ * @param options
2557
+ */
2401
2558
  declare interface SimulationOptions {
2402
2559
  frequency: number;
2403
2560
  oneD?: Partial<OneDOptions>;
@@ -2461,6 +2618,25 @@ export declare interface SpectraData2DWithIds extends Omit<SpectraData2D, 'zones
2461
2618
 
2462
2619
  export declare type SpectraDataWithIds = SpectraData1DWithIds | SpectraData2DWithIds;
2463
2620
 
2621
+ declare interface Spectrum1DInfo {
2622
+ nucleus: string;
2623
+ dimension: number;
2624
+ isComplex: boolean;
2625
+ originFrequency: number;
2626
+ baseFrequency: number;
2627
+ pulseSequence: string;
2628
+ experiment: string;
2629
+ isFt: boolean;
2630
+ }
2631
+
2632
+ declare interface Spectrum2DInfo {
2633
+ nucleus: string[];
2634
+ originFrequency: string;
2635
+ baseFrequency: string | number;
2636
+ pulseSequence: string;
2637
+ experiment: string;
2638
+ }
2639
+
2464
2640
  export declare interface SpinSystem {
2465
2641
  /**
2466
2642
  * isolated clusters from a similarity/connectivity matrix
@@ -2485,11 +2661,11 @@ export declare interface SpinSystem {
2485
2661
  }
2486
2662
 
2487
2663
  /**
2488
- * split a composed pattern like dt or ddt into ['d','t'] and ['d','d','t']
2664
+ * split a composed pattern like dt or ddt into an array of objects
2489
2665
  * @param multiplet - pattern or abbreviation.
2490
2666
  * @returns
2491
2667
  */
2492
- export declare function splitPatterns(multiplet: string): string[];
2668
+ export declare function splitPatterns(multiplet: string): MatchingMultiplicity[];
2493
2669
 
2494
2670
  export declare interface SplitSpinSystemOptions {
2495
2671
  /**
@@ -2664,12 +2840,23 @@ declare function unlink(range: Range_2, options?: UnlinkOptions): Range_2;
2664
2840
  regression: T1Regression;
2665
2841
  };
2666
2842
 
2843
+ export declare function xyGetPivot(data: DataXY<Float64Array>, options?: {
2844
+ thresholdFactor?: number;
2845
+ frequency?: number;
2846
+ }): PointXY;
2847
+
2667
2848
  export declare function xyKineticFirstOrder(data: DataXY): {
2668
2849
  regression: ExponentialRegression;
2669
2850
  rateConstant: number;
2670
2851
  initialConcentration: number;
2671
2852
  };
2672
2853
 
2854
+ declare interface XYObjectSidePointOptions {
2855
+ minX: number;
2856
+ maxX: number;
2857
+ thresholdFactor?: number;
2858
+ }
2859
+
2673
2860
  export declare function xyPeaksOptimization<T extends PeakXYWidth>(data: DataXY, peaks: T[], options: XYPeaksOptimizationOptions): (T extends {
2674
2861
  id: string;
2675
2862
  } ? GSDPeakOptimizedID : GSDPeakOptimized)[];