nmr-processing 5.0.0 → 6.0.3
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/get1HAssignments.d.ts +2 -2
- package/lib/{types → assignment}/nmrAssigment.d.ts +2 -2
- package/lib/{types → assignment}/nmrAssigment.js +0 -0
- package/lib/assignment/nmrAssigment.js.map +1 -0
- package/lib/assignment/utils/buildAssignments.js.map +1 -1
- package/lib/assignment/utils/createMapPossibleAssignments.d.ts +1 -1
- package/lib/assignment/utils/createMapPossibleAssignments.js.map +1 -1
- package/lib/constants/couplingValues.js.map +1 -1
- package/lib/databases/DatabaseNMREntry.d.ts +1 -1
- package/lib/index.d.ts +9 -10
- package/lib/index.js +1 -1
- package/lib/ml-matrix-convolution.d.ts +8 -0
- package/lib/ml-matrix-convolution.js +2 -0
- package/lib/ml-matrix-convolution.js.map +1 -0
- package/lib/ml-simple-clustering.d.ts +8 -0
- package/lib/ml-simple-clustering.js +2 -0
- package/lib/ml-simple-clustering.js.map +1 -0
- package/lib/{types → peaks}/NMRPeak1D.d.ts +0 -0
- package/lib/{types → peaks}/NMRPeak1D.js +0 -0
- package/lib/{types → peaks}/NMRPeak1D.js.map +1 -1
- package/lib/peaks/peaksFilterImpurities.d.ts +1 -1
- package/lib/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib/peaks/peaksToRanges.d.ts +2 -2
- package/lib/peaks/util/determineRealTop.d.ts +2 -2
- package/lib/peaks/util/determineRealTop.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.d.ts +2 -2
- package/lib/peaks/util/jAnalyzer.js +4 -3
- package/lib/peaks/util/jAnalyzer.js.map +1 -1
- package/lib/peaks/util/joinRanges.d.ts +1 -1
- package/lib/peaks/util/peakOptimizer.d.ts +3 -3
- package/lib/peaks/util/peakOptimizer.js.map +1 -1
- package/lib/{types → prediction}/dataStructure.d.ts +0 -0
- package/lib/{types → prediction}/dataStructure.js +0 -0
- package/lib/prediction/dataStructure.js.map +1 -0
- package/lib/prediction/predictAll.d.ts +1 -1
- package/lib/prediction/predictAll.js +1 -1
- package/lib/prediction/predictAll.js.map +1 -1
- package/lib/prediction/predictCOSY.d.ts +1 -1
- package/lib/prediction/predictCOSY.js.map +1 -1
- package/lib/prediction/predictCarbon.d.ts +2 -2
- package/lib/prediction/predictCarbon.js.map +1 -1
- package/lib/prediction/predictHMBC.d.ts +1 -1
- package/lib/prediction/predictHMBC.js.map +1 -1
- package/lib/prediction/predictHSQC.d.ts +1 -1
- package/lib/prediction/predictHSQC.js.map +1 -1
- package/lib/prediction/predictProton.d.ts +1 -1
- package/lib/prediction/predictProton.js +2 -2
- package/lib/prediction/predictProton.js.map +1 -1
- package/lib/{types → prediction}/prediction1D.d.ts +2 -2
- package/lib/{types → prediction}/prediction1D.js +0 -0
- package/lib/prediction/prediction1D.js.map +1 -0
- package/lib/prediction/utils/fetchPrediction.d.ts +1 -1
- package/lib/prediction/utils/getFilteredIDiaIDs.d.ts +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/getPredictions.js +1 -1
- package/lib/prediction/utils/getPredictions.js.map +1 -1
- package/lib/prediction/utils/predict2D.d.ts +2 -2
- package/lib/prediction/utils/queryByHOSE.d.ts +1 -1
- package/lib/prediction/utils/queryByHOSE.js.map +1 -1
- package/lib/ranges/rangesToACS.d.ts +1 -1
- package/lib/ranges/rangesToACS.js +8 -9
- package/lib/ranges/rangesToACS.js.map +1 -1
- package/lib/ranges/rangesToXY.d.ts +1 -1
- package/lib/ranges/rangesToXY.js.map +1 -1
- package/lib/signal/signalJoinCouplings.d.ts +2 -2
- package/lib/signal/signalJoinCouplings.js +3 -3
- package/lib/signal/signalJoinCouplings.js.map +1 -1
- package/lib/signal/signalMultiplicityPattern.d.ts +1 -1
- package/lib/{types → signals}/NMRSignal1D.d.ts +1 -1
- package/lib/{types → signals}/NMRSignal1D.js +0 -0
- package/lib/{types → signals}/NMRSignal1D.js.map +1 -1
- package/lib/signals/hackSignalsToXY.d.ts +1 -1
- package/lib/{types → signals}/jcoupling.d.ts +1 -1
- package/lib/{types → signals}/jcoupling.js +0 -0
- package/lib/{types → signals}/jcoupling.js.map +1 -1
- package/lib/signals/signals2DToZ.d.ts +1 -1
- package/lib/signals/signalsJoin.d.ts +4 -4
- package/lib/signals/signalsJoin.js +7 -7
- package/lib/signals/signalsJoin.js.map +1 -1
- package/lib/signals/signalsToRanges.d.ts +2 -2
- package/lib/signals/signalsToRanges.js.map +1 -1
- package/lib/signals/signalsToXY.d.ts +1 -1
- package/lib/signals/simulation/signalsToSpinSystem.d.ts +2 -2
- package/lib/signals/simulation/simulate1D.d.ts +1 -1
- package/lib/signals/simulation/simulate1D.js +2 -1
- package/lib/signals/simulation/simulate1D.js.map +1 -1
- package/lib/signals/simulation/splitSpinSystem.d.ts +1 -1
- package/lib/signals/simulation/splitSpinSystem.js.map +1 -1
- package/lib/{types → signals}/spinSystem.d.ts +0 -0
- package/lib/{types → signals}/spinSystem.js +0 -0
- package/lib/{types → signals}/spinSystem.js.map +1 -1
- package/lib/{types → utilities}/MakeMandatory.d.ts +0 -0
- package/lib/{types → utilities}/MakeMandatory.js +0 -0
- package/lib/utilities/MakeMandatory.js.map +1 -0
- package/lib/utilities/joinPatterns.js.map +1 -1
- package/lib/utilities/rangeFromSignal.d.ts +1 -1
- package/lib/utilities/resurrect.d.ts +1 -1
- package/lib/utilities/resurrectRange.d.ts +1 -1
- package/lib/{types → xy}/NMRRange.d.ts +1 -1
- package/lib/{types → xy}/NMRRange.js +0 -0
- package/lib/{types → xy}/NMRRange.js.map +1 -1
- package/lib/xy/xyAutoPeaksPicking.d.ts +2 -2
- package/lib/xy/xyAutoRangesPicking.d.ts +2 -2
- package/lib/xy/xyAutoRangesPicking.js.map +1 -1
- package/lib/{types → xyz}/NMRSignal2D.d.ts +6 -5
- package/lib/{types → xyz}/NMRSignal2D.js +0 -0
- package/lib/{types → xyz}/NMRSignal2D.js.map +1 -1
- package/lib/xyz/NMRZone.d.ts +8 -0
- package/lib/{types → xyz}/NMRZone.js +0 -0
- package/lib/{types → xyz}/NMRZone.js.map +1 -1
- package/lib/xyz/{xyzAutoPeaksPicking.d.ts → xyzAutoZonesPicking.d.ts} +3 -3
- package/lib/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +38 -26
- package/lib/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib/xyz/xyzJResAnalyzer.d.ts +1 -1
- package/lib/xyz/xyzJResAnalyzer.js.map +1 -1
- package/lib-esm/assignment/get13CAssignments.js.map +1 -1
- package/lib-esm/{types → assignment}/nmrAssigment.js +0 -0
- package/lib-esm/assignment/nmrAssigment.js.map +1 -0
- package/lib-esm/assignment/utils/buildAssignments.js.map +1 -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/ml-matrix-convolution.js +2 -0
- package/lib-esm/ml-matrix-convolution.js.map +1 -0
- package/lib-esm/ml-simple-clustering.js +2 -0
- package/lib-esm/ml-simple-clustering.js.map +1 -0
- package/lib-esm/{types → peaks}/NMRPeak1D.js +0 -0
- package/lib-esm/{types → peaks}/NMRPeak1D.js.map +1 -1
- package/lib-esm/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib-esm/peaks/util/determineRealTop.js.map +1 -1
- package/lib-esm/peaks/util/jAnalyzer.js +4 -3
- package/lib-esm/peaks/util/jAnalyzer.js.map +1 -1
- package/lib-esm/peaks/util/peakOptimizer.js.map +1 -1
- package/lib-esm/{types → prediction}/dataStructure.js +0 -0
- package/lib-esm/prediction/dataStructure.js.map +1 -0
- package/lib-esm/prediction/predictAll.js +1 -1
- package/lib-esm/prediction/predictAll.js.map +1 -1
- package/lib-esm/prediction/predictCOSY.js.map +1 -1
- package/lib-esm/prediction/predictCarbon.js.map +1 -1
- package/lib-esm/prediction/predictHMBC.js.map +1 -1
- package/lib-esm/prediction/predictHSQC.js.map +1 -1
- package/lib-esm/prediction/predictProton.js +2 -2
- package/lib-esm/prediction/predictProton.js.map +1 -1
- package/lib-esm/{types → prediction}/prediction1D.js +0 -0
- package/lib-esm/prediction/prediction1D.js.map +1 -0
- 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/getPredictions.js +1 -1
- package/lib-esm/prediction/utils/getPredictions.js.map +1 -1
- package/lib-esm/prediction/utils/queryByHOSE.js.map +1 -1
- package/lib-esm/ranges/rangesToACS.js +8 -9
- package/lib-esm/ranges/rangesToACS.js.map +1 -1
- 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/{types → signals}/NMRSignal1D.js +0 -0
- package/lib-esm/{types → signals}/NMRSignal1D.js.map +1 -1
- package/lib-esm/{types → signals}/jcoupling.js +0 -0
- package/lib-esm/{types → signals}/jcoupling.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/signalsToRanges.js.map +1 -1
- package/lib-esm/signals/simulation/simulate1D.js +2 -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 → signals}/spinSystem.js +0 -0
- package/lib-esm/{types → signals}/spinSystem.js.map +1 -1
- package/lib-esm/{types → utilities}/MakeMandatory.js +0 -0
- package/lib-esm/utilities/MakeMandatory.js.map +1 -0
- package/lib-esm/utilities/joinPatterns.js.map +1 -1
- package/lib-esm/{types → xy}/NMRRange.js +0 -0
- package/lib-esm/{types → xy}/NMRRange.js.map +1 -1
- package/lib-esm/xy/xyAutoRangesPicking.js.map +1 -1
- package/lib-esm/{types → xyz}/NMRSignal2D.js +0 -0
- package/lib-esm/{types → xyz}/NMRSignal2D.js.map +1 -1
- package/lib-esm/{types → xyz}/NMRZone.js +0 -0
- package/lib-esm/{types → xyz}/NMRZone.js.map +1 -1
- package/lib-esm/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +36 -24
- package/lib-esm/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib-esm/xyz/xyzJResAnalyzer.js.map +1 -1
- package/package.json +27 -36
- package/src/assignment/get13CAssignments.ts +5 -2
- package/src/assignment/get1HAssignments.ts +2 -2
- package/src/{types → assignment}/nmrAssigment.ts +2 -2
- package/src/assignment/utils/buildAssignments.ts +1 -4
- package/src/assignment/utils/createMapPossibleAssignments.ts +5 -2
- package/src/constants/couplingValues.ts +1 -1
- package/src/databases/DatabaseNMREntry.ts +1 -1
- package/src/index.ts +9 -10
- package/src/{types/ml-levenberg-marquardt/index.d.ts → ml-levenberg-marquardt.d.ts} +0 -0
- package/src/{types/ml-matrix-convolution/index.d.ts → ml-matrix-convolution.ts} +0 -0
- package/src/{types/ml-matrix-peaks-finder/index.d.ts → ml-matrix-peaks-finder.d.ts} +2 -2
- package/src/{types/ml-simple-clustering/index.d.ts → ml-simple-clustering.ts} +1 -1
- package/src/{types/ml-sparse-matrix/index.d.ts → ml-sparse-matrix.d.ts} +0 -0
- package/src/{types/ml-spectra-processing/index.d.ts → ml-spectra-processing.d.ts} +8 -2
- package/src/{types/ml-tree-set/index.d.ts → ml-tree-set.d.ts} +0 -0
- package/src/nmr-parser.d.ts +17 -0
- package/src/{types/openchemlib-utils/index..d.ts → openchemlib.d.ts} +17 -6
- package/src/{types → peaks}/NMRPeak1D.ts +0 -0
- package/src/peaks/peaksFilterImpurities.ts +2 -1
- package/src/peaks/peaksToRanges.ts +4 -4
- package/src/peaks/util/determineRealTop.ts +3 -4
- package/src/peaks/util/jAnalyzer.ts +9 -9
- package/src/peaks/util/joinRanges.ts +1 -1
- package/src/peaks/util/peakOptimizer.ts +5 -4
- package/src/{types → prediction}/dataStructure.ts +1 -1
- package/src/prediction/predictAll.ts +6 -7
- package/src/prediction/predictCOSY.ts +1 -2
- package/src/prediction/predictCarbon.ts +4 -4
- package/src/prediction/predictHMBC.ts +1 -2
- package/src/prediction/predictHSQC.ts +5 -3
- package/src/prediction/predictProton.ts +5 -4
- package/src/{types → prediction}/prediction1D.ts +2 -2
- package/src/prediction/utils/fetchPrediction.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 +4 -4
- package/src/prediction/utils/predict2D.ts +4 -4
- package/src/prediction/utils/queryByHOSE.ts +2 -2
- package/src/ranges/rangesToACS.ts +20 -13
- package/src/ranges/rangesToXY.ts +3 -3
- package/src/signal/signalJoinCouplings.ts +6 -6
- package/src/signal/signalMultiplicityPattern.ts +1 -1
- package/src/{types → signals}/NMRSignal1D.ts +2 -1
- package/src/signals/hackSignalsToXY.ts +2 -2
- package/src/{types → signals}/jcoupling.ts +1 -1
- package/src/signals/signals2DToZ.ts +1 -1
- package/src/signals/signalsJoin.ts +11 -10
- package/src/signals/signalsToRanges.ts +4 -3
- package/src/signals/signalsToXY.ts +4 -4
- package/src/signals/simulation/signalsToSpinSystem.ts +4 -4
- package/src/signals/simulation/simulate1D.ts +3 -2
- package/src/signals/simulation/splitSpinSystem.ts +11 -3
- package/src/{types → signals}/spinSystem.ts +0 -0
- package/src/{types → utilities}/MakeMandatory.ts +0 -0
- package/src/utilities/joinPatterns.ts +0 -1
- package/src/utilities/rangeFromSignal.ts +1 -1
- package/src/utilities/resurrect.ts +1 -1
- package/src/utilities/resurrectRange.ts +2 -2
- package/src/{types → xy}/NMRRange.ts +1 -1
- package/src/xy/xyAutoPeaksPicking.ts +6 -6
- package/src/xy/xyAutoRangesPicking.ts +3 -2
- package/src/{types → xyz}/NMRSignal2D.ts +6 -6
- package/src/xyz/NMRZone.ts +10 -0
- package/src/xyz/{xyzAutoPeaksPicking.ts → xyzAutoZonesPicking.ts} +44 -29
- package/src/xyz/xyzJResAnalyzer.ts +7 -6
- package/CHANGELOG.md +0 -572
- 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/types/MakeMandatory.js.map +0 -1
- package/lib/types/NMRZone.d.ts +0 -12
- package/lib/types/XYNumberArray.d.ts +0 -4
- package/lib/types/XYNumberArray.js +0 -3
- package/lib/types/XYNumberArray.js.map +0 -1
- package/lib/types/dataStructure.js.map +0 -1
- package/lib/types/nmrAssigment.js.map +0 -1
- package/lib/types/prediction1D.js.map +0 -1
- package/lib/types/prediction2D.d.ts +0 -0
- package/lib/types/prediction2D.js +0 -2
- package/lib/types/prediction2D.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/types/MakeMandatory.js.map +0 -1
- package/lib-esm/types/XYNumberArray.js +0 -2
- package/lib-esm/types/XYNumberArray.js.map +0 -1
- package/lib-esm/types/dataStructure.js.map +0 -1
- package/lib-esm/types/nmrAssigment.js.map +0 -1
- package/lib-esm/types/prediction1D.js.map +0 -1
- package/lib-esm/types/prediction2D.js +0 -2
- package/lib-esm/types/prediction2D.js.map +0 -1
- package/lib-esm/xyz/xyzAutoPeaksPicking.js.map +0 -1
- package/src/types/MPFPeak.ts +0 -9
- package/src/types/NMRZone.ts +0 -10
- package/src/types/XYNumberArray.ts +0 -4
- package/src/types/prediction2D.ts +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { impurities } from '../constants/impurities';
|
|
2
2
|
import type { ImpuritySignal } from '../constants/impurities';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import type { NMRPeak1D } from './NMRPeak1D';
|
|
4
5
|
|
|
5
6
|
const toCheck = ['solvent', 'h2o', 'tms'];
|
|
6
7
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DataXY } from 'cheminfo-types';
|
|
2
2
|
import { xyIntegration } from 'ml-spectra-processing';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { NMRRange } from '../
|
|
7
|
-
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
4
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
5
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
6
|
+
import type { NMRRange } from '../xy/NMRRange';
|
|
8
7
|
|
|
8
|
+
import type { NMRPeak1D } from './NMRPeak1D';
|
|
9
9
|
import jAnalyzer from './util/jAnalyzer';
|
|
10
10
|
import type { SignalIntern, Peak1DIntern } from './util/jAnalyzer';
|
|
11
11
|
import { joinRanges } from './util/joinRanges';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import LM from 'ml-levenberg-marquardt';
|
|
2
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
2
3
|
import { Gaussian2D } from 'ml-peak-shape-generator';
|
|
3
4
|
|
|
4
|
-
import type { MPFPeak } from '../../types/MPFPeak';
|
|
5
|
-
|
|
6
5
|
const direction8X = [-1, -1, -1, 0, 0, 1, 1, 1];
|
|
7
6
|
const direction8Y = [-1, 0, 1, -1, 1, -1, 0, 1];
|
|
8
7
|
const direction16X = [-2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2];
|
|
@@ -10,7 +9,7 @@ const direction16Y = [-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2];
|
|
|
10
9
|
|
|
11
10
|
type Data = number[] | Float64Array;
|
|
12
11
|
|
|
13
|
-
export function determineRealTop(peaks:
|
|
12
|
+
export function determineRealTop(peaks: Peak2D[], options: any) {
|
|
14
13
|
let { nCols, absoluteData, originalData, minX, maxX, minY, maxY } = options;
|
|
15
14
|
for (let i = 0; i < peaks.length; i++) {
|
|
16
15
|
let xIndex = Math.round(peaks[i].x);
|
|
@@ -148,7 +147,7 @@ function paramGaussian2D(intervalX: number, intervalY: number, nCols: number) {
|
|
|
148
147
|
let xIndex = t % nCols;
|
|
149
148
|
let yIndex = (t - xIndex) / nCols;
|
|
150
149
|
for (let i = 0; i < nL; i++) {
|
|
151
|
-
gaussian2D.fwhm = {x: p[i + 3 * nL], y: p[i + 4 * nL]};
|
|
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(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MakeMandatory } from '../../
|
|
2
|
-
import type { NMRPeak1D } from '
|
|
1
|
+
import type { MakeMandatory } from '../../utilities/MakeMandatory';
|
|
2
|
+
import type { NMRPeak1D } from '../NMRPeak1D';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* This library implements the J analyser described by Cobas et al in the paper:
|
|
@@ -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++;
|
|
@@ -222,8 +226,7 @@ function updateSignal(signal: SignalInternMandatory, jCouplings: number[]) {
|
|
|
222
226
|
signal.startX = peaks[0].x / signal.observe - peaks[0].width;
|
|
223
227
|
signal.stopX =
|
|
224
228
|
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width;
|
|
225
|
-
signal.integralData.from =
|
|
226
|
-
peaks[0].x / signal.observe - peaks[0].width * 3;
|
|
229
|
+
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3;
|
|
227
230
|
signal.integralData.to =
|
|
228
231
|
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3;
|
|
229
232
|
// Compile the pattern and format the constant couplings
|
|
@@ -525,10 +528,7 @@ function symmetrize(
|
|
|
525
528
|
|
|
526
529
|
if (Math.abs(diffL - diffR) < maxError) {
|
|
527
530
|
avg = Math.min(peaks[left].intensity, peaks[right].intensity);
|
|
528
|
-
avgWidth = Math.min(
|
|
529
|
-
peaks[left].width,
|
|
530
|
-
peaks[right].width,
|
|
531
|
-
);
|
|
531
|
+
avgWidth = Math.min(peaks[left].width, peaks[right].width);
|
|
532
532
|
peaks[left].intensity = peaks[right].intensity = avg;
|
|
533
533
|
peaks[left].width = peaks[right].width = avgWidth;
|
|
534
534
|
middle = [
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
2
|
+
|
|
3
|
+
import type { NMRSignal2D } from '../../xyz/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);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { Prediction1D } from '../types/prediction1D';
|
|
4
|
-
|
|
5
3
|
import { predictCOSY } from './predictCOSY';
|
|
6
4
|
import { predictCarbon, PredictCarbonOptions } from './predictCarbon';
|
|
7
5
|
import { predictHMBC } from './predictHMBC';
|
|
8
6
|
import { predictHSQC } from './predictHSQC';
|
|
9
7
|
import { predictProton, PredictProtonOptions } from './predictProton';
|
|
8
|
+
import type { Prediction1D } from './prediction1D';
|
|
10
9
|
import { getPredictions } from './utils/getPredictions';
|
|
11
10
|
import type { Predictor } from './utils/predict2D';
|
|
12
11
|
|
|
13
|
-
|
|
14
12
|
export interface PredictAllOptions {
|
|
15
13
|
/**
|
|
16
14
|
* nucleus label to use in the X axis
|
|
@@ -93,13 +91,14 @@ export async function predictAll(
|
|
|
93
91
|
predictions,
|
|
94
92
|
);
|
|
95
93
|
|
|
96
|
-
if (!xPrediction || !yPrediction)
|
|
97
|
-
|
|
94
|
+
if (!xPrediction || !yPrediction) {
|
|
95
|
+
throw new Error('predictions are not availaible');
|
|
96
|
+
}
|
|
98
97
|
|
|
99
98
|
predictions = {
|
|
100
99
|
H: xPrediction,
|
|
101
|
-
C: yPrediction
|
|
102
|
-
}
|
|
100
|
+
C: yPrediction,
|
|
101
|
+
};
|
|
103
102
|
|
|
104
103
|
const { molfile, diaIDs } = xPrediction;
|
|
105
104
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { Prediction1D } from '../types/prediction1D';
|
|
4
|
-
|
|
5
3
|
import { predictProton, PredictProtonOptions } from './predictProton';
|
|
4
|
+
import type { Prediction1D } from './prediction1D';
|
|
6
5
|
import { predict2D, Predictor } from './utils/predict2D';
|
|
7
6
|
|
|
8
7
|
export interface PredictCOSYOptions {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import fetch from 'cross-fetch';
|
|
2
2
|
import type { Molecule } from 'openchemlib';
|
|
3
3
|
|
|
4
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
4
5
|
import { signalsToRanges } from '../signals/signalsToRanges';
|
|
5
|
-
import type { MakeMandatory } from '../
|
|
6
|
-
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
7
|
-
import type { DataBaseStructure } from '../types/dataStructure';
|
|
8
|
-
import type { Prediction1D } from '../types/prediction1D';
|
|
6
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
9
7
|
|
|
8
|
+
import type { DataBaseStructure } from './dataStructure';
|
|
9
|
+
import type { Prediction1D } from './prediction1D';
|
|
10
10
|
import { fetchPrediction } from './utils/fetchPrediction';
|
|
11
11
|
import { flatGroupedDiaIDs } from './utils/flatGroupedDiaIDs';
|
|
12
12
|
import { getFilteredIDiaIDs } from './utils/getFilteredIDiaIDs';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { Prediction1D } from '../types/prediction1D';
|
|
4
|
-
|
|
5
3
|
import { predictCarbon } from './predictCarbon';
|
|
6
4
|
import type { PredictCarbonOptions } from './predictCarbon';
|
|
7
5
|
import { predictProton } from './predictProton';
|
|
8
6
|
import type { PredictProtonOptions } from './predictProton';
|
|
7
|
+
import type { Prediction1D } from './prediction1D';
|
|
9
8
|
import { predict2D } from './utils/predict2D';
|
|
10
9
|
import type { Predictor } from './utils/predict2D';
|
|
11
10
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { Prediction1D } from '../types/prediction1D';
|
|
4
|
-
|
|
5
3
|
import { predictCarbon, PredictCarbonOptions } from './predictCarbon';
|
|
6
4
|
import { predictProton, PredictProtonOptions } from './predictProton';
|
|
5
|
+
import type { Prediction1D } from './prediction1D';
|
|
7
6
|
import { predict2D, Predictor } from './utils/predict2D';
|
|
8
7
|
|
|
9
8
|
export interface PredictHSQCOptions {
|
|
@@ -49,7 +48,10 @@ export interface PredictHSQCOptions {
|
|
|
49
48
|
* @returns {Promise<object>} - object with molfile, diaIDs, 2D signals joined signals and zones.
|
|
50
49
|
*/
|
|
51
50
|
|
|
52
|
-
export async function predictHSQC(
|
|
51
|
+
export async function predictHSQC(
|
|
52
|
+
molecule: Molecule,
|
|
53
|
+
options: PredictHSQCOptions = {},
|
|
54
|
+
) {
|
|
53
55
|
let {
|
|
54
56
|
minLength = 1,
|
|
55
57
|
maxLength = 1,
|
|
@@ -7,10 +7,11 @@ import {
|
|
|
7
7
|
getDiastereotopicAtomIDs,
|
|
8
8
|
} from 'openchemlib-utils';
|
|
9
9
|
|
|
10
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
10
11
|
import { signalsJoin } from '../signals/signalsJoin';
|
|
11
12
|
import { signalsToRanges } from '../signals/signalsToRanges';
|
|
12
|
-
|
|
13
|
-
import type { Prediction1D } from '
|
|
13
|
+
|
|
14
|
+
import type { Prediction1D } from './prediction1D';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Makes a prediction using proton.
|
|
@@ -45,7 +46,7 @@ export async function predictProton(
|
|
|
45
46
|
formData.append('molfile', molfile);
|
|
46
47
|
const response = await fetch('https://www.nmrdb.org/service/predictor', {
|
|
47
48
|
method: 'POST',
|
|
48
|
-
|
|
49
|
+
// @ts-expect-error RequestInit type does not include FormData.
|
|
49
50
|
body: formData,
|
|
50
51
|
});
|
|
51
52
|
result = await response.text();
|
|
@@ -102,7 +103,7 @@ function protonParser(
|
|
|
102
103
|
atoms: [linked],
|
|
103
104
|
diaIDs: [diaIDs[linked]],
|
|
104
105
|
multiplicity: 'd',
|
|
105
|
-
|
|
106
|
+
pathLength: distanceMatrix[atom][linked],
|
|
106
107
|
});
|
|
107
108
|
signal.js.sort((a, b) => b.coupling - a.coupling);
|
|
108
109
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
4
|
+
import type { NMRRange } from '../xy/NMRRange';
|
|
5
5
|
|
|
6
6
|
export interface Prediction1D {
|
|
7
7
|
molfile: string;
|
|
@@ -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 '../prediction1D';
|
|
4
4
|
|
|
5
5
|
import type { Predictions, PredictOptions, Predictors } from './predict2D';
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ export async function getPredictions(
|
|
|
12
12
|
predictions?: Predictions,
|
|
13
13
|
) {
|
|
14
14
|
let prediction: Prediction1D | undefined;
|
|
15
|
-
if (predictions
|
|
15
|
+
if (predictions?.[key]) {
|
|
16
16
|
prediction = predictions[key];
|
|
17
17
|
} else if (predictor) {
|
|
18
18
|
const fromPredictor = predictor[key];
|
|
@@ -21,4 +21,4 @@ export async function getPredictions(
|
|
|
21
21
|
: undefined;
|
|
22
22
|
}
|
|
23
23
|
return prediction;
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -11,12 +11,12 @@ import type {
|
|
|
11
11
|
PathInfo,
|
|
12
12
|
} from 'openchemlib-utils';
|
|
13
13
|
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type { NMRSignal2D } from '../../
|
|
17
|
-
import type { Prediction1D } from '../../types/prediction1D';
|
|
14
|
+
import type { NMRSignal1D } from '../../signals/NMRSignal1D';
|
|
15
|
+
import type { MakeMandatory } from '../../utilities/MakeMandatory';
|
|
16
|
+
import type { NMRSignal2D } from '../../xyz/NMRSignal2D';
|
|
18
17
|
import type { PredictCarbon, PredictCarbonOptions } from '../predictCarbon';
|
|
19
18
|
import type { PredictProton, PredictProtonOptions } from '../predictProton';
|
|
19
|
+
import type { Prediction1D } from '../prediction1D';
|
|
20
20
|
|
|
21
21
|
import { getNuclei } from './getNuclei';
|
|
22
22
|
import { getPredictions } from './getPredictions';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataBaseStructure } from '
|
|
1
|
+
import type { DataBaseStructure } from '../dataStructure';
|
|
2
2
|
|
|
3
3
|
import type { GroupedDiaIDsWithHose } from './getFilteredIDiaIDs';
|
|
4
4
|
|
|
@@ -37,7 +37,7 @@ export function queryByHose(
|
|
|
37
37
|
for (const atomNumber of element.atoms) {
|
|
38
38
|
let atom = {
|
|
39
39
|
diaIDs: [element.oclID],
|
|
40
|
-
delta: res ? res[0]: null,
|
|
40
|
+
delta: res ? res[0] : null,
|
|
41
41
|
atoms: [atomNumber],
|
|
42
42
|
nbAtoms: 1,
|
|
43
43
|
level: level,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { signalJoinCouplings } from '../signal/signalJoinCouplings';
|
|
2
2
|
import { signalMultiplicityPattern } from '../signal/signalMultiplicityPattern';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
4
|
+
import type { NMRRange } from '../xy/NMRRange';
|
|
5
5
|
|
|
6
|
-
const globalOptions
|
|
6
|
+
const globalOptions: Record<
|
|
7
|
+
string,
|
|
8
|
+
{
|
|
9
|
+
nucleus: string;
|
|
10
|
+
nbDecimalDelta: number;
|
|
11
|
+
nbDecimalJ: number;
|
|
12
|
+
observedFrequency: number;
|
|
13
|
+
}
|
|
14
|
+
> = {
|
|
7
15
|
h: {
|
|
8
16
|
nucleus: '1H',
|
|
9
17
|
nbDecimalDelta: 2,
|
|
@@ -62,9 +70,8 @@ export function rangesToACS(
|
|
|
62
70
|
options: RangesToACSOptions = {},
|
|
63
71
|
) {
|
|
64
72
|
if (!options.nucleus) options.nucleus = '1H';
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let defaultOptions = globalOptions[nucleus];
|
|
73
|
+
const nucleus = options.nucleus.toLowerCase().replace(/[0-9]/g, '');
|
|
74
|
+
const defaultOptions = globalOptions[nucleus];
|
|
68
75
|
options = Object.assign(
|
|
69
76
|
{},
|
|
70
77
|
defaultOptions,
|
|
@@ -75,13 +82,13 @@ export function rangesToACS(
|
|
|
75
82
|
ranges = JSON.parse(JSON.stringify(ranges));
|
|
76
83
|
if (options.ascending === true) {
|
|
77
84
|
ranges.sort((a, b) => {
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
const fromA = Math.min(a.from, a.to);
|
|
86
|
+
const fromB = Math.min(b.from, b.to);
|
|
80
87
|
return fromA - fromB;
|
|
81
88
|
});
|
|
82
89
|
}
|
|
83
|
-
let acsString = formatAcs(ranges, options);
|
|
84
90
|
|
|
91
|
+
let acsString = formatAcs(ranges, options);
|
|
85
92
|
if (acsString.length > 0) acsString += '.';
|
|
86
93
|
|
|
87
94
|
return acsString;
|
|
@@ -90,8 +97,8 @@ export function rangesToACS(
|
|
|
90
97
|
function formatAcs(ranges: NMRRange[], options: any) {
|
|
91
98
|
let acs = spectroInformation(options);
|
|
92
99
|
if (acs.length === 0) acs = 'δ ';
|
|
93
|
-
|
|
94
|
-
for (
|
|
100
|
+
const acsRanges: string[] = [];
|
|
101
|
+
for (const range of ranges) {
|
|
95
102
|
if (uselessKind(range.kind, options.filter)) continue;
|
|
96
103
|
pushDelta(range, acsRanges, options);
|
|
97
104
|
}
|
|
@@ -103,7 +110,7 @@ function formatAcs(ranges: NMRRange[], options: any) {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
function spectroInformation(options: any) {
|
|
106
|
-
|
|
113
|
+
const parenthesis = [];
|
|
107
114
|
let strings = `${formatNucleus(options.nucleus)} NMR`;
|
|
108
115
|
if (options.solvent) {
|
|
109
116
|
parenthesis.push(formatMF(options.solvent));
|
|
@@ -122,7 +129,7 @@ function spectroInformation(options: any) {
|
|
|
122
129
|
function pushDelta(range: NMRRange, acsRanges: string[], options: any) {
|
|
123
130
|
let strings = '';
|
|
124
131
|
let parenthesis: any = [];
|
|
125
|
-
|
|
132
|
+
const fromTo = [range.from, range.to];
|
|
126
133
|
|
|
127
134
|
if (range.signals) {
|
|
128
135
|
range.signals = range.signals.filter(
|
package/src/ranges/rangesToXY.ts
CHANGED
|
@@ -3,10 +3,10 @@ import arraySequentialFill from 'ml-array-sequential-fill';
|
|
|
3
3
|
import type { Shape1D } from 'ml-peak-shape-generator';
|
|
4
4
|
import { SpectrumGenerator } from 'spectrum-generator';
|
|
5
5
|
|
|
6
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
6
7
|
import { hackSignalsToXY } from '../signals/hackSignalsToXY';
|
|
7
|
-
import type { MakeMandatory } from '../
|
|
8
|
-
import type { NMRRange } from '../
|
|
9
|
-
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
8
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
9
|
+
import type { NMRRange } from '../xy/NMRRange';
|
|
10
10
|
|
|
11
11
|
type RangeWithSignal = MakeMandatory<NMRRange, 'signals'>;
|
|
12
12
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import sum from 'ml-array-sum';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { NMRSignal1D } from '../signals/NMRSignal1D';
|
|
4
|
+
import type { Jcoupling } from '../signals/jcoupling';
|
|
5
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
6
6
|
import { joinPatterns } from '../utilities/joinPatterns';
|
|
7
7
|
|
|
8
8
|
export interface SignalJoinCouplingsOptions {
|
|
@@ -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);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { couplingPatterns } from '../constants/couplingPatterns';
|
|
2
|
-
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
3
|
-
import type { Jcoupling } from '../types/jcoupling';
|
|
4
2
|
|
|
3
|
+
import type { NMRSignal1D } from './NMRSignal1D';
|
|
4
|
+
import type { Jcoupling } from './jcoupling';
|
|
5
5
|
import { OptionsSignalsToXY, signalsToXY } from './signalsToXY';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generateSpectrum2D } from 'spectrum-generator';
|
|
2
2
|
import type { XYNumber } from 'spectrum-generator';
|
|
3
3
|
|
|
4
|
-
import type { NMRSignal2D } from '../
|
|
4
|
+
import type { NMRSignal2D } from '../xyz/NMRSignal2D';
|
|
5
5
|
|
|
6
6
|
interface Signals2DToZOptions {
|
|
7
7
|
/**
|
|
@@ -3,9 +3,10 @@ import sum from 'ml-array-sum';
|
|
|
3
3
|
|
|
4
4
|
import { signalJoinCouplings } from '../signal/signalJoinCouplings';
|
|
5
5
|
import type { SignalJoinCouplingsOptions } from '../signal/signalJoinCouplings';
|
|
6
|
-
import type { MakeMandatory } from '../
|
|
7
|
-
|
|
8
|
-
import type {
|
|
6
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
7
|
+
|
|
8
|
+
import type { NMRSignal1D } from './NMRSignal1D';
|
|
9
|
+
import type { Jcoupling } from './jcoupling';
|
|
9
10
|
|
|
10
11
|
export interface SignalsJoinOptions {
|
|
11
12
|
/**
|
|
@@ -17,7 +18,7 @@ export interface SignalsJoinOptions {
|
|
|
17
18
|
|
|
18
19
|
type JcouplingFromPrediction = MakeMandatory<
|
|
19
20
|
Jcoupling,
|
|
20
|
-
'multiplicity' | 'diaIDs' | '
|
|
21
|
+
'multiplicity' | 'diaIDs' | 'pathLength'
|
|
21
22
|
>;
|
|
22
23
|
type Signal1DWidthDiaID = MakeMandatory<NMRSignal1D, 'diaIDs'>;
|
|
23
24
|
type Signal1DWidthJsAndDiaID = Omit<Signal1DWidthDiaID, 'js'> & {
|
|
@@ -29,8 +30,8 @@ const localeCompareJcouplingKeys = (
|
|
|
29
30
|
a: JcouplingFromPrediction,
|
|
30
31
|
b: JcouplingFromPrediction,
|
|
31
32
|
) => {
|
|
32
|
-
const aa = `${a.diaIDs.join(' ')}${a.
|
|
33
|
-
const bb = `${b.diaIDs.join(' ')}${b.
|
|
33
|
+
const aa = `${a.diaIDs.join(' ')}${a.pathLength}`;
|
|
34
|
+
const bb = `${b.diaIDs.join(' ')}${b.pathLength}`;
|
|
34
35
|
return localeCompare(aa, bb);
|
|
35
36
|
};
|
|
36
37
|
function checkForMandatory(
|
|
@@ -41,7 +42,7 @@ function checkForMandatory(
|
|
|
41
42
|
if (!signal.diaIDs) throw new Error('there is not diaIDs');
|
|
42
43
|
for (const jcoupling of signal.js) {
|
|
43
44
|
if (!jcoupling.diaIDs) throw new Error('there is not diaIDs');
|
|
44
|
-
if (!jcoupling.
|
|
45
|
+
if (!jcoupling.pathLength) throw new Error('there is not pathLength');
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -68,7 +69,7 @@ export function signalsJoin(
|
|
|
68
69
|
const keyDiaIDs = signal.diaIDs.join(' ');
|
|
69
70
|
let id = `${keyDiaIDs} ${signal.js
|
|
70
71
|
.map(
|
|
71
|
-
(j: JcouplingFromPrediction) => `${j.diaIDs.join(' ')} ${j.
|
|
72
|
+
(j: JcouplingFromPrediction) => `${j.diaIDs.join(' ')} ${j.pathLength}`,
|
|
72
73
|
)
|
|
73
74
|
.sort(localeCompare)
|
|
74
75
|
.join(' ')}`;
|
|
@@ -80,13 +81,13 @@ export function signalsJoin(
|
|
|
80
81
|
// for each group we need to combine assignments and average couplings
|
|
81
82
|
let newSignals: Signal1DWidthJsAndDiaID[] = [];
|
|
82
83
|
Object.values(groupedSignals).forEach((group) => {
|
|
83
|
-
// joining couplings only if diaID and
|
|
84
|
+
// joining couplings only if diaID and pathLength are equal
|
|
84
85
|
let js: JcouplingFromPrediction[] = [];
|
|
85
86
|
for (let i = 0; i < group[0].js.length; i++) {
|
|
86
87
|
const coupling = group[0].js[i];
|
|
87
88
|
js.push({
|
|
88
89
|
diaIDs: coupling.diaIDs,
|
|
89
|
-
|
|
90
|
+
pathLength: coupling.pathLength,
|
|
90
91
|
multiplicity: coupling.multiplicity,
|
|
91
92
|
coupling: mean(group.map((item) => item.js[i].coupling)),
|
|
92
93
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { MakeMandatory } from '../
|
|
2
|
-
import type { NMRRange } from '../types/NMRRange';
|
|
3
|
-
import type { NMRSignal1D } from '../types/NMRSignal1D';
|
|
1
|
+
import type { MakeMandatory } from '../utilities/MakeMandatory';
|
|
4
2
|
import { rangeFromSignal } from '../utilities/rangeFromSignal';
|
|
3
|
+
import type { NMRRange } from '../xy/NMRRange';
|
|
4
|
+
|
|
5
|
+
import type { NMRSignal1D } from './NMRSignal1D';
|
|
5
6
|
|
|
6
7
|
interface SignalsToRangesOptions {
|
|
7
8
|
/**
|