nmr-processing 5.0.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.map +1 -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/util/determineRealTop.d.ts +2 -2
- package/lib/peaks/util/determineRealTop.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.js +4 -3
- 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/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/simulation/splitSpinSystem.js.map +1 -1
- package/lib/types/NMRSignal2D.d.ts +6 -4
- 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 +2 -2
- package/lib/xyz/{xyzAutoPeaksPicking.d.ts → xyzAutoZonesPicking.d.ts} +2 -2
- package/lib/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +38 -26
- 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.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/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/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/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/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/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 +19 -16
- package/src/assignment/get13CAssignments.ts +4 -1
- package/src/assignment/utils/buildAssignments.ts +1 -4
- package/src/assignment/utils/createMapPossibleAssignments.ts +4 -1
- package/src/constants/couplingValues.ts +1 -1
- package/src/index.ts +1 -1
- package/src/peaks/util/determineRealTop.ts +3 -4
- package/src/peaks/util/jAnalyzer.ts +7 -7
- 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/signal/signalJoinCouplings.ts +3 -3
- package/src/signals/signalsJoin.ts +7 -7
- package/src/signals/signalsToXY.ts +1 -1
- package/src/signals/simulation/splitSpinSystem.ts +10 -2
- package/src/types/NMRSignal2D.ts +7 -5
- 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 +6 -6
- package/src/xyz/{xyzAutoPeaksPicking.ts → xyzAutoZonesPicking.ts} +40 -26
- package/src/xyz/xyzJResAnalyzer.ts +4 -4
- 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/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
|
@@ -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
|
});
|
|
@@ -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[];
|
|
@@ -53,7 +53,11 @@ interface SplitClusterOptions {
|
|
|
53
53
|
connectivity: Matrix;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function splitCluster(
|
|
56
|
+
function splitCluster(
|
|
57
|
+
cluster: Cluster,
|
|
58
|
+
clusterList: Array<Int16Array>,
|
|
59
|
+
options: SplitClusterOptions,
|
|
60
|
+
) {
|
|
57
61
|
let { maxClusterSize, force, nSpins, connectivity } = options;
|
|
58
62
|
if (!force && cluster.size <= maxClusterSize) {
|
|
59
63
|
clusterList.push(getMembers(cluster.indices(), nSpins));
|
|
@@ -102,7 +106,11 @@ function splitCluster(cluster: Cluster, clusterList: Array<Int16Array>, options:
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
function calculateBetas(
|
|
109
|
+
function calculateBetas(
|
|
110
|
+
chemicalShifts: number[],
|
|
111
|
+
couplingConstants: Matrix,
|
|
112
|
+
frequency: number,
|
|
113
|
+
) {
|
|
106
114
|
let nRows = couplingConstants.rows;
|
|
107
115
|
let nColumns = couplingConstants.columns;
|
|
108
116
|
let betas = Matrix.zeros(nRows, nRows);
|
package/src/types/NMRSignal2D.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FromTo } from 'cheminfo-types';
|
|
2
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
2
3
|
|
|
3
4
|
export interface Signal2DAxisData {
|
|
4
5
|
nucleus?: string;
|
|
@@ -6,15 +7,16 @@ export interface Signal2DAxisData {
|
|
|
6
7
|
resolution?: number;
|
|
7
8
|
atoms?: number[];
|
|
8
9
|
diaIDs?: string[];
|
|
9
|
-
from: number;
|
|
10
|
-
to: number;
|
|
11
10
|
}
|
|
12
11
|
export interface NMRSignal2D {
|
|
13
12
|
x: Signal2DAxisData;
|
|
14
13
|
y: Signal2DAxisData;
|
|
14
|
+
j?: {
|
|
15
|
+
pathLength?: number | FromTo;
|
|
16
|
+
};
|
|
15
17
|
id?: string;
|
|
16
|
-
peaks?:
|
|
18
|
+
peaks?: Peak2D[];
|
|
17
19
|
kind?: string;
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
_highlight?: (number | string)[];
|
|
20
22
|
}
|
package/src/types/NMRZone.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FromTo } from 'cheminfo-types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { NMRSignal2D } from './NMRSignal2D';
|
|
4
4
|
|
|
5
5
|
export interface NMRZone {
|
|
6
|
-
x: FromTo
|
|
7
|
-
y: FromTo
|
|
6
|
+
x: FromTo;
|
|
7
|
+
y: FromTo;
|
|
8
8
|
id?: string;
|
|
9
|
-
signals: NMRSignal2D
|
|
10
|
-
}
|
|
9
|
+
signals: NMRSignal2D[];
|
|
10
|
+
}
|
package/src/types/jcoupling.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare module 'ml-matrix-peaks-finder' {
|
|
|
8
8
|
cols: number;
|
|
9
9
|
labelling?: 'drain' | 'floodfill';
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface Peak2D {
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
14
|
z: number;
|
|
@@ -20,5 +20,5 @@ declare module 'ml-matrix-peaks-finder' {
|
|
|
20
20
|
function findPeaks2DRegion(
|
|
21
21
|
absoluteData: number[] | Float64Array,
|
|
22
22
|
options?: FindPeaks2DRegionOptions,
|
|
23
|
-
):
|
|
23
|
+
): Peak2D[];
|
|
24
24
|
}
|
|
@@ -45,7 +45,13 @@ declare module 'ml-spectra-processing' {
|
|
|
45
45
|
|
|
46
46
|
interface XYIntegrationOptions extends XGetFromToIndexOptions {}
|
|
47
47
|
|
|
48
|
-
function xyIntegration(
|
|
48
|
+
function xyIntegration(
|
|
49
|
+
data: XYNumberArray,
|
|
50
|
+
options?: XYIntegrationOptions,
|
|
51
|
+
): number;
|
|
49
52
|
|
|
50
|
-
function xGetFromToIndex(
|
|
53
|
+
function xGetFromToIndex(
|
|
54
|
+
x: number[] | Float64Array,
|
|
55
|
+
options?: XGetFromToIndexOptions,
|
|
56
|
+
): number;
|
|
51
57
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'nmr-parser' {
|
|
2
|
+
interface FromBrukerOptions {
|
|
3
|
+
base64?: boolean;
|
|
4
|
+
shiftX?: number;
|
|
5
|
+
info?: any;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function fromBruker(
|
|
10
|
+
zipFile: ArrayBuffer | string,
|
|
11
|
+
options?: Partial<FromBrukerOptions>,
|
|
12
|
+
): Promise<Array<any>>;
|
|
13
|
+
|
|
14
|
+
function fromJCAMP(buffer: string | ArrayBuffer, options?: any): Array<any>;
|
|
15
|
+
|
|
16
|
+
function fromJEOL(buffer: ArrayBuffer): any;
|
|
17
|
+
}
|
|
@@ -48,7 +48,10 @@ declare module 'openchemlib-utils' {
|
|
|
48
48
|
export interface PathInfo extends AtomInfo {
|
|
49
49
|
paths: HoseCodesForPath[];
|
|
50
50
|
}
|
|
51
|
-
function getPathsInfo(
|
|
51
|
+
function getPathsInfo(
|
|
52
|
+
molecule: Molecule,
|
|
53
|
+
options?: GetPathsInfoOptions,
|
|
54
|
+
): PathInfo[];
|
|
52
55
|
|
|
53
56
|
export interface AtomInfo {
|
|
54
57
|
oclID: string;
|
|
@@ -102,20 +105,25 @@ declare module 'openchemlib-utils' {
|
|
|
102
105
|
export interface HoseCodesForPath {
|
|
103
106
|
atoms: number[];
|
|
104
107
|
from: number;
|
|
105
|
-
to: number
|
|
106
|
-
torsion?: number
|
|
108
|
+
to: number;
|
|
109
|
+
torsion?: number;
|
|
107
110
|
hoses: Hoses;
|
|
108
111
|
length: number;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
function getHoseCodesForPath(
|
|
114
|
+
function getHoseCodesForPath(
|
|
115
|
+
molecule: Molecule,
|
|
116
|
+
from: string,
|
|
117
|
+
to: string,
|
|
118
|
+
maxLength: number,
|
|
119
|
+
): HoseCodesForPath;
|
|
112
120
|
|
|
113
121
|
export interface GetConnectivityMatrixOptions {
|
|
114
122
|
/**
|
|
115
123
|
* get the path length between atoms
|
|
116
124
|
* @default false
|
|
117
125
|
*/
|
|
118
|
-
pathLength?: boolean
|
|
126
|
+
pathLength?: boolean;
|
|
119
127
|
/**
|
|
120
128
|
* set the nominal mass of the atoms on diagonal
|
|
121
129
|
* @default false
|
|
@@ -142,7 +150,10 @@ declare module 'openchemlib-utils' {
|
|
|
142
150
|
*/
|
|
143
151
|
stda?: boolean | number;
|
|
144
152
|
}
|
|
145
|
-
function getConnectivityMatrix(
|
|
153
|
+
function getConnectivityMatrix(
|
|
154
|
+
molecule: Molecule,
|
|
155
|
+
options?: GetConnectivityMatrixOptions,
|
|
156
|
+
): number[][] | Float64Array[];
|
|
146
157
|
|
|
147
158
|
function getDiastereotopicAtomIDs(molecule: Molecule): string[];
|
|
148
159
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { NMRRange } from
|
|
4
|
-
import type { NMRSignal1D } from
|
|
3
|
+
import type { NMRRange } from './NMRRange';
|
|
4
|
+
import type { NMRSignal1D } from './NMRSignal1D';
|
|
5
5
|
|
|
6
6
|
export interface Prediction1D {
|
|
7
7
|
molfile: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { couplingPatterns } from '../constants/couplingPatterns';
|
|
2
2
|
import { couplingValues } from '../constants/couplingValues';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
export function joinPatterns(patterns: string[]) {
|
|
6
5
|
const sum = patterns.reduce((sum, pattern) => {
|
|
7
6
|
if (isNaN(couplingValues[pattern])) {
|
|
@@ -2,9 +2,9 @@ import { DataXY } from 'cheminfo-types';
|
|
|
2
2
|
import { gsd, joinBroadPeaks, optimizePeaks } from 'ml-gsd';
|
|
3
3
|
import type {
|
|
4
4
|
Peak1D,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
GSDOptions,
|
|
6
|
+
OptimizePeaksOptions,
|
|
7
|
+
JoinBroadPeaksOptions,
|
|
8
8
|
} from 'ml-gsd';
|
|
9
9
|
import {
|
|
10
10
|
xyExtract,
|
|
@@ -26,9 +26,9 @@ interface OptionsGetCutOff {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface IGetPeakListOptions
|
|
29
|
-
extends
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
extends GSDOptions,
|
|
30
|
+
OptimizePeaksOptions,
|
|
31
|
+
JoinBroadPeaksOptions {
|
|
32
32
|
/**
|
|
33
33
|
* If it is true, the peaks parameters will be optimized.
|
|
34
34
|
* @default false
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Matrix } from 'ml-matrix';
|
|
2
2
|
import * as convolution from 'ml-matrix-convolution';
|
|
3
3
|
import * as matrixPeakFinders from 'ml-matrix-peaks-finder';
|
|
4
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
4
5
|
import simpleClustering from 'ml-simple-clustering';
|
|
5
6
|
|
|
7
|
+
import { NMRZone } from '..';
|
|
6
8
|
import { determineRealTop } from '../peaks/util/determineRealTop';
|
|
7
9
|
import { getKernel } from '../peaks/util/getKernel';
|
|
8
10
|
import type { GetKernelOptions } from '../peaks/util/getKernel';
|
|
9
11
|
import * as PeakOptimizer from '../peaks/util/peakOptimizer';
|
|
10
|
-
import type { MPFPeak } from '../types/MPFPeak';
|
|
11
12
|
import type { NMRSignal2D } from '../types/NMRSignal2D';
|
|
12
13
|
|
|
13
14
|
const smallFilter = [
|
|
@@ -86,7 +87,7 @@ export interface XYZAutoPeaksPickingOptions {
|
|
|
86
87
|
kernel?: GetKernelOptions;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
export function
|
|
90
|
+
export function xyzAutoZonesPicking(
|
|
90
91
|
spectraData: Data2D,
|
|
91
92
|
options: XYZAutoPeaksPickingOptions,
|
|
92
93
|
) {
|
|
@@ -178,7 +179,41 @@ export function xyzAutoPeaksPicking(
|
|
|
178
179
|
signals = PeakOptimizer.enhanceSymmetry(signals);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
return signals;
|
|
182
|
+
return formatZones(signals);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function formatZones(signals: NMRSignal2D[]) {
|
|
186
|
+
let zones: NMRZone[] = [];
|
|
187
|
+
for (const signal of signals) {
|
|
188
|
+
let minMax1 = [Number.MAX_VALUE, 0];
|
|
189
|
+
let minMax2 = [Number.MAX_VALUE, 0];
|
|
190
|
+
for (const peak of signal.peaks || []) {
|
|
191
|
+
if (peak.minX < minMax1[0]) {
|
|
192
|
+
minMax1[0] = peak.minX;
|
|
193
|
+
}
|
|
194
|
+
if (peak.maxX > minMax1[1]) {
|
|
195
|
+
minMax1[1] = peak.maxX;
|
|
196
|
+
}
|
|
197
|
+
if (peak.minY < minMax2[0]) {
|
|
198
|
+
minMax2[0] = peak.minY;
|
|
199
|
+
}
|
|
200
|
+
if (peak.maxY > minMax2[1]) {
|
|
201
|
+
minMax2[1] = peak.maxY;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
zones.push({
|
|
205
|
+
x: {
|
|
206
|
+
from: minMax1[0],
|
|
207
|
+
to: minMax1[1],
|
|
208
|
+
},
|
|
209
|
+
y: {
|
|
210
|
+
from: minMax2[0],
|
|
211
|
+
to: minMax2[1],
|
|
212
|
+
},
|
|
213
|
+
signals: [signal],
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return zones;
|
|
182
217
|
}
|
|
183
218
|
|
|
184
219
|
/**
|
|
@@ -201,7 +236,7 @@ export interface CreateSignals2DOptions {
|
|
|
201
236
|
minX: number;
|
|
202
237
|
maxX: number;
|
|
203
238
|
}
|
|
204
|
-
const createSignals2D = (peaks:
|
|
239
|
+
const createSignals2D = (peaks: Peak2D[], options: CreateSignals2DOptions) => {
|
|
205
240
|
let {
|
|
206
241
|
nCols,
|
|
207
242
|
nRows,
|
|
@@ -246,9 +281,6 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
246
281
|
peaks[i].maxY = minY + dy * peaks[i].maxY;
|
|
247
282
|
|
|
248
283
|
// Still having problems to correctly detect peaks on those areas. So I'm removing everything there.
|
|
249
|
-
if (peaks[i].y < -1 || peaks[i].y >= 210) {
|
|
250
|
-
peaks.splice(i, 1);
|
|
251
|
-
}
|
|
252
284
|
}
|
|
253
285
|
// The connectivity matrix is an square and symmetric matrix, so we'll only store the upper diagonal in an
|
|
254
286
|
// array like form
|
|
@@ -283,9 +315,7 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
283
315
|
resolution: dy,
|
|
284
316
|
},
|
|
285
317
|
};
|
|
286
|
-
let peaks2D = [];
|
|
287
|
-
let minMax1 = [Number.MAX_VALUE, 0];
|
|
288
|
-
let minMax2 = [Number.MAX_VALUE, 0];
|
|
318
|
+
let peaks2D: Peak2D[] = [];
|
|
289
319
|
let sumZ = 0;
|
|
290
320
|
|
|
291
321
|
for (let jPeak = 0; jPeak < cluster.length; jPeak++) {
|
|
@@ -294,25 +324,9 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
294
324
|
signal.x.delta += peaks[jPeak].x * peaks[jPeak].z;
|
|
295
325
|
signal.y.delta += peaks[jPeak].y * peaks[jPeak].z;
|
|
296
326
|
sumZ += peaks[jPeak].z;
|
|
297
|
-
if (peaks[jPeak].minX < minMax1[0]) {
|
|
298
|
-
minMax1[0] = peaks[jPeak].minX;
|
|
299
|
-
}
|
|
300
|
-
if (peaks[jPeak].maxX > minMax1[1]) {
|
|
301
|
-
minMax1[1] = peaks[jPeak].maxX;
|
|
302
|
-
}
|
|
303
|
-
if (peaks[jPeak].minY < minMax2[0]) {
|
|
304
|
-
minMax2[0] = peaks[jPeak].minY;
|
|
305
|
-
}
|
|
306
|
-
if (peaks[jPeak].maxY > minMax2[1]) {
|
|
307
|
-
minMax2[1] = peaks[jPeak].maxY;
|
|
308
|
-
}
|
|
309
327
|
}
|
|
310
328
|
}
|
|
311
329
|
|
|
312
|
-
signal.x.from = minMax1[0];
|
|
313
|
-
signal.y.from = minMax2[0];
|
|
314
|
-
signal.x.to = minMax1[1];
|
|
315
|
-
signal.y.to = minMax2[1];
|
|
316
330
|
signal.x.delta /= sumZ;
|
|
317
331
|
signal.y.delta /= sumZ;
|
|
318
332
|
signal.peaks = peaks2D;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
1
2
|
import simpleClustering from 'ml-simple-clustering';
|
|
2
3
|
|
|
3
4
|
import type { JAxisKeys } from '../peaks/util/jAnalyzer';
|
|
4
5
|
import jAnalyzer from '../peaks/util/jAnalyzer';
|
|
5
|
-
import type { MPFPeak } from '../types/MPFPeak';
|
|
6
6
|
import type { MakeMandatory } from '../types/MakeMandatory';
|
|
7
7
|
import type { NMRSignal2D } from '../types/NMRSignal2D';
|
|
8
8
|
|
|
@@ -96,7 +96,7 @@ function compilePattern(
|
|
|
96
96
|
for (const peak of peaks) {
|
|
97
97
|
if (!peak.width) peak.width = 0.02;
|
|
98
98
|
}
|
|
99
|
-
peaks.sort((a:
|
|
99
|
+
peaks.sort((a: Peak2D, b: Peak2D) => a.y - b.y);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
for (let i = 0; i < signals.length; i++) {
|
|
@@ -137,7 +137,7 @@ function compilePattern(
|
|
|
137
137
|
return signals;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
interface Peak2DHack extends
|
|
140
|
+
interface Peak2DHack extends Peak2D {
|
|
141
141
|
width?: number;
|
|
142
142
|
}
|
|
143
143
|
type Signal2DHack = Omit<NMRSignal2D, 'peaks'> & {
|
|
@@ -149,7 +149,7 @@ type Signal2DHack = Omit<NMRSignal2D, 'peaks'> & {
|
|
|
149
149
|
observe: number;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
function createSignals2D(peaksInput:
|
|
152
|
+
function createSignals2D(peaksInput: Peak2D[], options: any) {
|
|
153
153
|
let { observedFrequencies, tolerances, nuclei, dx, dy } = options;
|
|
154
154
|
|
|
155
155
|
const peaks: Peak2DHack[] = JSON.parse(JSON.stringify(peaksInput));
|