nmr-processing 3.3.3 → 4.0.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.
- package/CHANGELOG.md +38 -0
- package/lib/assignment/get13CAssignments.d.ts +35 -0
- package/lib/assignment/get13CAssignments.js +54 -0
- package/lib/assignment/get13CAssignments.js.map +1 -0
- package/lib/assignment/get1HAssignments.d.ts +42 -0
- package/lib/assignment/get1HAssignments.js +55 -0
- package/lib/assignment/get1HAssignments.js.map +1 -0
- package/lib/assignment/utils/buildAssignments.d.ts +33 -0
- package/lib/assignment/utils/buildAssignments.js +93 -0
- package/lib/assignment/utils/buildAssignments.js.map +1 -0
- package/lib/assignment/utils/createMapPossibleAssignments.d.ts +15 -0
- package/lib/assignment/utils/createMapPossibleAssignments.js +51 -0
- package/lib/assignment/utils/createMapPossibleAssignments.js.map +1 -0
- package/lib/assignment/utils/exploreTreeRec.d.ts +22 -0
- package/lib/assignment/utils/exploreTreeRec.js +77 -0
- package/lib/assignment/utils/exploreTreeRec.js.map +1 -0
- package/lib/assignment/utils/generateID.d.ts +1 -0
- package/lib/assignment/utils/generateID.js +13 -0
- package/lib/assignment/utils/generateID.js.map +1 -0
- package/lib/assignment/utils/partialScore.d.ts +16 -0
- package/lib/assignment/utils/partialScore.js +91 -0
- package/lib/assignment/utils/partialScore.js.map +1 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/peaks/peaksFilterImpurities.js +1 -1
- package/lib/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib/peaks/peaksToRanges.js +11 -17
- package/lib/peaks/peaksToRanges.js.map +1 -1
- package/lib/peaks/util/determineRealTop.js +3 -2
- package/lib/peaks/util/determineRealTop.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.js +33 -35
- package/lib/peaks/util/jAnalyzer.js.map +1 -1
- package/lib/ranges/rangesToXY.d.ts +2 -2
- package/lib/ranges/rangesToXY.js +10 -2
- package/lib/ranges/rangesToXY.js.map +1 -1
- package/lib/signals/signals2DToZ.d.ts +2 -2
- package/lib/signals/signalsToXY.d.ts +2 -2
- package/lib/signals/simulation/simulate1D.d.ts +4 -3
- package/lib/signals/simulation/simulate1D.js.map +1 -1
- package/lib/types/NMRPeak1D.d.ts +2 -9
- package/lib/types/NMRRange.d.ts +1 -0
- package/lib/types/NMRSignal1D.d.ts +3 -2
- package/lib/types/NMRSignal2D.d.ts +1 -0
- package/lib/types/NMRZone.d.ts +4 -3
- package/lib/xy/xyAutoPeaksPicking.d.ts +4 -60
- package/lib/xy/xyAutoPeaksPicking.js +3 -3
- package/lib/xy/xyAutoPeaksPicking.js.map +1 -1
- package/lib-esm/assignment/get13CAssignments.js +47 -0
- package/lib-esm/assignment/get13CAssignments.js.map +1 -0
- package/lib-esm/assignment/get1HAssignments.js +48 -0
- package/lib-esm/assignment/get1HAssignments.js.map +1 -0
- package/lib-esm/assignment/utils/buildAssignments.js +86 -0
- package/lib-esm/assignment/utils/buildAssignments.js.map +1 -0
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js +47 -0
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js.map +1 -0
- package/lib-esm/assignment/utils/exploreTreeRec.js +73 -0
- package/lib-esm/assignment/utils/exploreTreeRec.js.map +1 -0
- package/lib-esm/assignment/utils/generateID.js +10 -0
- package/lib-esm/assignment/utils/generateID.js.map +1 -0
- package/lib-esm/assignment/utils/partialScore.js +87 -0
- package/lib-esm/assignment/utils/partialScore.js.map +1 -0
- package/lib-esm/index.js +2 -5
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/peaks/peaksFilterImpurities.js +1 -1
- package/lib-esm/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib-esm/peaks/peaksToRanges.js +11 -17
- package/lib-esm/peaks/peaksToRanges.js.map +1 -1
- package/lib-esm/peaks/util/determineRealTop.js +4 -3
- package/lib-esm/peaks/util/determineRealTop.js.map +1 -1
- package/lib-esm/peaks/util/jAnalyzer.js +33 -35
- package/lib-esm/peaks/util/jAnalyzer.js.map +1 -1
- package/lib-esm/ranges/rangesToXY.js +10 -2
- package/lib-esm/ranges/rangesToXY.js.map +1 -1
- package/lib-esm/signals/simulation/simulate1D.js.map +1 -1
- package/lib-esm/xy/xyAutoPeaksPicking.js +3 -3
- package/lib-esm/xy/xyAutoPeaksPicking.js.map +1 -1
- package/package.json +4 -4
- package/src/assignment/get13CAssignments.ts +100 -0
- package/src/assignment/get1HAssignments.ts +116 -0
- package/src/assignment/utils/buildAssignments.ts +155 -0
- package/src/assignment/utils/createMapPossibleAssignments.ts +76 -0
- package/src/assignment/utils/exploreTreeRec.ts +138 -0
- package/src/assignment/utils/generateID.ts +11 -0
- package/src/assignment/utils/partialScore.ts +128 -0
- package/src/index.ts +3 -6
- package/src/peaks/peaksFilterImpurities.ts +1 -1
- package/src/peaks/peaksToRanges.ts +12 -19
- package/src/peaks/util/determineRealTop.ts +4 -6
- package/src/peaks/util/jAnalyzer.ts +34 -36
- package/src/ranges/rangesToXY.ts +14 -7
- package/src/signals/signals2DToZ.ts +2 -2
- package/src/signals/signalsToXY.ts +2 -2
- package/src/signals/simulation/simulate1D.ts +4 -3
- package/src/types/NMRPeak1D.ts +3 -9
- package/src/types/NMRRange.ts +1 -0
- package/src/types/NMRSignal1D.ts +3 -3
- package/src/types/NMRSignal2D.ts +2 -0
- package/src/types/NMRZone.ts +4 -3
- package/src/types/ml-spectra-processing/index.d.ts +8 -8
- package/src/types/ml-tree-set/index.d.ts +18 -0
- package/src/types/openchemlib-utils/index..d.ts +2 -2
- package/src/xy/xyAutoPeaksPicking.ts +19 -58
- package/src/types/ml-gsd/index.d.ts +0 -164
|
@@ -106,7 +106,7 @@ export default {
|
|
|
106
106
|
signal.asymmetric = false;
|
|
107
107
|
let P1, n2, maxFlagged;
|
|
108
108
|
let k = 1;
|
|
109
|
-
let
|
|
109
|
+
let jCouplings = [];
|
|
110
110
|
|
|
111
111
|
// Loop over the possible number of coupling contributing to the multiplet
|
|
112
112
|
for (let n = 0; n < 9; n++) {
|
|
@@ -144,17 +144,17 @@ export default {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
jCouplings = []; // The array to store the detected j-coupling
|
|
148
148
|
// 2.2 Set j = 1; J1 = P2 - P1. Flag components 1 and 2 as accounted for.
|
|
149
149
|
let j = 1;
|
|
150
|
-
|
|
150
|
+
jCouplings.push(peaks[1].x - peaks[0].x);
|
|
151
151
|
P1 = peaks[0].x;
|
|
152
152
|
numbering[0].splice(0, 1); // Flagged
|
|
153
153
|
numbering[1].splice(0, 1); // Flagged
|
|
154
154
|
k = 1;
|
|
155
155
|
let nFlagged = 2;
|
|
156
156
|
maxFlagged = Math.pow(2, n) - 1;
|
|
157
|
-
while (
|
|
157
|
+
while (jCouplings.length < n && nFlagged < maxFlagged && k < peaks.length) {
|
|
158
158
|
counter += 1;
|
|
159
159
|
// 4.1. Increment j. Set k to the number of the first unflagged component.
|
|
160
160
|
j++;
|
|
@@ -163,7 +163,7 @@ export default {
|
|
|
163
163
|
}
|
|
164
164
|
if (k < peaks.length) {
|
|
165
165
|
// 4.2 Jj = Pk - P1.
|
|
166
|
-
|
|
166
|
+
jCouplings.push(peaks[k].x - peaks[0].x);
|
|
167
167
|
// Flag component k and, for each sum of the...
|
|
168
168
|
numbering[k].splice(0, 1); // Flageed
|
|
169
169
|
nFlagged++;
|
|
@@ -171,7 +171,7 @@ export default {
|
|
|
171
171
|
for (let u = 2; u <= j; u++) {
|
|
172
172
|
let jSum = 0;
|
|
173
173
|
for (let i = 0; i < u; i++) {
|
|
174
|
-
jSum +=
|
|
174
|
+
jSum += jCouplings[i];
|
|
175
175
|
}
|
|
176
176
|
for (let i = 1; i < numbering.length; i++) {
|
|
177
177
|
// Maybe 0.25 Hz is too much?
|
|
@@ -185,7 +185,7 @@ export default {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
// Calculate the ideal patter by using the extracted j-couplings
|
|
188
|
-
let pattern = idealPattern(
|
|
188
|
+
let pattern = idealPattern(jCouplings);
|
|
189
189
|
// Compare the ideal pattern with the proposed intensities.
|
|
190
190
|
// All the intensities have to match to accept the multiplet
|
|
191
191
|
validPattern = true;
|
|
@@ -197,7 +197,7 @@ export default {
|
|
|
197
197
|
}
|
|
198
198
|
// If we found a valid pattern we should inform about the pattern.
|
|
199
199
|
if (validPattern) {
|
|
200
|
-
updateSignal(signal,
|
|
200
|
+
updateSignal(signal, jCouplings);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -213,58 +213,58 @@ export default {
|
|
|
213
213
|
* @private
|
|
214
214
|
* update the signal
|
|
215
215
|
* @param {*} signal
|
|
216
|
-
* @param {*}
|
|
216
|
+
* @param {*} jCouplings
|
|
217
217
|
*/
|
|
218
|
-
function updateSignal(signal: SignalInternMandatory,
|
|
218
|
+
function updateSignal(signal: SignalInternMandatory, jCouplings: number[]) {
|
|
219
219
|
// Update the limits of the signal
|
|
220
220
|
let peaks = signal.peaksComp; // Always in Hz
|
|
221
221
|
let nbPeaks = peaks.length;
|
|
222
|
-
signal.startX = peaks[0].x / signal.observe - peaks[0].
|
|
222
|
+
signal.startX = peaks[0].x / signal.observe - peaks[0].width;
|
|
223
223
|
signal.stopX =
|
|
224
|
-
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].
|
|
224
|
+
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width;
|
|
225
225
|
signal.integralData.from =
|
|
226
|
-
peaks[0].x / signal.observe - peaks[0].
|
|
226
|
+
peaks[0].x / signal.observe - peaks[0].width * 3;
|
|
227
227
|
signal.integralData.to =
|
|
228
|
-
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].
|
|
228
|
+
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3;
|
|
229
229
|
// Compile the pattern and format the constant couplings
|
|
230
230
|
signal.maskPattern = signal.mask2;
|
|
231
|
-
signal.multiplicity = abstractPattern(signal,
|
|
231
|
+
signal.multiplicity = abstractPattern(signal, jCouplings);
|
|
232
232
|
signal.pattern = signal.multiplicity; // Our library depends on this parameter, but it is old
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Returns the multiplet in the compact format
|
|
237
237
|
* @param {object} signal
|
|
238
|
-
* @param {object}
|
|
238
|
+
* @param {object} jCouplings
|
|
239
239
|
* @return {String}
|
|
240
240
|
* @private
|
|
241
241
|
*/
|
|
242
|
-
function abstractPattern(signal: SignalInternMandatory,
|
|
242
|
+
function abstractPattern(signal: SignalInternMandatory, jCouplings: number[]) {
|
|
243
243
|
let tol = 0.05;
|
|
244
244
|
let pattern = '';
|
|
245
245
|
let cont = 1;
|
|
246
246
|
let newNmrJs = [];
|
|
247
247
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
248
|
+
if (jCouplings && jCouplings.length > 0) {
|
|
249
|
+
jCouplings.sort((a, b) => {
|
|
250
250
|
return b - a;
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
-
for (let i = 0; i <
|
|
254
|
-
if (Math.abs(
|
|
253
|
+
for (let i = 0; i < jCouplings.length - 1; i++) {
|
|
254
|
+
if (Math.abs(jCouplings[i] - jCouplings[i + 1]) < tol) {
|
|
255
255
|
cont++;
|
|
256
256
|
} else {
|
|
257
257
|
newNmrJs.push({
|
|
258
|
-
coupling: Math.abs(
|
|
258
|
+
coupling: Math.abs(jCouplings[i]),
|
|
259
259
|
multiplicity: patterns[cont],
|
|
260
260
|
});
|
|
261
261
|
pattern += patterns[cont];
|
|
262
262
|
cont = 1;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
let index =
|
|
265
|
+
let index = jCouplings.length - 1;
|
|
266
266
|
newNmrJs.push({
|
|
267
|
-
coupling: Math.abs(
|
|
267
|
+
coupling: Math.abs(jCouplings[index]),
|
|
268
268
|
multiplicity: patterns[cont],
|
|
269
269
|
});
|
|
270
270
|
pattern += patterns[cont];
|
|
@@ -281,15 +281,15 @@ function abstractPattern(signal: SignalInternMandatory, Jc: number[]) {
|
|
|
281
281
|
/**
|
|
282
282
|
* This function creates an ideal pattern from the given J-couplings
|
|
283
283
|
* @private
|
|
284
|
-
* @param {Array}
|
|
284
|
+
* @param {Array} jCouplings
|
|
285
285
|
* @return {*[]}
|
|
286
286
|
* @private
|
|
287
287
|
*/
|
|
288
|
-
function idealPattern(
|
|
289
|
-
let hsum = Math.pow(2,
|
|
288
|
+
function idealPattern(jCouplings: number[]) {
|
|
289
|
+
let hsum = Math.pow(2, jCouplings.length);
|
|
290
290
|
let pattern = [{ x: 0, intensity: hsum }];
|
|
291
291
|
// To split the initial height
|
|
292
|
-
for (const jc of
|
|
292
|
+
for (const jc of jCouplings) {
|
|
293
293
|
for (let j = pattern.length - 1; j >= 0; j--) {
|
|
294
294
|
pattern.push({
|
|
295
295
|
x: pattern[j].x + jc / 2,
|
|
@@ -466,9 +466,7 @@ function symmetrize(
|
|
|
466
466
|
peaks[i] = {
|
|
467
467
|
x: peak[jAxis] * newSignal.observe,
|
|
468
468
|
intensity: peak[intensity],
|
|
469
|
-
|
|
470
|
-
width: peak.shape.width,
|
|
471
|
-
},
|
|
469
|
+
width: peak.width,
|
|
472
470
|
};
|
|
473
471
|
}
|
|
474
472
|
// Join the peaks that are closer than 0.25 Hz
|
|
@@ -480,7 +478,7 @@ function symmetrize(
|
|
|
480
478
|
peaks[i].intensity = peaks[i].intensity + peaks[i + 1].intensity;
|
|
481
479
|
peaks[i].x /= peaks[i].intensity;
|
|
482
480
|
peaks[i].intensity /= 2;
|
|
483
|
-
peaks[i].
|
|
481
|
+
peaks[i].width += peaks[i + 1].width;
|
|
484
482
|
peaks.splice(i + 1, 1);
|
|
485
483
|
}
|
|
486
484
|
}
|
|
@@ -528,11 +526,11 @@ function symmetrize(
|
|
|
528
526
|
if (Math.abs(diffL - diffR) < maxError) {
|
|
529
527
|
avg = Math.min(peaks[left].intensity, peaks[right].intensity);
|
|
530
528
|
avgWidth = Math.min(
|
|
531
|
-
peaks[left].
|
|
532
|
-
peaks[right].
|
|
529
|
+
peaks[left].width,
|
|
530
|
+
peaks[right].width,
|
|
533
531
|
);
|
|
534
532
|
peaks[left].intensity = peaks[right].intensity = avg;
|
|
535
|
-
peaks[left].
|
|
533
|
+
peaks[left].width = peaks[right].width = avgWidth;
|
|
536
534
|
middle = [
|
|
537
535
|
middle[0] + (peaks[right].x + peaks[left].x) / 2,
|
|
538
536
|
middle[1] + 1,
|
|
@@ -712,5 +710,5 @@ function chemicalShift(peaks: Peak1DIntern[], mask: boolean[] = []) {
|
|
|
712
710
|
* @private
|
|
713
711
|
*/
|
|
714
712
|
function getArea(peak: Peak1DIntern) {
|
|
715
|
-
return Math.abs(peak.intensity * peak.
|
|
713
|
+
return Math.abs(peak.intensity * peak.width * 1.57); // 1.772453851);
|
|
716
714
|
}
|
package/src/ranges/rangesToXY.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { DoubleArray } from 'cheminfo-types';
|
|
2
2
|
import arraySequentialFill from 'ml-array-sequential-fill';
|
|
3
|
+
import type { Shape1D } from 'ml-peak-shape-generator';
|
|
3
4
|
import { SpectrumGenerator } from 'spectrum-generator';
|
|
4
|
-
import type { Shape1DOptions } from 'spectrum-generator';
|
|
5
5
|
|
|
6
6
|
import { hackSignalsToXY } from '../signals/hackSignalsToXY';
|
|
7
7
|
import type { MakeMandatory } from '../types/MakeMandatory';
|
|
8
8
|
import type { NMRRange } from '../types/NMRRange';
|
|
9
9
|
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
type rangeWithSignal = MakeMandatory<NMRRange, 'signals'>;
|
|
11
|
+
type RangeWithSignal = MakeMandatory<NMRRange, 'signals'>;
|
|
13
12
|
|
|
14
13
|
export interface RangeToXYOptions {
|
|
15
14
|
/**
|
|
@@ -41,11 +40,11 @@ export interface RangeToXYOptions {
|
|
|
41
40
|
* options of signals.
|
|
42
41
|
* @default { kind: 'gaussian' }
|
|
43
42
|
*/
|
|
44
|
-
shape:
|
|
43
|
+
shape: Shape1D;
|
|
45
44
|
}
|
|
46
45
|
function checkForSignals(
|
|
47
46
|
ranges: NMRRange[],
|
|
48
|
-
): asserts ranges is
|
|
47
|
+
): asserts ranges is RangeWithSignal[] {
|
|
49
48
|
for (let range of ranges) {
|
|
50
49
|
if (!range.signals) throw new Error('range has not signals');
|
|
51
50
|
}
|
|
@@ -78,7 +77,15 @@ export function rangesToXY(ranges: NMRRange[], options: any = {}) {
|
|
|
78
77
|
|
|
79
78
|
let spectrum: DoubleArray = new Float64Array(nbPoints);
|
|
80
79
|
for (const range of ranges) {
|
|
81
|
-
const { integration, signals } = range;
|
|
80
|
+
const { integration, signals = [] } = range;
|
|
81
|
+
const { multiplicity: rangeMulplicity = '' } = range;
|
|
82
|
+
if (rangeMulplicity === 'm' && signals.length < 1) {
|
|
83
|
+
const { from, to } = range;
|
|
84
|
+
signals.push({
|
|
85
|
+
delta: (from + to) / 2,
|
|
86
|
+
multiplicity: 'm',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
82
89
|
let rangeSpectrum: DoubleArray = new Float64Array(nbPoints);
|
|
83
90
|
for (const signal of signals) {
|
|
84
91
|
const { multiplicity } = signal;
|
|
@@ -168,8 +175,8 @@ function normalizeSpectrum(
|
|
|
168
175
|
0,
|
|
169
176
|
);
|
|
170
177
|
|
|
171
|
-
const norma = (integration / sum) * 1e6;
|
|
172
178
|
if (sum !== 0) {
|
|
179
|
+
const norma = (integration / sum) * 1e6;
|
|
173
180
|
for (let i = 0; i < spectrum.length; i++) {
|
|
174
181
|
spectrum[i] *= norma;
|
|
175
182
|
}
|
|
@@ -3,7 +3,7 @@ import type { XYNumber } from 'spectrum-generator';
|
|
|
3
3
|
|
|
4
4
|
import type { NMRSignal2D } from '../types/NMRSignal2D';
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
interface Signals2DToZOptions {
|
|
7
7
|
/**
|
|
8
8
|
* lower limit in the spectrum, if it is a number the value will be defined for both axes
|
|
9
9
|
* @default -1
|
|
@@ -36,7 +36,7 @@ export interface Peak2DSeries {
|
|
|
36
36
|
|
|
37
37
|
export function signals2DToZ(
|
|
38
38
|
signals: NMRSignal2D[],
|
|
39
|
-
options:
|
|
39
|
+
options: Signals2DToZOptions = {},
|
|
40
40
|
) {
|
|
41
41
|
let { from = -1, to = 12, nbPoints = 512, width = 0.02 } = options;
|
|
42
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import rescale from 'ml-array-rescale';
|
|
2
2
|
import arraySequentialFill from 'ml-array-sequential-fill';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Shape1D } from 'ml-peak-shape-generator';
|
|
4
4
|
|
|
5
5
|
import type { MakeMandatory } from '../types/MakeMandatory';
|
|
6
6
|
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
@@ -25,7 +25,7 @@ export interface OptionsSignalsToXY {
|
|
|
25
25
|
/**
|
|
26
26
|
* Shape options for ml-spectrum-generator
|
|
27
27
|
*/
|
|
28
|
-
shape?:
|
|
28
|
+
shape?: Shape1D;
|
|
29
29
|
/**
|
|
30
30
|
* The linewidth of the output spectrum, expresed in Hz.
|
|
31
31
|
* @default 1
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import binarySearch from 'binary-search';
|
|
2
|
+
import { DataXY } from 'cheminfo-types';
|
|
2
3
|
import { Matrix, EVD } from 'ml-matrix';
|
|
3
4
|
import type { Matrix as MatrixClassType } from 'ml-matrix';
|
|
5
|
+
import type { Shape1D } from 'ml-peak-shape-generator';
|
|
4
6
|
import { SparseMatrix } from 'ml-sparse-matrix';
|
|
5
7
|
import { SpectrumGenerator } from 'spectrum-generator';
|
|
6
|
-
import type { Shape1DOptions } from 'spectrum-generator';
|
|
7
8
|
|
|
8
9
|
import type { SpinSystem } from '../../types/spinSystem';
|
|
9
10
|
|
|
@@ -46,7 +47,7 @@ interface Simulate1DOptions {
|
|
|
46
47
|
* Shape options
|
|
47
48
|
* @default {kind:'gaussian'}
|
|
48
49
|
*/
|
|
49
|
-
shape?:
|
|
50
|
+
shape?: Shape1D;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -59,7 +60,7 @@ export default function simulate1D(
|
|
|
59
60
|
*/
|
|
60
61
|
spinSystem: SpinSystem,
|
|
61
62
|
options: Simulate1DOptions = {},
|
|
62
|
-
) {
|
|
63
|
+
): DataXY {
|
|
63
64
|
let {
|
|
64
65
|
lineWidth = 1,
|
|
65
66
|
maxClusterSize = 8,
|
package/src/types/NMRPeak1D.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Peak1D } from 'ml-gsd';
|
|
2
|
+
|
|
3
|
+
export interface NMRPeak1D extends Peak1D {
|
|
2
4
|
kind?: string;
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
shape: {
|
|
6
|
-
width: number;
|
|
7
|
-
noiseLevel?: number;
|
|
8
|
-
soft?: boolean;
|
|
9
|
-
kind?: string;
|
|
10
|
-
};
|
|
11
5
|
}
|
package/src/types/NMRRange.ts
CHANGED
package/src/types/NMRSignal1D.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { NMRPeak1D } from './NMRPeak1D';
|
|
3
2
|
import type { Jcoupling } from './jcoupling';
|
|
4
3
|
|
|
5
4
|
export interface NMRSignal1D {
|
|
6
5
|
delta: number;
|
|
6
|
+
id?: string;
|
|
7
7
|
js?: Jcoupling[];
|
|
8
8
|
atoms?: number[];
|
|
9
9
|
assignment?: string;
|
|
@@ -12,7 +12,7 @@ export interface NMRSignal1D {
|
|
|
12
12
|
diaIDs?: string[];
|
|
13
13
|
nbAtoms?: number;
|
|
14
14
|
integration?: number;
|
|
15
|
-
peaks?:
|
|
15
|
+
peaks?: NMRPeak1D[];
|
|
16
16
|
statistic?: {
|
|
17
17
|
mean: number;
|
|
18
18
|
sd: number;
|
package/src/types/NMRSignal2D.ts
CHANGED
package/src/types/NMRZone.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { NMRSignal2D } from "./NMRSignal2D";
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface FromTo { from: number, to: number }
|
|
4
4
|
|
|
5
5
|
export interface NMRZone {
|
|
6
|
-
x:
|
|
7
|
-
y:
|
|
6
|
+
x: FromTo,
|
|
7
|
+
y: FromTo,
|
|
8
|
+
id?: string;
|
|
8
9
|
signals: NMRSignal2D
|
|
9
10
|
}
|
|
@@ -9,7 +9,7 @@ declare module 'ml-spectra-processing' {
|
|
|
9
9
|
options?: { zones: { from: number; to: number }[] },
|
|
10
10
|
): XYNumberArray;
|
|
11
11
|
|
|
12
|
-
interface
|
|
12
|
+
interface XNoiseSanPlotOptions {
|
|
13
13
|
mask?: boolean[];
|
|
14
14
|
cutOff?: number;
|
|
15
15
|
logBaseY?: number;
|
|
@@ -20,7 +20,7 @@ declare module 'ml-spectra-processing' {
|
|
|
20
20
|
fixOffset?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
interface
|
|
23
|
+
interface XNoiseSanPlotResult {
|
|
24
24
|
positive: number;
|
|
25
25
|
negative: number;
|
|
26
26
|
snr: number;
|
|
@@ -31,21 +31,21 @@ declare module 'ml-spectra-processing' {
|
|
|
31
31
|
}
|
|
32
32
|
function xNoiseSanPlot(
|
|
33
33
|
data: number[] | Float64Array,
|
|
34
|
-
options?:
|
|
35
|
-
):
|
|
34
|
+
options?: XNoiseSanPlotOptions,
|
|
35
|
+
): XNoiseSanPlotResult;
|
|
36
36
|
|
|
37
37
|
function xAbsoluteMedian(data: number[] | Float64Array): number;
|
|
38
38
|
|
|
39
|
-
interface
|
|
39
|
+
interface XGetFromToIndexOptions {
|
|
40
40
|
fromIndex?: number;
|
|
41
41
|
toIndex?: number;
|
|
42
42
|
from?: number;
|
|
43
43
|
to?: number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
interface
|
|
46
|
+
interface XYIntegrationOptions extends XGetFromToIndexOptions {}
|
|
47
47
|
|
|
48
|
-
function xyIntegration(data: XYNumberArray, options?:
|
|
48
|
+
function xyIntegration(data: XYNumberArray, options?: XYIntegrationOptions): number;
|
|
49
49
|
|
|
50
|
-
function xGetFromToIndex(x: number[] | Float64Array, options?:
|
|
50
|
+
function xGetFromToIndex(x: number[] | Float64Array, options?: XGetFromToIndexOptions): number;
|
|
51
51
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module 'ml-tree-set' {
|
|
2
|
+
type Comparator = (a: Elements, b: Elements) => number;
|
|
3
|
+
type Elements = any;
|
|
4
|
+
export default class TreeSet {
|
|
5
|
+
public length: number;
|
|
6
|
+
public elements: Array<Elements>;
|
|
7
|
+
|
|
8
|
+
public constructor(comparator: Comparator);
|
|
9
|
+
|
|
10
|
+
public size: () => number;
|
|
11
|
+
public last: () => Elements;
|
|
12
|
+
public first: () => Elements;
|
|
13
|
+
public isEmpty: () => boolean;
|
|
14
|
+
public pollLast: () => void;
|
|
15
|
+
public pollFirst: () => void;
|
|
16
|
+
public add(element: Elements): () => void;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -110,7 +110,7 @@ declare module 'openchemlib-utils' {
|
|
|
110
110
|
|
|
111
111
|
function getHoseCodesForPath(molecule: Molecule, from: string, to: string, maxLength: number): HoseCodesForPath;
|
|
112
112
|
|
|
113
|
-
export interface
|
|
113
|
+
export interface GetConnectivityMatrixOptions {
|
|
114
114
|
/**
|
|
115
115
|
* get the path length between atoms
|
|
116
116
|
* @default false
|
|
@@ -142,7 +142,7 @@ declare module 'openchemlib-utils' {
|
|
|
142
142
|
*/
|
|
143
143
|
stda?: boolean | number;
|
|
144
144
|
}
|
|
145
|
-
function getConnectivityMatrix(molecule: Molecule, options?:
|
|
145
|
+
function getConnectivityMatrix(molecule: Molecule, options?: GetConnectivityMatrixOptions): number[][] | Float64Array[];
|
|
146
146
|
|
|
147
147
|
function getDiastereotopicAtomIDs(molecule: Molecule): string[];
|
|
148
148
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { DataXY } from 'cheminfo-types';
|
|
2
2
|
import { gsd, joinBroadPeaks, optimizePeaks } from 'ml-gsd';
|
|
3
|
+
import type {
|
|
4
|
+
Peak1D,
|
|
5
|
+
IGSDOptions,
|
|
6
|
+
IOptimizePeaksOptions,
|
|
7
|
+
IJoinBroadPeaksOptions,
|
|
8
|
+
} from 'ml-gsd';
|
|
3
9
|
import {
|
|
4
10
|
xyExtract,
|
|
5
11
|
xNoiseSanPlot,
|
|
6
12
|
xAbsoluteMedian,
|
|
7
13
|
} from 'ml-spectra-processing';
|
|
8
14
|
|
|
9
|
-
import type { NMRPeak1D } from '../types/NMRPeak1D';
|
|
10
15
|
/**
|
|
11
16
|
* Implementation of the peak picking method described by Cobas in:
|
|
12
17
|
* A new approach to improving automated analysis of proton NMR spectra
|
|
@@ -20,63 +25,19 @@ interface OptionsGetCutOff {
|
|
|
20
25
|
thresholdFactor: number;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
noiseLevel?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Threshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak.
|
|
31
|
-
* @default 0.01
|
|
32
|
-
*/
|
|
33
|
-
minMaxRatio: number;
|
|
34
|
-
/**
|
|
35
|
-
* If broadRatio is higher than 0, then all the peaks which second derivative smaller than broadRatio * maxAbsSecondDerivative will be marked with the soft mask equal to true.
|
|
36
|
-
* @default 0.00025
|
|
37
|
-
*/
|
|
38
|
-
broadRatio: number;
|
|
39
|
-
/**
|
|
40
|
-
* Select the peak intensities from a smoothed version of the independent variables.
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
smoothY: boolean;
|
|
28
|
+
export interface IGetPeakListOptions
|
|
29
|
+
extends IGSDOptions,
|
|
30
|
+
IOptimizePeaksOptions,
|
|
31
|
+
IJoinBroadPeaksOptions {
|
|
44
32
|
/**
|
|
45
33
|
* If it is true, the peaks parameters will be optimized.
|
|
46
34
|
* @default false
|
|
47
35
|
*/
|
|
48
36
|
optimize: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* factor to determine the width at the moment to group the peaks in signals in 'GSD.optimizePeaks' function.
|
|
51
|
-
* @default 4
|
|
52
|
-
*/
|
|
53
|
-
factorWidth: number;
|
|
54
|
-
/**
|
|
55
|
-
* if it is true, it optimizes the x and intensity by extrapolation.
|
|
56
|
-
*/
|
|
57
|
-
realTopDetection: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* options to shape used to adapt the FWHM
|
|
60
|
-
* @default {kind:'gaussian'}
|
|
61
|
-
*/
|
|
62
|
-
shape: { kind: string };
|
|
63
|
-
/**
|
|
64
|
-
* options for optimization step, kind represent the algorithm
|
|
65
|
-
* @default {kind:'lm'}
|
|
66
|
-
*/
|
|
67
|
-
optimization: { kind: string };
|
|
68
|
-
/**
|
|
69
|
-
* Threshold to determine if some peak is candidate to clustering into range.
|
|
70
|
-
* @default 0.25
|
|
71
|
-
*/
|
|
72
|
-
broadWidth: number;
|
|
73
|
-
/**
|
|
74
|
-
* Options for savitz Golay
|
|
75
|
-
*/
|
|
76
|
-
sgOptions: { windowSize: number; polynomial: number };
|
|
77
37
|
}
|
|
78
38
|
|
|
79
|
-
export interface OptionsXYAutoPeaksPicking
|
|
39
|
+
export interface OptionsXYAutoPeaksPicking
|
|
40
|
+
extends Partial<IGetPeakListOptions> {
|
|
80
41
|
/**
|
|
81
42
|
* Low limit value in the x axis to extract a sub set of points from the input data.
|
|
82
43
|
*/
|
|
@@ -105,7 +66,7 @@ export interface OptionsXYAutoPeaksPicking extends Partial<OptionsGetPeakList> {
|
|
|
105
66
|
export function xyAutoPeaksPicking(
|
|
106
67
|
data: DataXY,
|
|
107
68
|
options: OptionsXYAutoPeaksPicking = {},
|
|
108
|
-
):
|
|
69
|
+
): Peak1D[] {
|
|
109
70
|
const {
|
|
110
71
|
from,
|
|
111
72
|
to,
|
|
@@ -131,7 +92,7 @@ export function xyAutoPeaksPicking(
|
|
|
131
92
|
|
|
132
93
|
const cutOff = getCutOff(data.y, { noiseLevel, useSanPlot, thresholdFactor });
|
|
133
94
|
|
|
134
|
-
let getPeakOptions = {
|
|
95
|
+
let getPeakOptions: IGetPeakListOptions = {
|
|
135
96
|
shape,
|
|
136
97
|
broadWidth,
|
|
137
98
|
optimize,
|
|
@@ -154,7 +115,7 @@ export function xyAutoPeaksPicking(
|
|
|
154
115
|
return peaks;
|
|
155
116
|
}
|
|
156
117
|
|
|
157
|
-
function getPeakList(data: DataXY, options:
|
|
118
|
+
function getPeakList(data: DataXY, options: IGetPeakListOptions) {
|
|
158
119
|
const {
|
|
159
120
|
shape,
|
|
160
121
|
broadWidth,
|
|
@@ -173,15 +134,15 @@ function getPeakList(data: DataXY, options: OptionsGetPeakList) {
|
|
|
173
134
|
shape,
|
|
174
135
|
sgOptions,
|
|
175
136
|
minMaxRatio,
|
|
176
|
-
broadRatio,
|
|
177
137
|
noiseLevel,
|
|
178
138
|
smoothY,
|
|
179
139
|
realTopDetection,
|
|
180
140
|
});
|
|
181
141
|
|
|
182
142
|
if (broadWidth) {
|
|
183
|
-
peakList = joinBroadPeaks(peakList, {
|
|
184
|
-
|
|
143
|
+
peakList = joinBroadPeaks(data, peakList, {
|
|
144
|
+
broadRatio,
|
|
145
|
+
broadWidth,
|
|
185
146
|
shape,
|
|
186
147
|
optimization,
|
|
187
148
|
});
|
|
@@ -198,7 +159,7 @@ function getPeakList(data: DataXY, options: OptionsGetPeakList) {
|
|
|
198
159
|
return peakList;
|
|
199
160
|
}
|
|
200
161
|
|
|
201
|
-
function getNegativePeaks(data: DataXY, options:
|
|
162
|
+
function getNegativePeaks(data: DataXY, options: IGetPeakListOptions) {
|
|
202
163
|
let { x, y } = data;
|
|
203
164
|
let negativeDataY = new Float64Array(data.y.length);
|
|
204
165
|
for (let i = 0; i < negativeDataY.length; i++) {
|