nmrium 0.38.2 → 0.39.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/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib/component/NMRium.d.ts +1 -0
- package/lib/component/NMRium.js +4 -2
- package/lib/component/context/LoggerContext.js +5 -0
- package/lib/component/context/PreferencesContext.d.ts +4 -2
- package/lib/component/elements/formik/FormikError.d.ts +8 -0
- package/lib/component/elements/formik/FormikError.js +22 -0
- package/lib/component/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- package/lib/component/modal/PredictSpectraModal.js +12 -2
- package/lib/component/modal/editRange/EditRangeModal.d.ts +7 -6
- package/lib/component/modal/editRange/EditRangeModal.js +33 -13
- package/lib/component/modal/setting/GeneralSettings.js +1 -1
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +1 -1
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib/component/reducer/actions/DomainActions.js +3 -0
- package/lib/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib/component/reducer/actions/ToolsActions.js +3 -32
- package/lib/component/reducer/actions/ZonesActions.js +2 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +8 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +35 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/data/PredictionManager.d.ts +3 -1
- package/lib/data/PredictionManager.js +27 -1
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib-cjs/component/NMRium.js +4 -2
- package/lib-cjs/component/context/LoggerContext.js +5 -0
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- package/lib-cjs/component/modal/PredictSpectraModal.js +12 -2
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +32 -12
- package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -1
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib-cjs/component/panels/Panels.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -0
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib-cjs/component/reducer/actions/ToolsActions.js +26 -32
- package/lib-cjs/component/reducer/actions/ZonesActions.js +2 -4
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +37 -0
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/data/PredictionManager.js +27 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +10 -10
|
@@ -38,7 +38,7 @@ const accordionItems = [
|
|
|
38
38
|
title: 'Peaks',
|
|
39
39
|
component: _jsx(PeaksPanel, {}),
|
|
40
40
|
hidePreferenceKey: 'peaksPanel',
|
|
41
|
-
mode:
|
|
41
|
+
mode: DISPLAYER_MODE.DM_1D,
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
title: 'Processings',
|
|
@@ -50,7 +50,7 @@ const accordionItems = [
|
|
|
50
50
|
title: 'Integrals',
|
|
51
51
|
component: _jsx(IntegralPanel, {}),
|
|
52
52
|
hidePreferenceKey: 'integralsPanel',
|
|
53
|
-
mode:
|
|
53
|
+
mode: DISPLAYER_MODE.DM_1D,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
title: 'Ranges',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RangeData } from './useMapRanges';
|
|
2
2
|
export default function useEditRangeModal(range?: RangeData): {
|
|
3
|
-
editRange: (
|
|
3
|
+
editRange: () => void;
|
|
4
4
|
deleteRange: (id?: string, resetSelectTool?: boolean) => void;
|
|
5
5
|
zoomRange: (modalRange?: RangeData) => void;
|
|
6
6
|
changeRangeSignalKind: (kind: any) => void;
|
|
@@ -57,31 +57,28 @@ export default function useEditRangeModal(range) {
|
|
|
57
57
|
modal.close();
|
|
58
58
|
}
|
|
59
59
|
}, [assignmentData, dispatch, modal]);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
deleteRange(range.id, true);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
saveEditRangeHandler(originalRange, false);
|
|
66
|
-
}
|
|
60
|
+
const resetHandler = useCallback((originalRange) => {
|
|
61
|
+
saveEditRangeHandler(originalRange, false);
|
|
67
62
|
modal.close();
|
|
68
|
-
}, [
|
|
69
|
-
const editRange = useCallback((
|
|
63
|
+
}, [modal, saveEditRangeHandler]);
|
|
64
|
+
const editRange = useCallback(() => {
|
|
65
|
+
if (!range?.id)
|
|
66
|
+
return;
|
|
70
67
|
dispatch({
|
|
71
68
|
type: 'SET_SELECTED_TOOL',
|
|
72
69
|
payload: { selectedTool: 'editRange' },
|
|
73
70
|
});
|
|
74
|
-
modal.show(_jsx(EditRangeModal, {
|
|
71
|
+
modal.show(_jsx(EditRangeModal, { onRest: resetHandler, onSave: saveEditRangeHandler, onZoom: zoomRange, rangeId: range?.id }), {
|
|
75
72
|
position: positions.MIDDLE_RIGHT,
|
|
76
73
|
transition: transitions.SCALE,
|
|
77
74
|
isBackgroundBlur: false,
|
|
78
75
|
});
|
|
79
76
|
zoomRange();
|
|
80
77
|
}, [
|
|
81
|
-
closeEditRangeHandler,
|
|
82
78
|
dispatch,
|
|
83
79
|
modal,
|
|
84
|
-
range,
|
|
80
|
+
range?.id,
|
|
81
|
+
resetHandler,
|
|
85
82
|
saveEditRangeHandler,
|
|
86
83
|
zoomRange,
|
|
87
84
|
]);
|
|
@@ -6,6 +6,7 @@ import { useAccordionContext } from 'react-science/ui';
|
|
|
6
6
|
import { predictSpectra } from '../../../data/PredictionManager';
|
|
7
7
|
import { useChartData } from '../../context/ChartContext';
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
|
+
import { useLogger } from '../../context/LoggerContext';
|
|
9
10
|
import Button from '../../elements/Button';
|
|
10
11
|
import NextPrev from '../../elements/NextPrev';
|
|
11
12
|
import { useAlert } from '../../elements/popup/Alert';
|
|
@@ -31,6 +32,7 @@ export default function PredictionPanel() {
|
|
|
31
32
|
const { molecules, view: { molecules: moleculesView, predictions }, } = useChartData();
|
|
32
33
|
const dispatch = useDispatch();
|
|
33
34
|
const alert = useAlert();
|
|
35
|
+
const { logger } = useLogger();
|
|
34
36
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
35
37
|
const [molfile, setMolfile] = useState(null);
|
|
36
38
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
@@ -70,7 +72,7 @@ export default function PredictionPanel() {
|
|
|
70
72
|
}
|
|
71
73
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
72
74
|
try {
|
|
73
|
-
const data = await predictSpectra(molfile);
|
|
75
|
+
const data = await predictSpectra(molfile, logger);
|
|
74
76
|
dispatch({
|
|
75
77
|
type: 'PREDICT_SPECTRA',
|
|
76
78
|
payload: {
|
|
@@ -23,9 +23,11 @@ function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
|
23
23
|
function handleResurrectSpectrumFromRanges(draft, action) {
|
|
24
24
|
const { ranges, info } = action.payload;
|
|
25
25
|
const datum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (datum) {
|
|
27
|
+
draft.data.push(datum);
|
|
28
|
+
setDomain(draft, { isYDomainShared: false });
|
|
29
|
+
setIntegralsYDomain(draft, [datum]);
|
|
30
|
+
setZoom(draft, { scale: 0.8, spectrumID: datum.id });
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
|
|
@@ -3,6 +3,7 @@ import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY';
|
|
|
3
3
|
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
|
|
4
4
|
import nucleusToString from '../../utility/nucleusToString';
|
|
5
5
|
import { DISPLAYER_MODE } from '../core/Constants';
|
|
6
|
+
import { addToBrushHistory } from '../helper/ZoomHistoryManager';
|
|
6
7
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
7
8
|
function getActiveData(draft) {
|
|
8
9
|
let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab &&
|
|
@@ -185,10 +186,12 @@ function setMode(draft) {
|
|
|
185
186
|
function handleSetXDomain(draft, action) {
|
|
186
187
|
const xDomain = action.payload.xDomain;
|
|
187
188
|
draft.xDomain = xDomain;
|
|
189
|
+
addToBrushHistory(draft, { xDomain, yDomain: draft.yDomain });
|
|
188
190
|
}
|
|
189
191
|
//action
|
|
190
192
|
function handleSetYDomain(draft, action) {
|
|
191
193
|
const yDomain = action.payload.yDomain;
|
|
192
194
|
draft.yDomain = yDomain;
|
|
195
|
+
addToBrushHistory(draft, { xDomain: draft.xDomain, yDomain });
|
|
193
196
|
}
|
|
194
197
|
export { getDomain, setDomain, setMode, setIntegralsYDomain, handleSetXDomain, handleSetYDomain, };
|
|
@@ -26,13 +26,15 @@ function handleAddIntegral(draft, action) {
|
|
|
26
26
|
const datum = data[activeSpectrum.index];
|
|
27
27
|
const { x, re } = datum.data;
|
|
28
28
|
const shiftX = getShiftX(datum);
|
|
29
|
+
const integration = xyIntegration({ x, y: re }, { from, to, reverse: true });
|
|
29
30
|
const integral = {
|
|
30
31
|
id: v4(),
|
|
31
32
|
originFrom: from - shiftX,
|
|
32
33
|
originTo: to - shiftX,
|
|
33
34
|
from,
|
|
34
35
|
to,
|
|
35
|
-
|
|
36
|
+
integral: integration,
|
|
37
|
+
absolute: integration,
|
|
36
38
|
kind: 'signal',
|
|
37
39
|
};
|
|
38
40
|
datum.integrals.values.push(integral);
|
|
@@ -6,7 +6,6 @@ import { Filters, FiltersManager } from 'nmr-processing';
|
|
|
6
6
|
import { generateSpectrumFromPublicationString, getReferenceShift, isSpectrum1D, get1DColor, } from '../../../data/data1d/Spectrum1D';
|
|
7
7
|
import { getMissingProjection, isSpectrum2D, get2DColor, } from '../../../data/data2d/Spectrum2D';
|
|
8
8
|
import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
|
|
9
|
-
import { options } from '../../toolbar/ToolTypes';
|
|
10
9
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
11
10
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
12
11
|
import { setZoom } from '../helper/Zoom1DManager';
|
|
@@ -204,8 +203,7 @@ function handleChangeActiveSpectrum(draft, action) {
|
|
|
204
203
|
setMargin(draft);
|
|
205
204
|
setMode(draft);
|
|
206
205
|
}
|
|
207
|
-
if (
|
|
208
|
-
!toolOptions.data.activeFilterID) {
|
|
206
|
+
if (!toolOptions.data.activeFilterID) {
|
|
209
207
|
resetSelectedTool(draft);
|
|
210
208
|
}
|
|
211
209
|
}
|
|
@@ -292,9 +290,11 @@ function handleAlignSpectraHandler(draft, action) {
|
|
|
292
290
|
function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
|
|
293
291
|
const publicationString = action.payload.publicationText;
|
|
294
292
|
const spectrum = generateSpectrumFromPublicationString(publicationString, draft.usedColors);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
293
|
+
if (spectrum) {
|
|
294
|
+
draft.data.push(spectrum);
|
|
295
|
+
setActiveTab(draft);
|
|
296
|
+
setZoom(draft, { scale: 0.8, spectrumID: spectrum.id });
|
|
297
|
+
}
|
|
298
298
|
}
|
|
299
299
|
//action
|
|
300
300
|
function handleImportSpectraMetaInfo(draft, action) {
|
|
@@ -11,7 +11,7 @@ import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
|
11
11
|
import { rangeStateInit } from '../Reducer';
|
|
12
12
|
import { DISPLAYER_MODE, MARGIN } from '../core/Constants';
|
|
13
13
|
import { setZoom, wheelZoom, ZOOM_TYPES, } from '../helper/Zoom1DManager';
|
|
14
|
-
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
14
|
+
import zoomHistoryManager, { addToBrushHistory, } from '../helper/ZoomHistoryManager';
|
|
15
15
|
import { getActiveSpectra } from '../helper/getActiveSpectra';
|
|
16
16
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
17
17
|
import { getVerticalAlign } from '../helper/getVerticalAlign';
|
|
@@ -145,7 +145,7 @@ function handleToggleRealImaginaryVisibility(draft) {
|
|
|
145
145
|
}
|
|
146
146
|
function handleBrushEnd(draft, action) {
|
|
147
147
|
const is2D = draft.displayerMode === DISPLAYER_MODE.DM_2D;
|
|
148
|
-
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode
|
|
148
|
+
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode } = draft;
|
|
149
149
|
const xScale = getXScale({ width, xDomains, xDomain, mode, margin });
|
|
150
150
|
const verticalAlign = getVerticalAlign(draft);
|
|
151
151
|
const yScale = is2D
|
|
@@ -158,36 +158,7 @@ function handleBrushEnd(draft, action) {
|
|
|
158
158
|
const endY = yScale.invert(_endY);
|
|
159
159
|
const domainX = startX > endX ? [endX, startX] : [startX, endX];
|
|
160
160
|
const domainY = startY > endY ? [endY, startY] : [startY, endY];
|
|
161
|
-
|
|
162
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
163
|
-
draft.zoom.history,
|
|
164
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
165
|
-
draft.view.spectra.activeTab);
|
|
166
|
-
if (displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
167
|
-
switch (trackID) {
|
|
168
|
-
case 'CENTER_2D':
|
|
169
|
-
draft.xDomain = domainX;
|
|
170
|
-
draft.yDomain = domainY;
|
|
171
|
-
break;
|
|
172
|
-
case 'TOP_1D':
|
|
173
|
-
draft.xDomain = domainX;
|
|
174
|
-
break;
|
|
175
|
-
case 'LEFT_1D':
|
|
176
|
-
draft.yDomain = domainY;
|
|
177
|
-
break;
|
|
178
|
-
default:
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
if (brushHistory) {
|
|
182
|
-
brushHistory.push({ xDomain, yDomain });
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
draft.xDomain = domainX;
|
|
187
|
-
if (brushHistory) {
|
|
188
|
-
brushHistory.push({ xDomain: domainX, yDomain: domainY });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
161
|
+
addToBrushHistory(draft, { trackID, xDomain: domainX, yDomain: domainY });
|
|
191
162
|
}
|
|
192
163
|
function setVerticalIndicatorXPosition(draft, action) {
|
|
193
164
|
const { position } = action.payload;
|
|
@@ -53,10 +53,8 @@ function handleAutoZonesDetection(draft, action) {
|
|
|
53
53
|
function handleAutoSpectraZonesDetection(draft) {
|
|
54
54
|
for (const datum of draft.data) {
|
|
55
55
|
const { info, data } = datum;
|
|
56
|
-
if (info.dimension === 2) {
|
|
57
|
-
const { minX, maxX, minY, maxY } =
|
|
58
|
-
? data.re
|
|
59
|
-
: data.rr;
|
|
56
|
+
if (info.dimension === 2 && info.isFt) {
|
|
57
|
+
const { minX, maxX, minY, maxY } = data.rr;
|
|
60
58
|
const detectionOptions = {
|
|
61
59
|
selectedZone: { fromX: minX, toX: maxX, fromY: minY, toY: maxY },
|
|
62
60
|
thresholdFactor: 1,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { Layout } from '../../2d/utilities/DimensionLayout';
|
|
3
|
+
import { State } from '../Reducer';
|
|
1
4
|
interface HistoryItem {
|
|
2
5
|
xDomain: Array<number>;
|
|
3
6
|
yDomain: Array<number>;
|
|
@@ -13,4 +16,9 @@ interface ZoomHistoryManager {
|
|
|
13
16
|
clear: () => void;
|
|
14
17
|
}
|
|
15
18
|
export default function zoomHistoryManager(zoomHistory: ZoomHistory, nucleus: string, baseZoom?: HistoryItem): ZoomHistoryManager;
|
|
19
|
+
export declare function addToBrushHistory(draft: Draft<State>, options: {
|
|
20
|
+
trackID?: Layout | null;
|
|
21
|
+
xDomain: number[];
|
|
22
|
+
yDomain: number[];
|
|
23
|
+
}): void;
|
|
16
24
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DISPLAYER_MODE } from '../core/Constants';
|
|
1
2
|
export default function zoomHistoryManager(zoomHistory, nucleus, baseZoom) {
|
|
2
3
|
if (!zoomHistory[nucleus] && !Array.isArray(zoomHistory[nucleus])) {
|
|
3
4
|
zoomHistory[nucleus] = [];
|
|
@@ -29,3 +30,37 @@ function prepareGetLast(historyStack) {
|
|
|
29
30
|
return historyStack.at(-1);
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
export function addToBrushHistory(draft, options) {
|
|
34
|
+
const { displayerMode } = draft;
|
|
35
|
+
const { trackID, xDomain, yDomain } = options;
|
|
36
|
+
const brushHistory = zoomHistoryManager(
|
|
37
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
38
|
+
draft.zoom.history,
|
|
39
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
40
|
+
draft.view.spectra.activeTab);
|
|
41
|
+
if (displayerMode === DISPLAYER_MODE.DM_2D) {
|
|
42
|
+
switch (trackID) {
|
|
43
|
+
case 'CENTER_2D':
|
|
44
|
+
draft.xDomain = xDomain;
|
|
45
|
+
draft.yDomain = yDomain;
|
|
46
|
+
break;
|
|
47
|
+
case 'TOP_1D':
|
|
48
|
+
draft.xDomain = xDomain;
|
|
49
|
+
break;
|
|
50
|
+
case 'LEFT_1D':
|
|
51
|
+
draft.yDomain = yDomain;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (brushHistory) {
|
|
57
|
+
brushHistory.push({ xDomain, yDomain });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
draft.xDomain = xDomain;
|
|
62
|
+
if (brushHistory) {
|
|
63
|
+
brushHistory.push({ xDomain, yDomain });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -3,12 +3,12 @@ import lodashMerge from 'lodash/merge';
|
|
|
3
3
|
import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
|
|
4
4
|
import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties';
|
|
5
5
|
export function addWorkspace(draft, action) {
|
|
6
|
-
const {
|
|
6
|
+
const { workspaceKey, data } = action.payload;
|
|
7
7
|
const newWorkSpace = lodashMerge({}, workspaceDefaultProperties,
|
|
8
8
|
// eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
|
|
9
9
|
data ? data : draft.workspaces[draft.workspace.current], {
|
|
10
10
|
version: 1,
|
|
11
|
-
label:
|
|
11
|
+
label: workspaceKey,
|
|
12
12
|
source: 'user',
|
|
13
13
|
});
|
|
14
14
|
const newWorkspaceKey = v4();
|
|
@@ -14,7 +14,7 @@ type InitPreferencesAction = ActionType<'INIT_PREFERENCES', {
|
|
|
14
14
|
customWorkspaces: Record<string, Workspace>;
|
|
15
15
|
dispatch: any;
|
|
16
16
|
}>;
|
|
17
|
-
type SetPreferencesAction = ActionType<'SET_PREFERENCES', Partial<Workspace
|
|
17
|
+
type SetPreferencesAction = ActionType<'SET_PREFERENCES', Partial<Workspace>> | ActionType<'SET_PREFERENCES', void>;
|
|
18
18
|
type SetPanelsPreferencesAction = ActionType<'SET_PANELS_PREFERENCES', {
|
|
19
19
|
key: string;
|
|
20
20
|
value: string;
|
|
@@ -30,7 +30,7 @@ export type WorkspaceAction = ActionType<'REMOVE_WORKSPACE' | 'SET_ACTIVE_WORKSP
|
|
|
30
30
|
workspace: string;
|
|
31
31
|
}>;
|
|
32
32
|
export type AddWorkspaceAction = ActionType<'ADD_WORKSPACE', {
|
|
33
|
-
|
|
33
|
+
workspaceKey: string;
|
|
34
34
|
data?: Omit<Workspace, 'version' | 'label'>;
|
|
35
35
|
}>;
|
|
36
36
|
export type ApplyGeneralPreferences = ActionType<'APPLY_General_PREFERENCES', {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FifoLogger } from 'fifo-logger';
|
|
1
2
|
import { Spectrum } from 'nmr-load-save';
|
|
2
3
|
import { PredictedAll } from 'nmr-processing';
|
|
3
4
|
export type Experiment = 'proton' | 'carbon' | 'cosy' | 'hsqc' | 'hmbc';
|
|
@@ -25,11 +26,12 @@ export interface PredictionOptions {
|
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
spectra: SpectraPredictionOptions;
|
|
29
|
+
logger?: FifoLogger;
|
|
28
30
|
}
|
|
29
31
|
export declare const defaultPredictionOptions: PredictionOptions;
|
|
30
32
|
export declare const FREQUENCIES: Array<{
|
|
31
33
|
value: number;
|
|
32
34
|
label: string;
|
|
33
35
|
}>;
|
|
34
|
-
export declare function predictSpectra(molfile: string): Promise<PredictedAll>;
|
|
36
|
+
export declare function predictSpectra(molfile: string, logger: FifoLogger): Promise<PredictedAll>;
|
|
35
37
|
export declare function generateSpectra(predictedSpectra: PredictedSpectraResult, inputOptions: PredictionOptions, color: string): Spectrum[];
|
|
@@ -26,7 +26,10 @@ export const defaultPredictionOptions = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export const FREQUENCIES = [
|
|
29
|
+
{ value: 40, label: '40 MHz' },
|
|
29
30
|
{ value: 60, label: '60 MHz' },
|
|
31
|
+
{ value: 80, label: '80 MHz' },
|
|
32
|
+
{ value: 90, label: '90 MHz' },
|
|
30
33
|
{ value: 100, label: '100 MHz' },
|
|
31
34
|
{ value: 200, label: '200 MHz' },
|
|
32
35
|
{ value: 300, label: '300 MHz' },
|
|
@@ -38,9 +41,10 @@ export const FREQUENCIES = [
|
|
|
38
41
|
{ value: 1200, label: '1200 MHz' },
|
|
39
42
|
];
|
|
40
43
|
const baseURL = 'https://nmr-prediction.service.zakodium.com';
|
|
41
|
-
export async function predictSpectra(molfile) {
|
|
44
|
+
export async function predictSpectra(molfile, logger) {
|
|
42
45
|
const molecule = OCL.Molecule.fromMolfile(molfile);
|
|
43
46
|
return predictAll(molecule, {
|
|
47
|
+
logger,
|
|
44
48
|
predictOptions: {
|
|
45
49
|
C: {
|
|
46
50
|
webserviceURL: `${baseURL}/v1/predict/carbon`,
|
|
@@ -165,6 +169,7 @@ function generated2DSpectrum(params) {
|
|
|
165
169
|
frequency,
|
|
166
170
|
experiment,
|
|
167
171
|
});
|
|
172
|
+
const spectralWidth = getSpectralWidth(experiment, inputOptions);
|
|
168
173
|
const datum = initiateDatum2D({
|
|
169
174
|
data: { rr: { ...minMaxContent, noise: 0.01 } },
|
|
170
175
|
display: {
|
|
@@ -178,6 +183,7 @@ function generated2DSpectrum(params) {
|
|
|
178
183
|
originFrequency: frequency,
|
|
179
184
|
baseFrequency: frequency,
|
|
180
185
|
pulseSequence: 'prediction',
|
|
186
|
+
spectralWidth,
|
|
181
187
|
experiment,
|
|
182
188
|
},
|
|
183
189
|
}, []);
|
|
@@ -187,6 +193,26 @@ function generated2DSpectrum(params) {
|
|
|
187
193
|
function get2DWidth(nucleus) {
|
|
188
194
|
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
189
195
|
}
|
|
196
|
+
function getSpectralWidth(experiment, options) {
|
|
197
|
+
const formTo = options['1d'];
|
|
198
|
+
switch (experiment) {
|
|
199
|
+
case 'cosy': {
|
|
200
|
+
const { from, to } = formTo['1H'];
|
|
201
|
+
const diff = to - from;
|
|
202
|
+
return [diff, diff];
|
|
203
|
+
}
|
|
204
|
+
case 'hsqc':
|
|
205
|
+
case 'hmbc': {
|
|
206
|
+
const proton = formTo['1H'];
|
|
207
|
+
const carbon = formTo['13C'];
|
|
208
|
+
const protonDiff = proton.to - proton.from;
|
|
209
|
+
const carbonDiff = carbon.to - carbon.from;
|
|
210
|
+
return [protonDiff, carbonDiff];
|
|
211
|
+
}
|
|
212
|
+
default:
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
190
216
|
function calculateFrequency(nucleus, frequency) {
|
|
191
217
|
if (typeof nucleus === 'string') {
|
|
192
218
|
return getFrequency(nucleus, { nucleus: '1H', frequency });
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Spectrum1D } from 'nmr-load-save';
|
|
2
1
|
import { UsedColors } from '../../../types/UsedColors';
|
|
3
|
-
export declare function generateSpectrumFromPublicationString(publicationString: string, usedColors: UsedColors): Spectrum1D;
|
|
2
|
+
export declare function generateSpectrumFromPublicationString(publicationString: string, usedColors: UsedColors): import("nmr-load-save").Spectrum1D | undefined;
|
|
@@ -57,13 +57,20 @@ export default function detectSignal(data, options) {
|
|
|
57
57
|
}
|
|
58
58
|
function joinCouplings(result) {
|
|
59
59
|
const { chemShift: delta, js } = result;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
let jCouplings = js;
|
|
61
|
+
if (js.length > 1) {
|
|
62
|
+
try {
|
|
63
|
+
jCouplings = signalJoinCouplings({
|
|
64
64
|
delta,
|
|
65
65
|
js,
|
|
66
|
-
}, { tolerance: 0.6, ignoreDiaIDs: true }).js
|
|
67
|
-
|
|
66
|
+
}, { tolerance: 0.6, ignoreDiaIDs: true }).js;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
reportError(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
delta,
|
|
74
|
+
js: jCouplings,
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -8,4 +8,4 @@ export interface ResurrectSpectrumInfo {
|
|
|
8
8
|
frequency?: number;
|
|
9
9
|
color?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare function generateSpectrumFromRanges(ranges: NMRRange[], info: ResurrectSpectrumInfo, usedColors: UsedColors): Spectrum1D;
|
|
11
|
+
export declare function generateSpectrumFromRanges(ranges: NMRRange[], info: ResurrectSpectrumInfo, usedColors: UsedColors): Spectrum1D | undefined;
|
|
@@ -2,23 +2,28 @@ import { rangesToXY } from 'nmr-processing';
|
|
|
2
2
|
import { initiateDatum1D } from '../initiateDatum1D';
|
|
3
3
|
export function generateSpectrumFromRanges(ranges, info, usedColors) {
|
|
4
4
|
const { nucleus, solvent, name = null, frequency = 400 } = info;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
frequency,
|
|
8
|
-
nbPoints: 2 ** 17,
|
|
9
|
-
});
|
|
10
|
-
const datum = initiateDatum1D({
|
|
11
|
-
data: { x, im: null, re: y },
|
|
12
|
-
info: {
|
|
5
|
+
try {
|
|
6
|
+
const { x, y } = rangesToXY(ranges, {
|
|
13
7
|
nucleus,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
frequency,
|
|
9
|
+
nbPoints: 2 ** 17,
|
|
10
|
+
});
|
|
11
|
+
const datum = initiateDatum1D({
|
|
12
|
+
data: { x, im: null, re: y },
|
|
13
|
+
info: {
|
|
14
|
+
nucleus,
|
|
15
|
+
originFrequency: frequency,
|
|
16
|
+
baseFrequency: frequency,
|
|
17
|
+
pulseSequence: '',
|
|
18
|
+
solvent,
|
|
19
|
+
isFt: true,
|
|
20
|
+
name,
|
|
21
|
+
},
|
|
22
|
+
ranges: { values: ranges, options: { sum: 100 } },
|
|
23
|
+
}, { usedColors });
|
|
24
|
+
return datum;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
reportError(error);
|
|
28
|
+
}
|
|
24
29
|
}
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.39.0' };
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const nmr_load_save_1 = require("nmr-load-save");
|
|
7
8
|
const react_1 = require("react");
|
|
8
9
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
9
10
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
10
11
|
const AnalysisRange_1 = __importDefault(require("./AnalysisRange"));
|
|
11
|
-
const nmr_load_save_1 = require("nmr-load-save");
|
|
12
12
|
function MultiAnalysisRangesInner({ columns, displayerKey, activeTab, }) {
|
|
13
13
|
const ranges = Object.keys(columns).filter((key) => columns[key].type !== nmr_load_save_1.AnalysisColumnsTypes.FORMULA);
|
|
14
14
|
if (!ranges || ranges.length === 0) {
|