nmr-processing 10.0.4 → 10.0.6

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 (72) hide show
  1. package/lib/datum/FiltersManager.js +1 -0
  2. package/lib/datum/FiltersManager.js.map +1 -1
  3. package/lib/datum/data1d/filter1d/baselineCorrection.js +1 -1
  4. package/lib/datum/data1d/filter1d/baselineCorrection.js.map +1 -1
  5. package/lib/prediction/predict.js +14 -25
  6. package/lib/prediction/predict.js.map +1 -1
  7. package/lib/prediction/predictCOSY.d.ts +2 -20
  8. package/lib/prediction/predictCOSY.js +2 -2
  9. package/lib/prediction/predictCOSY.js.map +1 -1
  10. package/lib/prediction/predictCarbon.d.ts +2 -15
  11. package/lib/prediction/predictCarbon.js +14 -16
  12. package/lib/prediction/predictCarbon.js.map +1 -1
  13. package/lib/prediction/predictHMBC.d.ts +2 -12
  14. package/lib/prediction/predictHMBC.js +2 -2
  15. package/lib/prediction/predictHMBC.js.map +1 -1
  16. package/lib/prediction/predictHSQC.d.ts +2 -12
  17. package/lib/prediction/predictHSQC.js +2 -2
  18. package/lib/prediction/predictHSQC.js.map +1 -1
  19. package/lib/prediction/predictProton.d.ts +2 -9
  20. package/lib/prediction/predictProton.js +9 -10
  21. package/lib/prediction/predictProton.js.map +1 -1
  22. package/lib/prediction/predictSpectra.d.ts +3 -2
  23. package/lib/prediction/predictSpectra.js +12 -7
  24. package/lib/prediction/predictSpectra.js.map +1 -1
  25. package/lib/prediction/utils/predict2D.d.ts +2 -12
  26. package/lib/prediction/utils/predict2D.js +9 -9
  27. package/lib/prediction/utils/predict2D.js.map +1 -1
  28. package/lib/prediction/utils/queryByHOSE.d.ts +2 -1
  29. package/lib/prediction/utils/queryByHOSE.js +29 -27
  30. package/lib/prediction/utils/queryByHOSE.js.map +1 -1
  31. package/lib/ranges/rangesToACS.js.map +1 -1
  32. package/lib/xyz/xyzAutoSignalsPicking.js +2 -2
  33. package/lib/xyz/xyzAutoSignalsPicking.js.map +1 -1
  34. package/lib-esm/datum/FiltersManager.js +1 -0
  35. package/lib-esm/datum/FiltersManager.js.map +1 -1
  36. package/lib-esm/datum/data1d/filter1d/baselineCorrection.js +1 -1
  37. package/lib-esm/datum/data1d/filter1d/baselineCorrection.js.map +1 -1
  38. package/lib-esm/prediction/predict.js +15 -26
  39. package/lib-esm/prediction/predict.js.map +1 -1
  40. package/lib-esm/prediction/predictCOSY.js +2 -2
  41. package/lib-esm/prediction/predictCOSY.js.map +1 -1
  42. package/lib-esm/prediction/predictCarbon.js +16 -18
  43. package/lib-esm/prediction/predictCarbon.js.map +1 -1
  44. package/lib-esm/prediction/predictHMBC.js +2 -2
  45. package/lib-esm/prediction/predictHMBC.js.map +1 -1
  46. package/lib-esm/prediction/predictHSQC.js +2 -2
  47. package/lib-esm/prediction/predictHSQC.js.map +1 -1
  48. package/lib-esm/prediction/predictProton.js +9 -10
  49. package/lib-esm/prediction/predictProton.js.map +1 -1
  50. package/lib-esm/prediction/predictSpectra.js +10 -5
  51. package/lib-esm/prediction/predictSpectra.js.map +1 -1
  52. package/lib-esm/prediction/utils/predict2D.js +9 -9
  53. package/lib-esm/prediction/utils/predict2D.js.map +1 -1
  54. package/lib-esm/prediction/utils/queryByHOSE.js +29 -27
  55. package/lib-esm/prediction/utils/queryByHOSE.js.map +1 -1
  56. package/lib-esm/ranges/rangesToACS.js.map +1 -1
  57. package/lib-esm/xyz/xyzAutoSignalsPicking.js +2 -2
  58. package/lib-esm/xyz/xyzAutoSignalsPicking.js.map +1 -1
  59. package/package.json +2 -2
  60. package/src/datum/FiltersManager.ts +1 -0
  61. package/src/datum/data1d/filter1d/baselineCorrection.ts +1 -1
  62. package/src/prediction/predict.ts +15 -40
  63. package/src/prediction/predictCOSY.ts +3 -19
  64. package/src/prediction/predictCarbon.ts +19 -33
  65. package/src/prediction/predictHMBC.ts +3 -13
  66. package/src/prediction/predictHSQC.ts +3 -13
  67. package/src/prediction/predictProton.ts +11 -19
  68. package/src/prediction/predictSpectra.ts +14 -6
  69. package/src/prediction/utils/predict2D.ts +13 -29
  70. package/src/prediction/utils/queryByHOSE.ts +31 -30
  71. package/src/ranges/rangesToACS.ts +1 -0
  72. package/src/xyz/xyzAutoSignalsPicking.ts +2 -2
@@ -1,4 +1,5 @@
1
- import { v4 as generateID } from '@lukeed/uuid';
1
+ import { v4 } from '@lukeed/uuid';
2
+ import { TopicMolecule } from 'openchemlib-utils';
2
3
 
3
4
  import { setIDs } from '../peaks/util/setIDs';
4
5
  import type { NMRSignal1D } from '../signals/NMRSignal1D';
@@ -8,10 +9,7 @@ import type { MakeMandatory } from '../utilities/MakeMandatory';
8
9
  import { PredictionBase1D } from './PredictionBase1D';
9
10
  import type { DataBaseStructure } from './dataStructure';
10
11
  import { fetchPrediction } from './utils/fetchPrediction';
11
- import { getFilteredIDiaIDs } from './utils/getFilteredIDiaIDs';
12
- import { isMolfileNotEmpty } from './utils/isMolfileNotEmpty';
13
12
  import { Prediction, queryByHose } from './utils/queryByHOSE';
14
- import { GroupedDiaID } from 'openchemlib-utils';
15
13
 
16
14
  export interface PredictCarbonOptions {
17
15
  /**
@@ -29,19 +27,6 @@ export interface PredictCarbonOptions {
29
27
  * @default 'maximum level in the database'
30
28
  */
31
29
  maxSphereSize?: number;
32
- /**
33
- * diastereotopic atom ids.
34
- */
35
- groupedDiaIDs: GroupedDiaID[];
36
- /**
37
- * hoses code of the molecule.
38
- */
39
- hoses: Array<any[] | undefined>;
40
- /**
41
- * molfile of the molecule, it could be used if there is not a database provided.
42
- * so the prediction will be fetched to the web service (webserviceURL)
43
- */
44
- molfile?: string;
45
30
  }
46
31
 
47
32
  export type PredictCarbon = typeof predictCarbon;
@@ -63,19 +48,15 @@ function checkFromPrediction(
63
48
  */
64
49
 
65
50
  export async function predictCarbon(
66
- options: PredictCarbonOptions,
51
+ topicMolecule: TopicMolecule,
52
+ options: PredictCarbonOptions = {},
67
53
  ): Promise<PredictionBase1D> {
68
54
  const {
69
- hoses,
70
- molfile,
71
55
  database,
72
56
  webserviceURL = 'https://nmr-prediction.service.zakodium.com/v1/predict/carbon',
73
- groupedDiaIDs,
74
57
  } = options;
75
58
 
76
- if (!database && isMolfileNotEmpty(molfile)) {
77
- return fetchPrediction(molfile, { webserviceURL });
78
- } else if (!isMolfileNotEmpty(molfile)) {
59
+ if (topicMolecule.molecule.getAllAtoms() === 0) {
79
60
  return {
80
61
  nucleus: '13C',
81
62
  joinedSignals: [],
@@ -85,7 +66,8 @@ export async function predictCarbon(
85
66
  }
86
67
 
87
68
  if (!database) {
88
- throw new Error('There is not a database');
69
+ const molfile = topicMolecule.toMolfile();
70
+ return fetchPrediction(molfile, { webserviceURL });
89
71
  }
90
72
 
91
73
  const maxLevel = database.length - 1;
@@ -94,13 +76,17 @@ export async function predictCarbon(
94
76
 
95
77
  if (maxSphereSize > maxLevel) maxSphereSize = maxLevel;
96
78
 
97
- const carbonDiaIDs = getFilteredIDiaIDs({
98
- groupedDiaIDs,
99
- hoses,
100
- });
79
+ const hoseCodes = topicMolecule.hoseCodes;
80
+ const diaIDsWithInfo = topicMolecule.diaIDsAndInfo.map(
81
+ (entry: any, index: number) => ({
82
+ ...entry,
83
+ hoses: hoseCodes[index],
84
+ }),
85
+ );
101
86
 
102
- const predictions = queryByHose(carbonDiaIDs, database, {
87
+ const predictions = queryByHose(diaIDsWithInfo, database, {
103
88
  maxSphereSize,
89
+ atomLabel: 'C',
104
90
  });
105
91
 
106
92
  const signals = formatSignals(predictions);
@@ -116,10 +102,10 @@ export async function predictCarbon(
116
102
  function formatSignals(predictions: Prediction[]) {
117
103
  const signals = [];
118
104
  for (const prediction of predictions) {
119
- const { atoms, nbAtoms, delta, diaIDs, statistic } = prediction;
105
+ const { nbAtoms, atoms, delta, diaIDs, statistic } = prediction;
120
106
  const signal = {
121
- id: generateID(),
122
- delta: delta || NaN,
107
+ id: v4(),
108
+ delta: delta ?? NaN,
123
109
  atoms,
124
110
  diaIDs,
125
111
  multiplicity: 's',
@@ -1,6 +1,5 @@
1
- import type { Molecule } from 'openchemlib/full';
1
+ import { TopicMolecule } from 'openchemlib-utils';
2
2
 
3
- import { GroupDiastereotopicAtomIDs } from './GroupDiastereotopicAtomIDs';
4
3
  import { PredictionBase1D } from './PredictionBase1D';
5
4
  import { predict2D } from './utils/predict2D';
6
5
 
@@ -36,19 +35,10 @@ export interface PredictHMBCOptions {
36
35
  H?: PredictionBase1D;
37
36
  C?: PredictionBase1D;
38
37
  };
39
- /**
40
- * diastereotopic atom ids of the molecule.
41
- */
42
- diaIDs: string[];
43
- /**
44
- * grouped diastereotopic atom ids of the molecule.
45
- */
46
- groupedDiaIDs: GroupDiastereotopicAtomIDs[];
47
- distanceMatrix: number[][];
48
38
  }
49
39
 
50
40
  export async function predictHMBC(
51
- molecule: Molecule,
41
+ topicMolecule: TopicMolecule,
52
42
  options: PredictHMBCOptions,
53
43
  ) {
54
44
  const {
@@ -57,7 +47,7 @@ export async function predictHMBC(
57
47
  joinDistance = { H: 0.05, C: 0.5 },
58
48
  } = options;
59
49
 
60
- return predict2D(molecule, {
50
+ return predict2D(topicMolecule, {
61
51
  ...options,
62
52
  from: 'H',
63
53
  to: 'C',
@@ -1,6 +1,5 @@
1
- import type { Molecule } from 'openchemlib/full';
1
+ import { TopicMolecule } from 'openchemlib-utils';
2
2
 
3
- import { GroupDiastereotopicAtomIDs } from './GroupDiastereotopicAtomIDs';
4
3
  import { PredictionBase1D } from './PredictionBase1D';
5
4
  import { predict2D } from './utils/predict2D';
6
5
 
@@ -31,15 +30,6 @@ export interface PredictHSQCOptions {
31
30
  H?: PredictionBase1D;
32
31
  C?: PredictionBase1D;
33
32
  };
34
- /**
35
- * diastereotopic atom ids of the molecule.
36
- */
37
- diaIDs: string[];
38
- /**
39
- * grouped diastereotopic atom ids of the molecule.
40
- */
41
- groupedDiaIDs: GroupDiastereotopicAtomIDs[];
42
- distanceMatrix: number[][];
43
33
  }
44
34
  /**
45
35
  * Generate the correlation bidimensional nmr peaks based on the number of bonds between a pair of atoms
@@ -47,7 +37,7 @@ export interface PredictHSQCOptions {
47
37
  */
48
38
 
49
39
  export async function predictHSQC(
50
- molecule: Molecule,
40
+ topicMolecule: TopicMolecule,
51
41
  options: PredictHSQCOptions,
52
42
  ) {
53
43
  const {
@@ -56,7 +46,7 @@ export async function predictHSQC(
56
46
  joinDistance = { H: 0.05, C: 0.5 },
57
47
  } = options;
58
48
 
59
- return predict2D(molecule, {
49
+ return predict2D(topicMolecule, {
60
50
  ...options,
61
51
  from: 'H',
62
52
  to: 'C',
@@ -1,13 +1,13 @@
1
1
  import { v4 as generateID } from '@lukeed/uuid';
2
2
  import fetch from 'cross-fetch';
3
3
  import FormData from 'form-data';
4
+ import { TopicMolecule } from 'openchemlib-utils';
4
5
 
5
6
  import type { NMRSignal1D } from '../signals/NMRSignal1D';
6
7
  import { signalsJoin } from '../signals/signalsJoin';
7
8
  import { signalsToRanges } from '../signals/signalsToRanges';
8
9
 
9
10
  import { PredictionBase1D } from './PredictionBase1D';
10
- import { isMolfileNotEmpty } from './utils/isMolfileNotEmpty';
11
11
 
12
12
  /**
13
13
  * Makes a prediction using proton.
@@ -19,23 +19,15 @@ export interface PredictProtonOptions {
19
19
  * A callback receiving a molfile and the result
20
20
  */
21
21
  cache?: (molfile: string, result?: string) => void | string | undefined;
22
- /**
23
- * diastereotopic atom ids.
24
- */
25
- diaIDs: string[];
26
- /**
27
- * distance matrix
28
- */
29
- distanceMatrix: number[][];
30
22
  }
31
23
 
32
24
  export type PredictProton = typeof predictProton;
33
25
 
34
26
  export async function predictProton(
35
- molfile: string,
36
- options: PredictProtonOptions,
27
+ topicMolecule: TopicMolecule,
28
+ options: PredictProtonOptions = {},
37
29
  ): Promise<PredictionBase1D> {
38
- if (!isMolfileNotEmpty(molfile)) {
30
+ if (topicMolecule.molecule.getAllAtoms() === 0) {
39
31
  return {
40
32
  nucleus: '1H',
41
33
  joinedSignals: [],
@@ -47,11 +39,11 @@ export async function predictProton(
47
39
 
48
40
  let result;
49
41
  if (cache) {
50
- result = cache(molfile);
42
+ result = cache(topicMolecule.idCode);
51
43
  }
52
44
  if (result === undefined) {
53
45
  const formData = new FormData();
54
- formData.append('molfile', molfile);
46
+ formData.append('molfile', topicMolecule.toMolfile());
55
47
  const response = await fetch('https://www.nmrdb.org/service/predictor', {
56
48
  method: 'POST',
57
49
  // @ts-expect-error RequestInit type does not include FormData.
@@ -59,12 +51,11 @@ export async function predictProton(
59
51
  });
60
52
  result = await response.text();
61
53
  if (cache) {
62
- cache(molfile, result);
54
+ cache(topicMolecule.idCode, result);
63
55
  }
64
56
  }
65
57
 
66
- const { diaIDs, distanceMatrix } = options;
67
- const signals = protonParser(result, { diaIDs, distanceMatrix });
58
+ const signals = protonParser(result, topicMolecule);
68
59
  const joinedSignals = signalsJoin(signals);
69
60
  return {
70
61
  nucleus: '1H',
@@ -76,12 +67,13 @@ export async function predictProton(
76
67
 
77
68
  function protonParser(
78
69
  result: string,
79
- options: { diaIDs: string[]; distanceMatrix: number[][] },
70
+ topicMolecule: TopicMolecule,
80
71
  ): NMRSignal1D[] {
81
72
  if (result.includes('ERR')) {
82
73
  throw Error(`Spinus optimization: ${result}`);
83
74
  }
84
- const { diaIDs, distanceMatrix } = options;
75
+ const diaIDs = topicMolecule.diaIDs;
76
+ const distanceMatrix = topicMolecule.distanceMatrix;
85
77
  const lines = result.split('\n').filter((line) => line);
86
78
  const signals = [];
87
79
  for (const line of lines) {
@@ -1,4 +1,4 @@
1
- import { FromTo, PointXY } from 'cheminfo-types';
1
+ import { FromTo, Logger, PointXY } from 'cheminfo-types';
2
2
  import type { Molecule } from 'openchemlib/full';
3
3
 
4
4
  import { signals2DToZ } from '../signals/signals2DToZ';
@@ -31,26 +31,29 @@ interface SimulationOptions {
31
31
  twoD?: Partial<TwoDOptions>;
32
32
  }
33
33
  interface PredictAllSpectraOptions {
34
+ logger?: Logger;
34
35
  prediction?: PredictAllOptions;
35
36
  simulation?: SimulationOptions;
36
37
  }
37
38
 
38
- export async function predictAllSpectra(
39
+ export async function predictSpectra(
39
40
  molecule: Molecule,
40
41
  options: PredictAllSpectraOptions = {},
41
42
  ) {
42
43
  const {
44
+ logger,
43
45
  simulation: simulationOptions = { oneD: {}, twoD: {} } as SimulationOptions,
44
- prediction: predictionOptions = {},
46
+ prediction: predictOptions = {},
45
47
  } = options;
46
48
 
47
- const { spectra } = await predict(molecule, predictionOptions);
49
+ const { spectra } = await predict(molecule, { logger, ...predictOptions });
48
50
 
49
51
  const oneDOptions: OneDOptions = {
50
52
  ...{
51
53
  proton: { from: 0, to: 14 },
52
54
  carbon: { from: 0, to: 200 },
53
55
  nbPoints: 65536,
56
+ frequency: 400,
54
57
  lineWidth: 1,
55
58
  },
56
59
  ...(simulationOptions.oneD || {}),
@@ -65,6 +68,11 @@ export async function predictAllSpectra(
65
68
  ...(simulationOptions.twoD || {}),
66
69
  };
67
70
 
71
+ if (!('frequency' in simulationOptions) && logger) {
72
+ logger.warn(`Frequency is settled to 400 MHz`);
73
+ }
74
+ const { frequency = 400 } = simulationOptions;
75
+
68
76
  const newSpectra: any[] = [];
69
77
  for (const experiment in spectra) {
70
78
  switch (experiment) {
@@ -76,7 +84,7 @@ export async function predictAllSpectra(
76
84
  lineWidth: oneDOptions.lineWidth,
77
85
  ...oneDOptions[experiment],
78
86
  experiment,
79
- frequency: simulationOptions.frequency,
87
+ frequency,
80
88
  }),
81
89
  );
82
90
  break;
@@ -88,7 +96,7 @@ export async function predictAllSpectra(
88
96
  get2DSpectrum(spectra[experiment], {
89
97
  ...twoDOptions,
90
98
  experiment,
91
- frequency: simulationOptions.frequency,
99
+ frequency,
92
100
  }),
93
101
  );
94
102
  break;
@@ -2,6 +2,7 @@ import { v4 as generateID } from '@lukeed/uuid';
2
2
  import { agnes, Cluster } from 'ml-hclust';
3
3
  import { Matrix } from 'ml-matrix';
4
4
  import { Molecule } from 'openchemlib/full';
5
+ import { TopicMolecule } from 'openchemlib-utils';
5
6
 
6
7
  import { setIDs } from '../../peaks/util/setIDs';
7
8
  import type { NMRSignal1D } from '../../signals/NMRSignal1D';
@@ -70,15 +71,6 @@ export interface Predict2DOptions {
70
71
  * @default false
71
72
  */
72
73
  includeDiagonal?: boolean;
73
- /**
74
- * diastereotopic atom ids of the molecule.
75
- */
76
- diaIDs: string[];
77
- /**
78
- * grouped diastereotopic atom ids of the molecule.
79
- */
80
- groupedDiaIDs: GroupDiastereotopicAtomIDs[];
81
- distanceMatrix: number[][];
82
74
  }
83
75
 
84
76
  export interface PredictOptions {
@@ -108,34 +100,30 @@ function checkFromTo(
108
100
 
109
101
  type Signal1DByDiaID = Record<string, Record<string, NMRSignal1D>>;
110
102
 
111
- export async function predict2D(molecule: Molecule, options: Predict2DOptions) {
103
+ export async function predict2D(
104
+ topicMolecule: TopicMolecule,
105
+ options: Predict2DOptions,
106
+ ) {
112
107
  checkFromTo(options);
113
108
 
114
- molecule.addImplicitHydrogens();
115
-
116
109
  const {
117
110
  from,
118
111
  to,
119
- diaIDs,
120
- groupedDiaIDs,
121
112
  minLength = 0,
122
113
  maxLength,
123
114
  predictions,
124
- distanceMatrix,
125
115
  joinDistance = { H: 0.05, C: 0.5 },
126
116
  includeDiagonal = false,
127
117
  } = options;
128
118
 
129
- const pathsInfo = getPossibleCorrelations({
130
- molecule,
119
+ const pathsInfo = getPossibleCorrelations(topicMolecule, {
131
120
  fromLabel: from,
132
121
  toLabel: to,
133
- diaIDs,
134
- distanceMatrix,
135
122
  minLength,
136
123
  maxLength,
137
124
  });
138
125
 
126
+ const groupedDiaIDs = topicMolecule.getGroupedDiastereotopicAtomIDs();
139
127
  const diaIDswithAtomInfo: GroupDiastereotopicAtomIDsWithAtomInfo[] = [];
140
128
  for (const diaID of groupedDiaIDs) {
141
129
  diaIDswithAtomInfo.push({
@@ -223,16 +211,12 @@ interface AtomPartialPathInfo {
223
211
  oclID: string;
224
212
  paths: Array<{ from: number; to: number }>;
225
213
  }
226
- function getPossibleCorrelations(options: any) {
227
- const {
228
- fromLabel,
229
- toLabel,
230
- distanceMatrix,
231
- molecule,
232
- diaIDs,
233
- minLength,
234
- maxLength,
235
- } = options;
214
+ function getPossibleCorrelations(topicMolecule: TopicMolecule, options: any) {
215
+ const { fromLabel, toLabel, minLength, maxLength } = options;
216
+
217
+ const diaIDs = topicMolecule.diaIDs;
218
+ const molecule = topicMolecule.moleculeWithH;
219
+ const distanceMatrix = topicMolecule.distanceMatrix;
236
220
  const fromAtomicNumber = Molecule.getAtomicNoFromLabel(fromLabel);
237
221
  const toAtomicNumber = Molecule.getAtomicNoFromLabel(toLabel);
238
222
  const atomPathInfo: AtomPartialPathInfo[] = [];
@@ -17,43 +17,44 @@ export interface Prediction {
17
17
  };
18
18
  }
19
19
  export function queryByHose(
20
- diaIDs: any,
20
+ diaIDsWithInfo: any,
21
21
  db: DataBaseStructure,
22
- options: { maxSphereSize: number },
22
+ options: { maxSphereSize: number; atomLabel: string },
23
23
  ): Prediction[] {
24
- const { maxSphereSize } = options;
24
+ const { maxSphereSize, atomLabel } = options;
25
+
26
+ const results = [];
27
+ for (let i = 0; i < diaIDsWithInfo.length; i++) {
28
+ const entry = diaIDsWithInfo[i];
29
+ if (atomLabel && entry.atomLabel !== atomLabel) continue;
25
30
 
26
- const toReturn = [];
27
- for (const element of diaIDs) {
28
31
  let res;
29
32
  let level = null;
30
- for (let k = maxSphereSize; !res && k >= 0; k--) {
31
- if (db[k]) {
32
- res = db[k][element.hose[k]];
33
+ for (let k = maxSphereSize; k >= 0; k--) {
34
+ if (db[k]?.[entry.hoses[k]]) {
35
+ res = db[k][entry.hoses[k]];
33
36
  level = k;
37
+ break;
34
38
  }
35
39
  }
36
-
37
- for (const atomNumber of element.atoms) {
38
- const atom = {
39
- diaIDs: [element.oclID],
40
- delta: res ? res[0] : null,
41
- atoms: [atomNumber],
42
- nbAtoms: 1,
43
- level,
44
- statistic:
45
- res && res.length > 1
46
- ? {
47
- mean: res[1],
48
- sd: res[2],
49
- min: res[3],
50
- max: res[4],
51
- nb: res[5],
52
- }
53
- : undefined,
54
- };
55
- toReturn.push(atom);
56
- }
40
+ const result = {
41
+ diaIDs: [entry.idCode],
42
+ delta: res ? res[0] : null,
43
+ atoms: [i],
44
+ nbAtoms: 1,
45
+ level,
46
+ statistic:
47
+ res && res.length > 1 // only if DB contains statistics
48
+ ? {
49
+ mean: res[1],
50
+ sd: res[2],
51
+ min: res[3],
52
+ max: res[4],
53
+ nb: res[5],
54
+ }
55
+ : undefined,
56
+ };
57
+ results.push(result);
57
58
  }
58
- return toReturn;
59
+ return results;
59
60
  }
@@ -1,4 +1,5 @@
1
1
  import { isAnyArray } from 'is-any-array';
2
+
2
3
  import { signalJoinCouplings } from '../signal/signalJoinCouplings';
3
4
  import { signalMultiplicityPattern } from '../signal/signalMultiplicityPattern';
4
5
  import type { NMRSignal1D } from '../signals/NMRSignal1D';
@@ -1,5 +1,6 @@
1
1
  import { v4 as generateID } from '@lukeed/uuid';
2
2
  import { NmrData2DContent } from 'cheminfo-types';
3
+ import { isAnyArray } from 'is-any-array';
3
4
  import * as convolution from 'ml-matrix-convolution';
4
5
  import * as matrixPeakFinders from 'ml-matrix-peaks-finder';
5
6
  import type { Peak2D } from 'ml-matrix-peaks-finder';
@@ -14,7 +15,6 @@ import { MakeMandatory } from '../utilities/MakeMandatory';
14
15
 
15
16
  import type { NMRSignal2D } from './NMRSignal2D';
16
17
  import { padData } from './util/padData';
17
- import { isAnyArray } from 'is-any-array';
18
18
 
19
19
  const smallFilter = [
20
20
  [0, 0, 1, 2, 2, 2, 1, 0, 0],
@@ -108,7 +108,7 @@ export function xyzAutoSignalsPicking(
108
108
 
109
109
  let { thresholdFactor = 0.5 } = options;
110
110
 
111
- if (isAnyArray(observedFrequencies)) {
111
+ if (!isAnyArray(observedFrequencies)) {
112
112
  throw new Error('observedFrequencies is mandatory');
113
113
  }
114
114