nmr-processing 3.4.0 → 6.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/lib/assignment/get13CAssignments.js.map +1 -1
- package/lib/assignment/utils/buildAssignments.js +0 -1
- package/lib/assignment/utils/buildAssignments.js.map +1 -1
- package/lib/assignment/utils/createMapPossibleAssignments.js +0 -1
- package/lib/assignment/utils/createMapPossibleAssignments.js.map +1 -1
- package/lib/constants/couplingValues.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +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.d.ts +2 -2
- package/lib/peaks/util/determineRealTop.js +3 -2
- package/lib/peaks/util/determineRealTop.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.js +12 -13
- package/lib/peaks/util/jAnalyzer.js.map +1 -1
- package/lib/peaks/util/peakOptimizer.d.ts +2 -2
- package/lib/peaks/util/peakOptimizer.js.map +1 -1
- package/lib/prediction/predictAll.js +1 -1
- package/lib/prediction/predictAll.js.map +1 -1
- package/lib/prediction/predictHSQC.js.map +1 -1
- package/lib/prediction/predictProton.js +1 -1
- package/lib/prediction/predictProton.js.map +1 -1
- package/lib/prediction/utils/getFilteredIDiaIDs.js.map +1 -1
- package/lib/prediction/utils/getNuclei.js +1 -1
- package/lib/prediction/utils/getNuclei.js.map +1 -1
- package/lib/prediction/utils/getPredictions.d.ts +2 -2
- package/lib/prediction/utils/queryByHOSE.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/signal/signalJoinCouplings.d.ts +1 -1
- package/lib/signal/signalJoinCouplings.js +3 -3
- package/lib/signal/signalJoinCouplings.js.map +1 -1
- package/lib/signals/signalsJoin.d.ts +1 -1
- package/lib/signals/signalsJoin.js +7 -7
- package/lib/signals/signalsJoin.js.map +1 -1
- 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/signals/simulation/splitSpinSystem.js.map +1 -1
- package/lib/types/NMRPeak1D.d.ts +2 -9
- package/lib/types/NMRSignal2D.d.ts +6 -6
- package/lib/types/NMRZone.d.ts +3 -7
- package/lib/types/jcoupling.d.ts +1 -1
- package/lib/types/modules/nmr-parser.d.ts +11 -0
- package/lib/types/modules/nmr-parser.js +2 -0
- package/lib/types/modules/nmr-parser.js.map +1 -0
- package/lib/types/prediction1D.d.ts +2 -2
- package/lib/utilities/joinPatterns.js.map +1 -1
- 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/xyz/{xyzAutoPeaksPicking.d.ts → xyzAutoZonesPicking.d.ts} +2 -2
- package/lib/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +38 -24
- package/lib/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib/xyz/xyzJResAnalyzer.js.map +1 -1
- package/lib-esm/assignment/get13CAssignments.js.map +1 -1
- package/lib-esm/assignment/utils/buildAssignments.js +0 -1
- package/lib-esm/assignment/utils/buildAssignments.js.map +1 -1
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js +0 -1
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js.map +1 -1
- package/lib-esm/constants/couplingValues.js.map +1 -1
- package/lib-esm/index.js +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 +12 -13
- package/lib-esm/peaks/util/jAnalyzer.js.map +1 -1
- package/lib-esm/peaks/util/peakOptimizer.js.map +1 -1
- package/lib-esm/prediction/predictAll.js +1 -1
- package/lib-esm/prediction/predictAll.js.map +1 -1
- package/lib-esm/prediction/predictHSQC.js.map +1 -1
- package/lib-esm/prediction/predictProton.js +1 -1
- package/lib-esm/prediction/predictProton.js.map +1 -1
- package/lib-esm/prediction/utils/getFilteredIDiaIDs.js.map +1 -1
- package/lib-esm/prediction/utils/getNuclei.js +1 -1
- package/lib-esm/prediction/utils/getNuclei.js.map +1 -1
- package/lib-esm/prediction/utils/queryByHOSE.js.map +1 -1
- package/lib-esm/ranges/rangesToXY.js +10 -2
- package/lib-esm/ranges/rangesToXY.js.map +1 -1
- package/lib-esm/signal/signalJoinCouplings.js +3 -3
- package/lib-esm/signal/signalJoinCouplings.js.map +1 -1
- package/lib-esm/signals/signalsJoin.js +7 -7
- package/lib-esm/signals/signalsJoin.js.map +1 -1
- package/lib-esm/signals/simulation/simulate1D.js.map +1 -1
- package/lib-esm/signals/simulation/splitSpinSystem.js.map +1 -1
- package/lib-esm/types/modules/nmr-parser.js +2 -0
- package/lib-esm/types/modules/nmr-parser.js.map +1 -0
- package/lib-esm/utilities/joinPatterns.js.map +1 -1
- package/lib-esm/xy/xyAutoPeaksPicking.js +3 -3
- package/lib-esm/xy/xyAutoPeaksPicking.js.map +1 -1
- package/lib-esm/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +36 -22
- package/lib-esm/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib-esm/xyz/xyzJResAnalyzer.js.map +1 -1
- package/package.json +19 -16
- package/src/assignment/get13CAssignments.ts +4 -1
- package/src/assignment/utils/buildAssignments.ts +2 -5
- package/src/assignment/utils/createMapPossibleAssignments.ts +4 -2
- package/src/constants/couplingValues.ts +1 -1
- package/src/index.ts +1 -1
- package/src/peaks/peaksFilterImpurities.ts +1 -1
- package/src/peaks/peaksToRanges.ts +11 -17
- package/src/peaks/util/determineRealTop.ts +6 -9
- package/src/peaks/util/jAnalyzer.ts +14 -16
- package/src/peaks/util/peakOptimizer.ts +4 -3
- package/src/prediction/predictAll.ts +5 -5
- package/src/prediction/predictHSQC.ts +4 -1
- package/src/prediction/predictProton.ts +1 -1
- package/src/prediction/utils/getFilteredIDiaIDs.ts +1 -2
- package/src/prediction/utils/getNuclei.ts +3 -3
- package/src/prediction/utils/getPredictions.ts +3 -3
- package/src/prediction/utils/queryByHOSE.ts +1 -1
- package/src/ranges/rangesToXY.ts +12 -5
- package/src/signal/signalJoinCouplings.ts +3 -3
- package/src/signals/signalsJoin.ts +7 -7
- package/src/signals/signalsToXY.ts +3 -3
- package/src/signals/simulation/simulate1D.ts +4 -3
- package/src/signals/simulation/splitSpinSystem.ts +10 -2
- package/src/types/NMRPeak1D.ts +3 -9
- package/src/types/NMRSignal2D.ts +7 -7
- package/src/types/NMRZone.ts +6 -6
- package/src/types/dataStructure.ts +1 -1
- package/src/types/jcoupling.ts +1 -1
- package/src/types/ml-matrix-peaks-finder/index.d.ts +2 -2
- package/src/types/ml-simple-clustering/index.d.ts +1 -1
- package/src/types/ml-spectra-processing/index.d.ts +8 -2
- package/src/types/modules/nmr-parser.ts +17 -0
- package/src/types/openchemlib-utils/index..d.ts +17 -6
- package/src/types/prediction1D.ts +2 -2
- package/src/utilities/joinPatterns.ts +0 -1
- package/src/xy/xyAutoPeaksPicking.ts +19 -58
- package/src/xyz/{xyzAutoPeaksPicking.ts → xyzAutoZonesPicking.ts} +40 -24
- package/src/xyz/xyzJResAnalyzer.ts +4 -4
- package/CHANGELOG.md +0 -543
- package/lib/types/MPFPeak.d.ts +0 -9
- package/lib/types/MPFPeak.js +0 -3
- package/lib/types/MPFPeak.js.map +0 -1
- package/lib/xyz/xyzAutoPeaksPicking.js.map +0 -1
- package/lib-esm/types/MPFPeak.js +0 -2
- package/lib-esm/types/MPFPeak.js.map +0 -1
- package/lib-esm/xyz/xyzAutoPeaksPicking.js.map +0 -1
- package/src/types/MPFPeak.ts +0 -9
- package/src/types/ml-gsd/index.d.ts +0 -164
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmr-processing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Pure functions allowing to process NMR spectra.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -16,9 +16,12 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"clean": "rimraf lib lib-esm",
|
|
18
18
|
"build": "npm run tsc && cheminfo-build",
|
|
19
|
-
"
|
|
19
|
+
"check-types": "tsc --noEmit",
|
|
20
|
+
"eslint": "eslint src --cache",
|
|
20
21
|
"eslint-fix": "npm run eslint -- --fix",
|
|
21
22
|
"prepack": "npm run tsc",
|
|
23
|
+
"prettier": "prettier --check src",
|
|
24
|
+
"prettier-write": "prettier --write src",
|
|
22
25
|
"test": "npm run test-coverage && npm run eslint",
|
|
23
26
|
"test-coverage": "npm run test-only -- --coverage",
|
|
24
27
|
"test-only": "jest",
|
|
@@ -46,45 +49,45 @@
|
|
|
46
49
|
"trailingComma": "all"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@types/jest": "^27.0.
|
|
52
|
+
"@types/jest": "^27.0.3",
|
|
50
53
|
"cheminfo-build": "^1.1.11",
|
|
51
|
-
"cheminfo-types": "^0.
|
|
52
|
-
"eslint": "^8.0
|
|
53
|
-
"eslint-config-cheminfo-typescript": "^10.
|
|
54
|
+
"cheminfo-types": "^0.8.0",
|
|
55
|
+
"eslint": "^8.3.0",
|
|
56
|
+
"eslint-config-cheminfo-typescript": "^10.2.4",
|
|
54
57
|
"esm": "^3.2.25",
|
|
55
|
-
"jest": "^27.2
|
|
58
|
+
"jest": "^27.4.2",
|
|
56
59
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
57
60
|
"md5": "^2.3.0",
|
|
58
61
|
"ml-array-median": "^1.1.5",
|
|
59
62
|
"nmr-xy-testdata": "^0.2.1",
|
|
60
63
|
"openchemlib": "^7.4.3",
|
|
61
|
-
"prettier": "^2.
|
|
64
|
+
"prettier": "^2.5.0",
|
|
62
65
|
"rimraf": "^3.0.2",
|
|
63
|
-
"ts-jest": "^27.0.
|
|
64
|
-
"typescript": "^4.
|
|
66
|
+
"ts-jest": "^27.0.7",
|
|
67
|
+
"typescript": "^4.5.2"
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
67
70
|
"assign-deep": "^1.0.1",
|
|
68
71
|
"binary-search": "^1.3.6",
|
|
69
72
|
"cross-fetch": "^3.1.4",
|
|
70
73
|
"form-data": "^4.0.0",
|
|
71
|
-
"is-any-array": "^
|
|
74
|
+
"is-any-array": "^2.0.0",
|
|
72
75
|
"ml-array-mean": "^1.1.5",
|
|
73
76
|
"ml-array-rescale": "^1.3.6",
|
|
74
77
|
"ml-array-sequential-fill": "^1.1.7",
|
|
75
78
|
"ml-array-sum": "^1.1.5",
|
|
76
|
-
"ml-gsd": "^
|
|
79
|
+
"ml-gsd": "^9.0.3",
|
|
77
80
|
"ml-hclust": "^3.1.0",
|
|
78
81
|
"ml-levenberg-marquardt": "^3.1.1",
|
|
79
|
-
"ml-matrix": "^6.8.
|
|
82
|
+
"ml-matrix": "^6.8.2",
|
|
80
83
|
"ml-matrix-convolution": "^1.0.0",
|
|
81
84
|
"ml-matrix-peaks-finder": "^1.0.0",
|
|
82
|
-
"ml-peak-shape-generator": "^
|
|
85
|
+
"ml-peak-shape-generator": "^4.0.1",
|
|
83
86
|
"ml-simple-clustering": "^0.1.0",
|
|
84
87
|
"ml-sparse-matrix": "^2.1.0",
|
|
85
88
|
"ml-spectra-processing": "^6.8.0",
|
|
86
89
|
"ml-tree-set": "^0.1.1",
|
|
87
|
-
"openchemlib-utils": "^1.
|
|
88
|
-
"spectrum-generator": "^
|
|
90
|
+
"openchemlib-utils": "^1.6.0",
|
|
91
|
+
"spectrum-generator": "^6.0.2"
|
|
89
92
|
}
|
|
90
93
|
}
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from '../prediction/predictCarbon';
|
|
9
9
|
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
NMRSignal1DWithAtomsAndDiaIDs,
|
|
13
|
+
Targets,
|
|
14
|
+
} from './get1HAssignments';
|
|
12
15
|
import { RestrictionByCS, buildAssignments } from './utils/buildAssignments';
|
|
13
16
|
import generateID from './utils/generateID';
|
|
14
17
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import treeSet from 'ml-tree-set';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Targets,
|
|
5
|
-
NMRSignal1DWithAtomsAndDiaIDs,
|
|
6
|
-
} from '../get1HAssignments';
|
|
3
|
+
import { Targets, NMRSignal1DWithAtomsAndDiaIDs } from '../get1HAssignments';
|
|
7
4
|
|
|
8
5
|
import { createMapPossibleAssignments } from './createMapPossibleAssignments';
|
|
9
6
|
import { exploreTreeRec } from './exploreTreeRec';
|
|
@@ -94,7 +91,7 @@ export async function buildAssignments(props: BuildAssignmentsProps) {
|
|
|
94
91
|
predictions,
|
|
95
92
|
targets,
|
|
96
93
|
});
|
|
97
|
-
|
|
94
|
+
|
|
98
95
|
const diaIDPeerPossibleAssignment = Object.keys(possibleAssignmentMap);
|
|
99
96
|
|
|
100
97
|
let partial = fillPartial(nSources);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MakeMandatory } from '../../types/MakeMandatory';
|
|
2
2
|
import type { Targets } from '../get1HAssignments';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
RestrictionByCS,
|
|
6
|
+
Predictions1Dassignments,
|
|
7
|
+
} from './buildAssignments';
|
|
5
8
|
|
|
6
9
|
type RestrictionByCSMandatory = MakeMandatory<
|
|
7
10
|
RestrictionByCS,
|
|
@@ -27,7 +30,6 @@ export function createMapPossibleAssignments(
|
|
|
27
30
|
const { tolerance: toleranceCS, chemicalShiftRestriction } = restrictionByCS;
|
|
28
31
|
|
|
29
32
|
let errorAbs = Math.abs(toleranceCS);
|
|
30
|
-
console.log('use INT', useIntegrationRestriction)
|
|
31
33
|
const expandMap: PossibleAssignmentMap = {};
|
|
32
34
|
for (const diaID in predictions) {
|
|
33
35
|
let prediction = predictions[diaID];
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ export * from './utilities/rangeFromSignal';
|
|
|
27
27
|
export * from './xy/xyAutoPeaksPicking';
|
|
28
28
|
export * from './xy/xyAutoRangesPicking';
|
|
29
29
|
|
|
30
|
-
export * from './xyz/
|
|
30
|
+
export * from './xyz/xyzAutoZonesPicking';
|
|
31
31
|
export * from './xyz/xyzJResAnalyzer';
|
|
32
32
|
|
|
33
33
|
export * from './databases/getDatabase';
|
|
@@ -66,7 +66,7 @@ function checkImpurity(
|
|
|
66
66
|
while (i--) {
|
|
67
67
|
j = peakList.length;
|
|
68
68
|
while (j--) {
|
|
69
|
-
tolerance = error + peakList[j].
|
|
69
|
+
tolerance = error + peakList[j].width;
|
|
70
70
|
difference = Math.abs(impurity[i].shift - peakList[j].x);
|
|
71
71
|
if (difference < tolerance) {
|
|
72
72
|
// && (impurity[i].multiplicity === '' || (impurity[i].multiplicity.indexOf(peakList[j].multiplicity)) { // some impurities has multiplicities like 'bs' but at presents it is unsupported
|
|
@@ -91,22 +91,20 @@ const assignSignal = (
|
|
|
91
91
|
delta: NaN,
|
|
92
92
|
nbPeaks: 1,
|
|
93
93
|
kind: 'signal',
|
|
94
|
-
startX: peak.x - peak.
|
|
95
|
-
stopX: peak.x + peak.
|
|
94
|
+
startX: peak.x - peak.width,
|
|
95
|
+
stopX: peak.x + peak.width,
|
|
96
96
|
observe: frequency,
|
|
97
97
|
nucleus,
|
|
98
98
|
integralData: {
|
|
99
|
-
from: peak.x - peak.
|
|
100
|
-
to: peak.x + peak.
|
|
99
|
+
from: peak.x - peak.width * 3,
|
|
100
|
+
to: peak.x + peak.width * 3,
|
|
101
101
|
value: 0,
|
|
102
102
|
},
|
|
103
103
|
peaks: [
|
|
104
104
|
{
|
|
105
105
|
x: peak.x,
|
|
106
106
|
intensity: peak.y,
|
|
107
|
-
|
|
108
|
-
width: peak.shape.width,
|
|
109
|
-
},
|
|
107
|
+
width: peak.width,
|
|
110
108
|
},
|
|
111
109
|
],
|
|
112
110
|
};
|
|
@@ -177,9 +175,7 @@ export function peaksToRanges(
|
|
|
177
175
|
peaksO.push({
|
|
178
176
|
x: peakR.x,
|
|
179
177
|
y: peakR.intensity,
|
|
180
|
-
|
|
181
|
-
width: peakR.shape.width,
|
|
182
|
-
},
|
|
178
|
+
width: peakR.width,
|
|
183
179
|
});
|
|
184
180
|
signal.mask.splice(j, 1);
|
|
185
181
|
signal.mask2.splice(j, 1);
|
|
@@ -306,24 +302,22 @@ function detectSignals(
|
|
|
306
302
|
if (peak.kind) signal1D.kind = peak.kind;
|
|
307
303
|
signals.push(signal1D);
|
|
308
304
|
} else {
|
|
309
|
-
let tmp = peak.x + peak.
|
|
305
|
+
let tmp = peak.x + peak.width;
|
|
310
306
|
signal1D.stopX = Math.max(signal1D.stopX, tmp);
|
|
311
307
|
signal1D.startX = Math.min(signal1D.startX, tmp);
|
|
312
308
|
signal1D.nbPeaks++;
|
|
313
309
|
signal1D.peaks.push({
|
|
314
310
|
x: peak.x,
|
|
315
311
|
intensity: peak.y,
|
|
316
|
-
|
|
317
|
-
width: peak.shape.width,
|
|
318
|
-
},
|
|
312
|
+
width: peak.width,
|
|
319
313
|
});
|
|
320
314
|
signal1D.integralData.from = Math.min(
|
|
321
315
|
signal1D.integralData.from,
|
|
322
|
-
peak.x - peak.
|
|
316
|
+
peak.x - peak.width * 3,
|
|
323
317
|
);
|
|
324
318
|
signal1D.integralData.to = Math.max(
|
|
325
319
|
signal1D.integralData.to,
|
|
326
|
-
peak.x + peak.
|
|
320
|
+
peak.x + peak.width * 3,
|
|
327
321
|
);
|
|
328
322
|
if (peak.kind) signal1D.kind = peak.kind;
|
|
329
323
|
}
|
|
@@ -371,5 +365,5 @@ function detectSignals(
|
|
|
371
365
|
* @private
|
|
372
366
|
*/
|
|
373
367
|
function computeArea(peak: Peak1DIntern) {
|
|
374
|
-
return Math.abs(peak.intensity * peak.
|
|
368
|
+
return Math.abs(peak.intensity * peak.width * 1.57); // todo add an option with this value: 1.772453851
|
|
375
369
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import LM from 'ml-levenberg-marquardt';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { MPFPeak } from '../../types/MPFPeak';
|
|
5
|
-
|
|
6
|
-
const { fct: gaussian2DFct } = gaussian2D;
|
|
2
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
3
|
+
import { Gaussian2D } from 'ml-peak-shape-generator';
|
|
7
4
|
|
|
8
5
|
const direction8X = [-1, -1, -1, 0, 0, 1, 1, 1];
|
|
9
6
|
const direction8Y = [-1, 0, 1, -1, 1, -1, 0, 1];
|
|
@@ -12,7 +9,7 @@ const direction16Y = [-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2];
|
|
|
12
9
|
|
|
13
10
|
type Data = number[] | Float64Array;
|
|
14
11
|
|
|
15
|
-
export function determineRealTop(peaks:
|
|
12
|
+
export function determineRealTop(peaks: Peak2D[], options: any) {
|
|
16
13
|
let { nCols, absoluteData, originalData, minX, maxX, minY, maxY } = options;
|
|
17
14
|
for (let i = 0; i < peaks.length; i++) {
|
|
18
15
|
let xIndex = Math.round(peaks[i].x);
|
|
@@ -142,6 +139,7 @@ function fitGaussian(
|
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
function paramGaussian2D(intervalX: number, intervalY: number, nCols: number) {
|
|
142
|
+
const gaussian2D = new Gaussian2D();
|
|
145
143
|
return (p: number[]) => {
|
|
146
144
|
return (t: number) => {
|
|
147
145
|
let nL = p.length / 5;
|
|
@@ -149,13 +147,12 @@ function paramGaussian2D(intervalX: number, intervalY: number, nCols: number) {
|
|
|
149
147
|
let xIndex = t % nCols;
|
|
150
148
|
let yIndex = (t - xIndex) / nCols;
|
|
151
149
|
for (let i = 0; i < nL; i++) {
|
|
150
|
+
gaussian2D.fwhm = { x: p[i + 3 * nL], y: p[i + 4 * nL] };
|
|
152
151
|
result +=
|
|
153
152
|
p[i + 2 * nL] *
|
|
154
|
-
|
|
153
|
+
gaussian2D.fct(
|
|
155
154
|
(xIndex - p[i]) * intervalX,
|
|
156
155
|
(yIndex - p[i + nL]) * intervalY,
|
|
157
|
-
p[i + 3 * nL],
|
|
158
|
-
p[i + 4 * nL],
|
|
159
156
|
);
|
|
160
157
|
}
|
|
161
158
|
return result;
|
|
@@ -154,7 +154,11 @@ export default {
|
|
|
154
154
|
k = 1;
|
|
155
155
|
let nFlagged = 2;
|
|
156
156
|
maxFlagged = Math.pow(2, n) - 1;
|
|
157
|
-
while (
|
|
157
|
+
while (
|
|
158
|
+
jCouplings.length < n &&
|
|
159
|
+
nFlagged < maxFlagged &&
|
|
160
|
+
k < peaks.length
|
|
161
|
+
) {
|
|
158
162
|
counter += 1;
|
|
159
163
|
// 4.1. Increment j. Set k to the number of the first unflagged component.
|
|
160
164
|
j++;
|
|
@@ -219,13 +223,12 @@ function updateSignal(signal: SignalInternMandatory, jCouplings: number[]) {
|
|
|
219
223
|
// Update the limits of the signal
|
|
220
224
|
let peaks = signal.peaksComp; // Always in Hz
|
|
221
225
|
let nbPeaks = peaks.length;
|
|
222
|
-
signal.startX = peaks[0].x / signal.observe - peaks[0].
|
|
226
|
+
signal.startX = peaks[0].x / signal.observe - peaks[0].width;
|
|
223
227
|
signal.stopX =
|
|
224
|
-
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].
|
|
225
|
-
signal.integralData.from =
|
|
226
|
-
peaks[0].x / signal.observe - peaks[0].shape.width * 3;
|
|
228
|
+
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width;
|
|
229
|
+
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3;
|
|
227
230
|
signal.integralData.to =
|
|
228
|
-
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].
|
|
231
|
+
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3;
|
|
229
232
|
// Compile the pattern and format the constant couplings
|
|
230
233
|
signal.maskPattern = signal.mask2;
|
|
231
234
|
signal.multiplicity = abstractPattern(signal, jCouplings);
|
|
@@ -466,9 +469,7 @@ function symmetrize(
|
|
|
466
469
|
peaks[i] = {
|
|
467
470
|
x: peak[jAxis] * newSignal.observe,
|
|
468
471
|
intensity: peak[intensity],
|
|
469
|
-
|
|
470
|
-
width: peak.shape.width,
|
|
471
|
-
},
|
|
472
|
+
width: peak.width,
|
|
472
473
|
};
|
|
473
474
|
}
|
|
474
475
|
// Join the peaks that are closer than 0.25 Hz
|
|
@@ -480,7 +481,7 @@ function symmetrize(
|
|
|
480
481
|
peaks[i].intensity = peaks[i].intensity + peaks[i + 1].intensity;
|
|
481
482
|
peaks[i].x /= peaks[i].intensity;
|
|
482
483
|
peaks[i].intensity /= 2;
|
|
483
|
-
peaks[i].
|
|
484
|
+
peaks[i].width += peaks[i + 1].width;
|
|
484
485
|
peaks.splice(i + 1, 1);
|
|
485
486
|
}
|
|
486
487
|
}
|
|
@@ -527,12 +528,9 @@ function symmetrize(
|
|
|
527
528
|
|
|
528
529
|
if (Math.abs(diffL - diffR) < maxError) {
|
|
529
530
|
avg = Math.min(peaks[left].intensity, peaks[right].intensity);
|
|
530
|
-
avgWidth = Math.min(
|
|
531
|
-
peaks[left].shape.width,
|
|
532
|
-
peaks[right].shape.width,
|
|
533
|
-
);
|
|
531
|
+
avgWidth = Math.min(peaks[left].width, peaks[right].width);
|
|
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
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
2
|
+
|
|
2
3
|
import type { NMRSignal2D } from '../../types/NMRSignal2D';
|
|
3
4
|
|
|
4
5
|
let diagonalError = 0.05;
|
|
5
6
|
let tolerance = 0.05;
|
|
6
7
|
|
|
7
|
-
export function clean(peaks:
|
|
8
|
+
export function clean(peaks: Peak2D[], threshold: number) {
|
|
8
9
|
let max = Number.NEGATIVE_INFINITY;
|
|
9
10
|
// double min = Double.MAX_VALUE;
|
|
10
11
|
for (let i = peaks.length - 1; i >= 0; i--) {
|
|
@@ -151,7 +152,7 @@ function completeMissingIfNeeded(
|
|
|
151
152
|
},
|
|
152
153
|
peaks: [{ x: thisSignal.x.delta, y: thisSignal.x.delta, z: 1 }],
|
|
153
154
|
};
|
|
154
|
-
newSignal.peaks = [{ x: thisSignal.x.delta, y: thisSignal.x.delta, z: 1 }]
|
|
155
|
+
newSignal.peaks = [{ x: thisSignal.x.delta, y: thisSignal.x.delta, z: 1 }];
|
|
155
156
|
output.push(newSignal);
|
|
156
157
|
tmpProp = [0, thisProp[1]];
|
|
157
158
|
properties.push(tmpProp);
|
|
@@ -10,7 +10,6 @@ import { predictProton, PredictProtonOptions } from './predictProton';
|
|
|
10
10
|
import { getPredictions } from './utils/getPredictions';
|
|
11
11
|
import type { Predictor } from './utils/predict2D';
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
export interface PredictAllOptions {
|
|
15
14
|
/**
|
|
16
15
|
* nucleus label to use in the X axis
|
|
@@ -93,13 +92,14 @@ export async function predictAll(
|
|
|
93
92
|
predictions,
|
|
94
93
|
);
|
|
95
94
|
|
|
96
|
-
if (!xPrediction || !yPrediction)
|
|
97
|
-
|
|
95
|
+
if (!xPrediction || !yPrediction) {
|
|
96
|
+
throw new Error('predictions are not availaible');
|
|
97
|
+
}
|
|
98
98
|
|
|
99
99
|
predictions = {
|
|
100
100
|
H: xPrediction,
|
|
101
|
-
C: yPrediction
|
|
102
|
-
}
|
|
101
|
+
C: yPrediction,
|
|
102
|
+
};
|
|
103
103
|
|
|
104
104
|
const { molfile, diaIDs } = xPrediction;
|
|
105
105
|
|
|
@@ -49,7 +49,10 @@ export interface PredictHSQCOptions {
|
|
|
49
49
|
* @returns {Promise<object>} - object with molfile, diaIDs, 2D signals joined signals and zones.
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
-
export async function predictHSQC(
|
|
52
|
+
export async function predictHSQC(
|
|
53
|
+
molecule: Molecule,
|
|
54
|
+
options: PredictHSQCOptions = {},
|
|
55
|
+
) {
|
|
53
56
|
let {
|
|
54
57
|
minLength = 1,
|
|
55
58
|
maxLength = 1,
|
|
@@ -102,7 +102,7 @@ function protonParser(
|
|
|
102
102
|
atoms: [linked],
|
|
103
103
|
diaIDs: [diaIDs[linked]],
|
|
104
104
|
multiplicity: 'd',
|
|
105
|
-
|
|
105
|
+
pathLength: distanceMatrix[atom][linked],
|
|
106
106
|
});
|
|
107
107
|
signal.js.sort((a, b) => b.coupling - a.coupling);
|
|
108
108
|
}
|
|
@@ -24,8 +24,7 @@ export function getFilteredIDiaIDs(
|
|
|
24
24
|
|
|
25
25
|
const molfile = molecule.toMolfile();
|
|
26
26
|
|
|
27
|
-
let groupedDiaIDs =
|
|
28
|
-
getGroupedDiastereotopicAtomIDs(molecule);
|
|
27
|
+
let groupedDiaIDs = getGroupedDiastereotopicAtomIDs(molecule);
|
|
29
28
|
|
|
30
29
|
let carbonDiaIDs = groupedDiaIDs
|
|
31
30
|
.filter((e) => e.atomLabel === 'C')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const nucleusMap: {[key: string]: string
|
|
1
|
+
const nucleusMap: { [key: string]: string } = {
|
|
2
2
|
h: '1H',
|
|
3
3
|
c: '13C',
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
export function getNuclei(input: {[key: string]: string}) {
|
|
7
|
-
return Object.values(input).map((e) =>
|
|
6
|
+
export function getNuclei(input: { [key: string]: string }) {
|
|
7
|
+
return Object.values(input).map((e) => nucleusMap[e.toLowerCase()]);
|
|
8
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Molecule } from
|
|
1
|
+
import type { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { Prediction1D } from
|
|
3
|
+
import type { Prediction1D } from '../../types/prediction1D';
|
|
4
4
|
|
|
5
5
|
import type { Predictions, PredictOptions, Predictors } from './predict2D';
|
|
6
6
|
|
|
@@ -21,4 +21,4 @@ export async function getPredictions(
|
|
|
21
21
|
: undefined;
|
|
22
22
|
}
|
|
23
23
|
return prediction;
|
|
24
|
-
}
|
|
24
|
+
}
|
package/src/ranges/rangesToXY.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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
11
|
type RangeWithSignal = MakeMandatory<NMRRange, 'signals'>;
|
|
13
12
|
|
|
14
13
|
export interface RangeToXYOptions {
|
|
@@ -41,7 +40,7 @@ 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[],
|
|
@@ -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
|
}
|
|
@@ -46,7 +46,7 @@ const takeCareDiaIDs = (
|
|
|
46
46
|
/**
|
|
47
47
|
* Join couplings smaller than a define tolerance.
|
|
48
48
|
* The resulting coupling should be an average of the existing one.
|
|
49
|
-
* If
|
|
49
|
+
* If pathLength is specified and is not always the same this property will be removed.
|
|
50
50
|
*/
|
|
51
51
|
export function signalJoinCouplings(
|
|
52
52
|
signal: NMRSignal1D,
|
|
@@ -111,7 +111,7 @@ function groupJCouplings(
|
|
|
111
111
|
) as string[];
|
|
112
112
|
|
|
113
113
|
let distances = distinctValues(
|
|
114
|
-
group.map((group) => group.
|
|
114
|
+
group.map((group) => group.pathLength) as number[],
|
|
115
115
|
) as number[];
|
|
116
116
|
|
|
117
117
|
let multiplicity = joinPatterns(
|
|
@@ -126,7 +126,7 @@ function groupJCouplings(
|
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
if (diaIDs.length === 1) newJ.diaIDs = diaIDs;
|
|
129
|
-
if (distances.length === 1 && distances[0]) newJ.
|
|
129
|
+
if (distances.length === 1 && distances[0]) newJ.pathLength = distances[0];
|
|
130
130
|
if (assignment.length > 0) newJ.assignment = assignment;
|
|
131
131
|
if (atoms.length > 0) newJ.atoms = atoms;
|
|
132
132
|
signal.js.push(newJ);
|
|
@@ -17,7 +17,7 @@ export interface SignalsJoinOptions {
|
|
|
17
17
|
|
|
18
18
|
type JcouplingFromPrediction = MakeMandatory<
|
|
19
19
|
Jcoupling,
|
|
20
|
-
'multiplicity' | 'diaIDs' | '
|
|
20
|
+
'multiplicity' | 'diaIDs' | 'pathLength'
|
|
21
21
|
>;
|
|
22
22
|
type Signal1DWidthDiaID = MakeMandatory<NMRSignal1D, 'diaIDs'>;
|
|
23
23
|
type Signal1DWidthJsAndDiaID = Omit<Signal1DWidthDiaID, 'js'> & {
|
|
@@ -29,8 +29,8 @@ const localeCompareJcouplingKeys = (
|
|
|
29
29
|
a: JcouplingFromPrediction,
|
|
30
30
|
b: JcouplingFromPrediction,
|
|
31
31
|
) => {
|
|
32
|
-
const aa = `${a.diaIDs.join(' ')}${a.
|
|
33
|
-
const bb = `${b.diaIDs.join(' ')}${b.
|
|
32
|
+
const aa = `${a.diaIDs.join(' ')}${a.pathLength}`;
|
|
33
|
+
const bb = `${b.diaIDs.join(' ')}${b.pathLength}`;
|
|
34
34
|
return localeCompare(aa, bb);
|
|
35
35
|
};
|
|
36
36
|
function checkForMandatory(
|
|
@@ -41,7 +41,7 @@ function checkForMandatory(
|
|
|
41
41
|
if (!signal.diaIDs) throw new Error('there is not diaIDs');
|
|
42
42
|
for (const jcoupling of signal.js) {
|
|
43
43
|
if (!jcoupling.diaIDs) throw new Error('there is not diaIDs');
|
|
44
|
-
if (!jcoupling.
|
|
44
|
+
if (!jcoupling.pathLength) throw new Error('there is not pathLength');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -68,7 +68,7 @@ export function signalsJoin(
|
|
|
68
68
|
const keyDiaIDs = signal.diaIDs.join(' ');
|
|
69
69
|
let id = `${keyDiaIDs} ${signal.js
|
|
70
70
|
.map(
|
|
71
|
-
(j: JcouplingFromPrediction) => `${j.diaIDs.join(' ')} ${j.
|
|
71
|
+
(j: JcouplingFromPrediction) => `${j.diaIDs.join(' ')} ${j.pathLength}`,
|
|
72
72
|
)
|
|
73
73
|
.sort(localeCompare)
|
|
74
74
|
.join(' ')}`;
|
|
@@ -80,13 +80,13 @@ export function signalsJoin(
|
|
|
80
80
|
// for each group we need to combine assignments and average couplings
|
|
81
81
|
let newSignals: Signal1DWidthJsAndDiaID[] = [];
|
|
82
82
|
Object.values(groupedSignals).forEach((group) => {
|
|
83
|
-
// joining couplings only if diaID and
|
|
83
|
+
// joining couplings only if diaID and pathLength are equal
|
|
84
84
|
let js: JcouplingFromPrediction[] = [];
|
|
85
85
|
for (let i = 0; i < group[0].js.length; i++) {
|
|
86
86
|
const coupling = group[0].js[i];
|
|
87
87
|
js.push({
|
|
88
88
|
diaIDs: coupling.diaIDs,
|
|
89
|
-
|
|
89
|
+
pathLength: coupling.pathLength,
|
|
90
90
|
multiplicity: coupling.multiplicity,
|
|
91
91
|
coupling: mean(group.map((item) => item.js[i].coupling)),
|
|
92
92
|
});
|
|
@@ -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
|
|
@@ -48,7 +48,7 @@ export interface OptionsSignalsToXY {
|
|
|
48
48
|
maxClusterSize?: number;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
type JcouplingFromPrediction = MakeMandatory<Jcoupling, '
|
|
51
|
+
type JcouplingFromPrediction = MakeMandatory<Jcoupling, 'pathLength'>;
|
|
52
52
|
type Signal1DWidthAtomsIDsAndDiaID = MakeMandatory<NMRSignal1D, 'atoms'>;
|
|
53
53
|
type Signal1DWidthJsAndDiaID = Omit<Signal1DWidthAtomsIDsAndDiaID, 'js'> & {
|
|
54
54
|
js: JcouplingFromPrediction[];
|