nmrium 0.46.1 → 0.48.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/component/1d/Line.js +1 -1
- package/lib/component/1d/LinesSeries.d.ts +1 -1
- package/lib/component/1d/LinesSeries.js +24 -3
- package/lib/component/1d/integral/Integration.js +2 -1
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/ranges/Range.js +3 -1
- package/lib/component/1d/utilities/scale.d.ts +1 -0
- package/lib/component/1d/utilities/scale.js +2 -1
- package/lib/component/context/KeyModifierContext.d.ts +1 -1
- package/lib/component/elements/formik/FormikColorPickerDropdown.d.ts +6 -0
- package/lib/component/elements/formik/FormikColorPickerDropdown.js +14 -0
- package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +1 -0
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
- package/lib/component/hooks/useExport.js +2 -2
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
- package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
- package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
- package/lib/component/loader/DropZone.js +4 -2
- package/lib/component/main/InnerNMRium.js +1 -1
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/modal/setting/GeneralSettings.js +2 -1
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.d.ts +2 -0
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +131 -0
- package/lib/component/modal/setting/settingsValidation.js +12 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +16 -2
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +10 -2
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +26 -38
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
- package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
- package/lib/component/panels/databasePanel/DatabasePreferences.js +2 -2
- package/lib/component/panels/filtersPanel/FiltersTable.js +3 -2
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +1 -1
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/DomainActions.js +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +1 -2
- package/lib/component/reducer/actions/IntegralsActions.d.ts +8 -2
- package/lib/component/reducer/actions/IntegralsActions.js +10 -1
- package/lib/component/reducer/actions/LoadActions.d.ts +3 -1
- package/lib/component/reducer/actions/LoadActions.js +9 -4
- package/lib/component/reducer/actions/SpectrumsActions.js +14 -4
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/toolbar/FunctionToolBar.js +2 -1
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +42 -26
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +5 -0
- package/lib/component/workspaces/simulation.js +5 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +41 -0
- package/lib/data/PredictionManager.js +1 -1
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +9 -1
- package/lib/data/data1d/Spectrum1D/get1DColor.js +12 -4
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +2 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +7 -6
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -76
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +10 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +70 -0
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +9 -2
- package/lib/data/data2d/Spectrum2D/get2DColor.js +13 -5
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +7 -2
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +3 -2
- package/lib/data/utilities/getCustomColor.d.ts +4 -0
- package/lib/data/utilities/getCustomColor.js +38 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +25 -25
- package/lib/component/elements/formik/FormikColorInput.d.ts +0 -8
- package/lib/component/elements/formik/FormikColorInput.js +0 -15
|
@@ -12,16 +12,12 @@ const getSpectraDefaultValues = (nucleus) => {
|
|
|
12
12
|
visible: true,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
name: 'name',
|
|
16
15
|
label: 'Spectrum Name',
|
|
17
|
-
description: 'Spectrum Name',
|
|
18
16
|
jpath: ['info', 'name'],
|
|
19
17
|
visible: true,
|
|
20
18
|
},
|
|
21
19
|
{
|
|
22
|
-
name: 'solvent',
|
|
23
20
|
label: 'Solvent',
|
|
24
|
-
description: 'Solvent',
|
|
25
21
|
jpath: ['info', 'solvent'],
|
|
26
22
|
visible: true,
|
|
27
23
|
},
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { SvgNmrApodization, SvgNmrBaselineCorrection, SvgNmrFourierTransform, SvgNmrIntegrate, SvgNmrMultipleAnalysis, SvgNmrPeakPicking, SvgNmrPhaseCorrection, SvgNmrRangePicking, SvgNmrZeroFilling, } from 'cheminfo-font';
|
|
3
3
|
import { useState, useEffect, useCallback, memo } from 'react';
|
|
4
4
|
import { FaSearchPlus, FaExpand, FaDiceFour } from 'react-icons/fa';
|
|
5
|
+
import { PiKnifeBold } from 'react-icons/pi';
|
|
5
6
|
import { Toolbar } from 'react-science/ui';
|
|
6
7
|
import { useChartData } from '../context/ChartContext';
|
|
7
8
|
import { useDispatch } from '../context/DispatchContext';
|
|
@@ -66,7 +67,7 @@ function FunctionToolBarInner({ defaultValue, ftCounter, }) {
|
|
|
66
67
|
{
|
|
67
68
|
id: 'slicing',
|
|
68
69
|
label: options.slicing.label,
|
|
69
|
-
icon: _jsx(
|
|
70
|
+
icon: _jsx(PiKnifeBold, {}),
|
|
70
71
|
},
|
|
71
72
|
{
|
|
72
73
|
id: 'rangePicking',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import { SpectraTableColumn } from 'nmr-load-save';
|
|
2
3
|
/**
|
|
3
4
|
* export the experiments result in JSON format
|
|
4
5
|
* @param data
|
|
@@ -7,7 +8,7 @@ import { SerializedStyles } from '@emotion/react';
|
|
|
7
8
|
* @param isCompressed
|
|
8
9
|
*/
|
|
9
10
|
declare function exportAsJSON(data: any, fileName?: string, spaceIndent?: number, isCompressed?: boolean): Promise<void>;
|
|
10
|
-
declare function exportAsMatrix(data: any, fileName?: string): void;
|
|
11
|
+
declare function exportAsMatrix(data: any, spectraColumns: SpectraTableColumn[], fileName?: string): void;
|
|
11
12
|
declare function exportAsNMRE(data: any, fileName?: string): void;
|
|
12
13
|
declare function exportAsMol(data: any, fileName?: string): void;
|
|
13
14
|
/**
|
|
@@ -15,7 +16,7 @@ declare function exportAsMol(data: any, fileName?: string): void;
|
|
|
15
16
|
*/
|
|
16
17
|
declare function exportAsSVG(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
17
18
|
declare function exportAsPng(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
18
|
-
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): void
|
|
19
|
+
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): Promise<void>;
|
|
19
20
|
export interface BlobObject {
|
|
20
21
|
blob: Blob;
|
|
21
22
|
width: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveAs } from 'file-saver';
|
|
2
2
|
import JSZip from 'jszip';
|
|
3
|
-
import
|
|
3
|
+
import lodashGet from 'lodash/get';
|
|
4
4
|
/**
|
|
5
5
|
* export the experiments result in JSON format
|
|
6
6
|
* @param data
|
|
@@ -33,16 +33,29 @@ async function exportAsJSON(data, fileName = 'experiment', spaceIndent = 0, isCo
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function exportAsMatrix(data, fileName = 'experiment') {
|
|
36
|
+
function exportAsMatrix(data, spectraColumns, fileName = 'experiment') {
|
|
37
37
|
//columns labels
|
|
38
|
-
const
|
|
38
|
+
const columnsLabels = [];
|
|
39
|
+
// listed the spectra panel columns
|
|
40
|
+
for (const col of spectraColumns) {
|
|
41
|
+
if (col.visible && 'jpath' in col) {
|
|
42
|
+
columnsLabels.push(col.label);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
39
45
|
for (const value of data[0].data.x) {
|
|
40
|
-
|
|
46
|
+
columnsLabels.push(value);
|
|
41
47
|
}
|
|
42
|
-
let matrix = `${
|
|
48
|
+
let matrix = `${columnsLabels.join('\t')}\n`;
|
|
43
49
|
for (const spectrum of data) {
|
|
44
|
-
const { data: { re },
|
|
45
|
-
const cellsValues = [
|
|
50
|
+
const { data: { re }, } = spectrum;
|
|
51
|
+
const cellsValues = [];
|
|
52
|
+
// listed the spectra cell values
|
|
53
|
+
for (const col of spectraColumns) {
|
|
54
|
+
if (col.visible && 'jpath' in col) {
|
|
55
|
+
const jpath = col?.jpath;
|
|
56
|
+
cellsValues.push(lodashGet(spectrum, jpath, `null`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
46
59
|
for (const value of re) {
|
|
47
60
|
cellsValues.push(value);
|
|
48
61
|
}
|
|
@@ -107,29 +120,32 @@ function copyDataURLClipboardFireFox(image) {
|
|
|
107
120
|
document.execCommand('Copy');
|
|
108
121
|
img.remove();
|
|
109
122
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
123
|
+
async function resolveBlob(b) {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
resolve(b);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function writeImageToClipboard(image, isSafari = false) {
|
|
129
|
+
await navigator.clipboard.write([
|
|
130
|
+
new ClipboardItem({ [image.type]: isSafari ? resolveBlob(image) : image }),
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
async function copyBlobToClipboard(canvas) {
|
|
134
|
+
canvas.toBlob(async (b) => {
|
|
112
135
|
if (!b)
|
|
113
136
|
return;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})()
|
|
120
|
-
.catch(() => {
|
|
137
|
+
const isSafari = /^(?<safari>(?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
138
|
+
if (typeof ClipboardItem !== 'undefined') {
|
|
139
|
+
await writeImageToClipboard(b, isSafari).catch(reportError);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
121
142
|
const png = canvas.toDataURL('image/png', 1);
|
|
122
143
|
copyDataURLClipboardFireFox(png);
|
|
123
144
|
URL.revokeObjectURL(png);
|
|
124
|
-
}
|
|
125
|
-
.then(() => {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
|
-
console.log('experiment copied.');
|
|
128
|
-
})
|
|
129
|
-
.catch(reportError);
|
|
145
|
+
}
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
function copyPNGToClipboard(rootRef, elementID, css) {
|
|
148
|
+
async function copyPNGToClipboard(rootRef, elementID, css) {
|
|
133
149
|
const { blob, width, height } = getBlob(rootRef, elementID, css);
|
|
134
150
|
try {
|
|
135
151
|
const canvas = document.createElement('canvas');
|
|
@@ -142,16 +158,16 @@ function copyPNGToClipboard(rootRef, elementID, css) {
|
|
|
142
158
|
}
|
|
143
159
|
const img = new Image();
|
|
144
160
|
const url = URL.createObjectURL(blob);
|
|
145
|
-
img.addEventListener('load', () => {
|
|
161
|
+
img.addEventListener('load', async () => {
|
|
146
162
|
context?.drawImage(img, 0, 0);
|
|
147
|
-
copyBlobToClipboard(canvas);
|
|
163
|
+
await copyBlobToClipboard(canvas);
|
|
148
164
|
});
|
|
149
165
|
img.src = url;
|
|
150
166
|
}
|
|
151
167
|
catch (error) {
|
|
152
168
|
if (error instanceof ReferenceError) {
|
|
153
169
|
// eslint-disable-next-line no-alert
|
|
154
|
-
alert('Your browser does not support this feature, please use Google Chrome');
|
|
170
|
+
alert('Your browser does not support this feature, please use Google Chrome or Firefox');
|
|
155
171
|
}
|
|
156
172
|
// TODO: handle error.
|
|
157
173
|
reportError(error);
|
|
@@ -10,6 +10,11 @@ export const simulation = {
|
|
|
10
10
|
invert: false,
|
|
11
11
|
},
|
|
12
12
|
display: {
|
|
13
|
+
general: {
|
|
14
|
+
hideGeneralSettings: true,
|
|
15
|
+
hideLogs: true,
|
|
16
|
+
hideWorkspaces: true,
|
|
17
|
+
},
|
|
13
18
|
panels: {
|
|
14
19
|
spectraPanel: { display: true },
|
|
15
20
|
simulationPanel: { display: true, open: true },
|
|
@@ -185,4 +185,45 @@ export const workspaceDefaultProperties = {
|
|
|
185
185
|
],
|
|
186
186
|
},
|
|
187
187
|
},
|
|
188
|
+
spectraColors: {
|
|
189
|
+
oneDimension: [],
|
|
190
|
+
twoDimensions: [
|
|
191
|
+
{
|
|
192
|
+
jpath: ['info', 'experiment'],
|
|
193
|
+
value: 'cosy',
|
|
194
|
+
positiveColor: 'darkblue',
|
|
195
|
+
negativeColor: 'blue',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
jpath: ['info', 'experiment'],
|
|
199
|
+
value: 'noesy',
|
|
200
|
+
positiveColor: 'pink',
|
|
201
|
+
negativeColor: 'yellow',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
jpath: ['info', 'experiment'],
|
|
205
|
+
value: 'roesy',
|
|
206
|
+
positiveColor: 'pink',
|
|
207
|
+
negativeColor: 'yellow',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
jpath: ['info', 'experiment'],
|
|
211
|
+
value: 'tocsy',
|
|
212
|
+
positiveColor: 'green',
|
|
213
|
+
negativeColor: 'yellow',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
jpath: ['info', 'experiment'],
|
|
217
|
+
value: 'hsqc',
|
|
218
|
+
positiveColor: 'black',
|
|
219
|
+
negativeColor: 'yellow',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
jpath: ['info', 'experiment'],
|
|
223
|
+
value: 'hmbc',
|
|
224
|
+
positiveColor: 'darkviolet',
|
|
225
|
+
negativeColor: 'yellow',
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
188
229
|
};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { SpectrumOneDimensionColor } from 'nmr-load-save';
|
|
2
|
+
import { UsedColors } from '../../../types/UsedColors';
|
|
3
|
+
interface GetOnDimensionColorOption {
|
|
4
|
+
usedColors?: UsedColors;
|
|
5
|
+
colors?: SpectrumOneDimensionColor[];
|
|
6
|
+
regenerate?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function get1DColor(spectrum: any, options: GetOnDimensionColorOption): {
|
|
2
9
|
color: string;
|
|
3
10
|
};
|
|
11
|
+
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { generateColor } from '../../utilities/generateColor';
|
|
2
|
-
|
|
2
|
+
import { getCustomColor } from '../../utilities/getCustomColor';
|
|
3
|
+
export function get1DColor(spectrum, options) {
|
|
4
|
+
const { regenerate = false, usedColors = {}, colors } = options;
|
|
3
5
|
let color = 'black';
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
+
if (!spectrum?.display?.color || regenerate) {
|
|
7
|
+
const customColor = getCustomColor(spectrum, colors);
|
|
8
|
+
if (customColor) {
|
|
9
|
+
color = customColor;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
color = generateColor(false, usedColors?.['1d'] || []);
|
|
13
|
+
}
|
|
6
14
|
}
|
|
7
15
|
else {
|
|
8
|
-
color =
|
|
16
|
+
color = spectrum.display.color;
|
|
9
17
|
}
|
|
10
18
|
if (usedColors['1d']) {
|
|
11
19
|
usedColors['1d'].push(color);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Spectrum1D } from 'nmr-load-save';
|
|
1
|
+
import { Spectrum1D, SpectrumOneDimensionColor } from 'nmr-load-save';
|
|
2
2
|
import { UsedColors } from '../../../types/UsedColors';
|
|
3
3
|
import { StateMoleculeExtended } from '../../molecules/Molecule';
|
|
4
4
|
export interface InitiateDatum1DOptions {
|
|
5
5
|
usedColors?: UsedColors;
|
|
6
6
|
molecules?: StateMoleculeExtended[];
|
|
7
|
+
colors?: SpectrumOneDimensionColor[];
|
|
7
8
|
}
|
|
8
9
|
export declare function initiateDatum1D(spectrum: any, options?: InitiateDatum1DOptions): Spectrum1D;
|
|
@@ -8,7 +8,7 @@ import { initiateIntegrals } from './integrals/initiateIntegrals';
|
|
|
8
8
|
import { initiatePeaks } from './peaks/initiatePeaks';
|
|
9
9
|
import { initiateRanges } from './ranges/initiateRanges';
|
|
10
10
|
export function initiateDatum1D(spectrum, options = {}) {
|
|
11
|
-
const { usedColors
|
|
11
|
+
const { usedColors, colors, molecules = [] } = options;
|
|
12
12
|
const { integrals, ranges, ...restSpectrum } = spectrum;
|
|
13
13
|
const spectrumObj = { ...restSpectrum };
|
|
14
14
|
spectrumObj.id = spectrum.id || v4();
|
|
@@ -16,7 +16,7 @@ export function initiateDatum1D(spectrum, options = {}) {
|
|
|
16
16
|
isVisible: true,
|
|
17
17
|
isRealSpectrumVisible: true,
|
|
18
18
|
...spectrum.display,
|
|
19
|
-
...get1DColor(spectrum, usedColors),
|
|
19
|
+
...get1DColor(spectrum, { usedColors, colors }),
|
|
20
20
|
};
|
|
21
21
|
spectrumObj.info = {
|
|
22
22
|
nucleus: '1H', // 1H, 13C, 19F, ...
|
|
@@ -5,6 +5,13 @@ export default function detectSignals(data: DataXY, options: {
|
|
|
5
5
|
nucleus: string;
|
|
6
6
|
frequency: number;
|
|
7
7
|
}): {
|
|
8
|
+
multiplicity: any;
|
|
9
|
+
kind: string;
|
|
10
|
+
delta: number;
|
|
11
|
+
js: any;
|
|
12
|
+
peaks: import("nmr-processing").NMRPeak1DWithShapeID[];
|
|
13
|
+
diaIDs: never[];
|
|
14
|
+
}[] | {
|
|
8
15
|
delta: number;
|
|
9
16
|
id?: string | undefined;
|
|
10
17
|
js: import("nmr-processing").Jcoupling[];
|
|
@@ -23,10 +30,4 @@ export default function detectSignals(data: DataXY, options: {
|
|
|
23
30
|
max: number;
|
|
24
31
|
nb: number;
|
|
25
32
|
} | undefined;
|
|
26
|
-
}[] | {
|
|
27
|
-
multiplicity: any;
|
|
28
|
-
kind: string;
|
|
29
|
-
delta: number;
|
|
30
|
-
js: any;
|
|
31
|
-
diaIDs: never[];
|
|
32
33
|
}[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { xGetFromToIndex } from 'ml-spectra-processing';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { xyAutoRangesPicking } from 'nmr-processing';
|
|
3
|
+
import { detectSignalsByMultipletAnalysis } from './detectSignalsByMultipletAnalysis';
|
|
4
4
|
const MAX_LENGTH = 4092;
|
|
5
5
|
export default function detectSignals(data, options) {
|
|
6
6
|
const { from, to, frequency, nucleus } = options;
|
|
@@ -34,77 +34,3 @@ export default function detectSignals(data, options) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function detectSignalsByMultipletAnalysis(data, options) {
|
|
38
|
-
const { fromIndex, toIndex, frequency } = options;
|
|
39
|
-
const dataRoi = {
|
|
40
|
-
x: data.x.slice(fromIndex, toIndex),
|
|
41
|
-
y: data.y.slice(fromIndex, toIndex),
|
|
42
|
-
};
|
|
43
|
-
const result = analyseMultiplet(dataRoi, {
|
|
44
|
-
frequency,
|
|
45
|
-
minimalResolution: 0.1,
|
|
46
|
-
maxTestedJ: 17,
|
|
47
|
-
checkSymmetryFirst: true,
|
|
48
|
-
takeBestPartMultiplet: true,
|
|
49
|
-
correctVerticalOffset: true,
|
|
50
|
-
symmetrizeEachStep: false,
|
|
51
|
-
decreasingJvalues: true,
|
|
52
|
-
makeShortCutForSpeed: true,
|
|
53
|
-
});
|
|
54
|
-
if (result && result.chemShift === undefined)
|
|
55
|
-
return [];
|
|
56
|
-
const { delta, js } = joinCouplings(result);
|
|
57
|
-
let cs = 0;
|
|
58
|
-
let area = 0;
|
|
59
|
-
for (let i = 0; i < dataRoi.x.length; i++) {
|
|
60
|
-
cs += dataRoi.x[i] * dataRoi.y[i];
|
|
61
|
-
area += dataRoi.y[i];
|
|
62
|
-
}
|
|
63
|
-
cs /= area;
|
|
64
|
-
const multiplicity = getMultiplicity(js, { cs, data, delta, frequency });
|
|
65
|
-
return [
|
|
66
|
-
{
|
|
67
|
-
multiplicity,
|
|
68
|
-
kind: 'signal',
|
|
69
|
-
delta: cs,
|
|
70
|
-
js,
|
|
71
|
-
diaIDs: [],
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
function getMultiplicity(js, options) {
|
|
76
|
-
const { cs, delta, frequency, data } = options;
|
|
77
|
-
if (js?.length > 0) {
|
|
78
|
-
return js.map((j) => j.multiplicity).join('');
|
|
79
|
-
}
|
|
80
|
-
//check if the massive center is closer to the shift from multiplet-analysis,
|
|
81
|
-
//if true, is it possibly a singlet.
|
|
82
|
-
if (Math.abs(cs - delta) / cs < 1e-3) {
|
|
83
|
-
let peaks = [];
|
|
84
|
-
if (js?.length === 0) {
|
|
85
|
-
peaks = xyAutoPeaksPicking(data, { frequency });
|
|
86
|
-
}
|
|
87
|
-
if (peaks.length === 1)
|
|
88
|
-
return 's';
|
|
89
|
-
}
|
|
90
|
-
return 'm';
|
|
91
|
-
}
|
|
92
|
-
function joinCouplings(result) {
|
|
93
|
-
const { chemShift: delta, js } = result;
|
|
94
|
-
let jCouplings = js;
|
|
95
|
-
if (js.length > 1) {
|
|
96
|
-
try {
|
|
97
|
-
jCouplings = signalJoinCouplings({
|
|
98
|
-
delta,
|
|
99
|
-
js,
|
|
100
|
-
}, { tolerance: 0.6, ignoreDiaIDs: true }).js;
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
reportError(error);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
delta,
|
|
108
|
-
js: jCouplings,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataXY } from 'cheminfo-types';
|
|
2
|
+
import { NMRPeak1DWithShapeID } from 'nmr-processing';
|
|
3
|
+
export declare function detectSignalsByMultipletAnalysis(data: DataXY, options: any): {
|
|
4
|
+
multiplicity: any;
|
|
5
|
+
kind: string;
|
|
6
|
+
delta: number;
|
|
7
|
+
js: any;
|
|
8
|
+
peaks: NMRPeak1DWithShapeID[];
|
|
9
|
+
diaIDs: never[];
|
|
10
|
+
}[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { analyseMultiplet } from 'multiplet-analysis';
|
|
2
|
+
import { signalJoinCouplings, xyAutoPeaksPicking, } from 'nmr-processing';
|
|
3
|
+
export function detectSignalsByMultipletAnalysis(data, options) {
|
|
4
|
+
const { fromIndex, toIndex, frequency } = options;
|
|
5
|
+
const dataRoi = {
|
|
6
|
+
x: data.x.slice(fromIndex, toIndex),
|
|
7
|
+
y: data.y.slice(fromIndex, toIndex),
|
|
8
|
+
};
|
|
9
|
+
const result = analyseMultiplet(dataRoi, {
|
|
10
|
+
frequency,
|
|
11
|
+
minimalResolution: 0.1,
|
|
12
|
+
maxTestedJ: 17,
|
|
13
|
+
checkSymmetryFirst: true,
|
|
14
|
+
takeBestPartMultiplet: true,
|
|
15
|
+
correctVerticalOffset: true,
|
|
16
|
+
symmetrizeEachStep: false,
|
|
17
|
+
decreasingJvalues: true,
|
|
18
|
+
makeShortCutForSpeed: true,
|
|
19
|
+
});
|
|
20
|
+
if (result && result.chemShift === undefined)
|
|
21
|
+
return [];
|
|
22
|
+
const { delta, js } = joinCouplings(result);
|
|
23
|
+
let cs = 0;
|
|
24
|
+
let area = 0;
|
|
25
|
+
for (let i = 0; i < dataRoi.x.length; i++) {
|
|
26
|
+
cs += dataRoi.x[i] * dataRoi.y[i];
|
|
27
|
+
area += dataRoi.y[i];
|
|
28
|
+
}
|
|
29
|
+
cs /= area;
|
|
30
|
+
const peaks = xyAutoPeaksPicking(dataRoi, { frequency });
|
|
31
|
+
const multiplicity = getMultiplicity(js, { cs, delta, peaks });
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
multiplicity,
|
|
35
|
+
kind: 'signal',
|
|
36
|
+
delta: cs,
|
|
37
|
+
js,
|
|
38
|
+
peaks,
|
|
39
|
+
diaIDs: [],
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
function getMultiplicity(js, options) {
|
|
44
|
+
const { cs, delta, peaks } = options;
|
|
45
|
+
if (js?.length > 0) {
|
|
46
|
+
return js.map((j) => j.multiplicity).join('');
|
|
47
|
+
}
|
|
48
|
+
//check if the massive center is closer to the shift from multiplet-analysis,
|
|
49
|
+
//if true, is it possibly a singlet.
|
|
50
|
+
return peaks.length === 1 && Math.abs(cs - delta) / cs < 1e-3 ? 's' : 'm';
|
|
51
|
+
}
|
|
52
|
+
function joinCouplings(result) {
|
|
53
|
+
const { chemShift: delta, js } = result;
|
|
54
|
+
let jCouplings = js;
|
|
55
|
+
if (js.length > 1) {
|
|
56
|
+
try {
|
|
57
|
+
jCouplings = signalJoinCouplings({
|
|
58
|
+
delta,
|
|
59
|
+
js,
|
|
60
|
+
}, { tolerance: 0.6, ignoreDiaIDs: true }).js;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
reportError(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
delta,
|
|
68
|
+
js: jCouplings,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -99,15 +99,19 @@ export function generateAnalyzeSpectra(multipleSpectraAnalysis, spectra, nucleus
|
|
|
99
99
|
const newData = Object.fromEntries(Object.entries(data).map((spectra) => {
|
|
100
100
|
const result = Object.fromEntries(Object.keys(columns).map((key) => {
|
|
101
101
|
const isFormula = columns[key].type === AnalysisColumnsTypes.FORMULA;
|
|
102
|
-
|
|
103
|
-
key
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
if (isFormula) {
|
|
103
|
+
const { SID, id } = spectra[1][key];
|
|
104
|
+
return [
|
|
105
|
+
key,
|
|
106
|
+
{
|
|
107
|
+
SID,
|
|
108
|
+
id,
|
|
106
109
|
colKey: key,
|
|
107
110
|
value: calculate(columns, data[spectra[0]], columns[key].formula),
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
return [key, { ...spectra[1][key], colKey: key }];
|
|
111
115
|
}));
|
|
112
116
|
return [spectra[0], result];
|
|
113
117
|
}));
|
|
@@ -147,52 +151,35 @@ export function getDataAsString(spectraAnalysis, spectra, spectraPanelPreference
|
|
|
147
151
|
const spectraData = convertSpectraArrayToObject(spectra);
|
|
148
152
|
if (spectraAnalysis) {
|
|
149
153
|
const { values, options: { columns }, } = spectraAnalysis;
|
|
150
|
-
|
|
154
|
+
//columns labels
|
|
155
|
+
const letters = Object.keys(columns);
|
|
156
|
+
const columnsLabels = letters.slice();
|
|
157
|
+
let index = 0;
|
|
151
158
|
// listed the spectra panel columns
|
|
152
159
|
for (const col of spectraPanelPreferences.columns) {
|
|
153
|
-
if (col.visible) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
result += `${col.label}\t`;
|
|
157
|
-
}
|
|
160
|
+
if (col.visible && 'jpath' in col) {
|
|
161
|
+
columnsLabels.splice(index, 0, col.label);
|
|
162
|
+
index++;
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
|
-
|
|
161
|
-
// listed the spectra analysis panel columns
|
|
162
|
-
for (const letter of letters) {
|
|
163
|
-
result += `${letter}\t`;
|
|
164
|
-
}
|
|
165
|
-
result += '\n';
|
|
165
|
+
let result = `${columnsLabels.join('\t')}\n`;
|
|
166
166
|
for (const spectrumAnalysis of Object.values(values)) {
|
|
167
167
|
const spectrum = spectraData[spectrumAnalysis[letters[0]].SID];
|
|
168
|
+
const cellsValues = [];
|
|
168
169
|
// listed the spectra cell values
|
|
169
170
|
for (const col of spectraPanelPreferences.columns) {
|
|
170
|
-
if (col.visible) {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
switch (name) {
|
|
175
|
-
case 'name':
|
|
176
|
-
result += `${spectrum.info.name}\t`;
|
|
177
|
-
break;
|
|
178
|
-
case 'solvent':
|
|
179
|
-
result += `${spectrum.info.solvent || `null`}\t`;
|
|
180
|
-
break;
|
|
181
|
-
default:
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
const path = col?.jpath;
|
|
187
|
-
result += `${lodashGet(spectrum, path, `null`)}\t`;
|
|
188
|
-
}
|
|
171
|
+
if (col.visible && 'jpath' in col) {
|
|
172
|
+
const jpath = col?.jpath;
|
|
173
|
+
const value = lodashGet(spectrum, jpath, `null`);
|
|
174
|
+
cellsValues.push(value);
|
|
189
175
|
}
|
|
190
176
|
}
|
|
191
177
|
// listed the spectra analysis cell values
|
|
192
178
|
for (const letter of letters) {
|
|
193
|
-
|
|
179
|
+
const value = spectrumAnalysis[letter][columns[letter].valueKey];
|
|
180
|
+
cellsValues.push(value);
|
|
194
181
|
}
|
|
195
|
-
result += '\n
|
|
182
|
+
result += `${cellsValues.join('\t')}\n`;
|
|
196
183
|
}
|
|
197
184
|
return result;
|
|
198
185
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import { Color2D } from 'nmr-load-save';
|
|
2
|
-
|
|
1
|
+
import { Color2D, SpectrumTwoDimensionsColor } from 'nmr-load-save';
|
|
2
|
+
import { UsedColors } from '../../../types/UsedColors';
|
|
3
|
+
interface GetTwoDimensionsColorOption {
|
|
4
|
+
usedColors?: UsedColors;
|
|
5
|
+
colors?: SpectrumTwoDimensionsColor[];
|
|
6
|
+
regenerate?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function get2DColor(spectrum: any, options: GetTwoDimensionsColorOption): Color2D;
|
|
9
|
+
export {};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { generate2DColor } from '../../utilities/generateColor';
|
|
2
|
-
|
|
2
|
+
import { getCustomColor } from '../../utilities/getCustomColor';
|
|
3
|
+
export function get2DColor(spectrum, options) {
|
|
4
|
+
const { regenerate = false, usedColors = {}, colors } = options;
|
|
3
5
|
let color = {};
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
+
if (spectrum?.display?.negativeColor === undefined ||
|
|
7
|
+
spectrum?.display?.positiveColor === undefined ||
|
|
6
8
|
regenerate) {
|
|
7
|
-
|
|
9
|
+
const customColor = getCustomColor(spectrum, colors);
|
|
10
|
+
if (customColor) {
|
|
11
|
+
color = customColor;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
color = generate2DColor(spectrum.info.experiment, usedColors?.['2d'] || []);
|
|
15
|
+
}
|
|
8
16
|
}
|
|
9
17
|
else {
|
|
10
|
-
const { positiveColor = 'red', negativeColor = 'blue' } =
|
|
18
|
+
const { positiveColor = 'red', negativeColor = 'blue' } = spectrum?.display || {};
|
|
11
19
|
color = { positiveColor, negativeColor };
|
|
12
20
|
}
|
|
13
21
|
if (usedColors['2d']) {
|