nmrium 0.46.1 → 0.47.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/integral/Integration.js +2 -1
- package/lib/component/1d/ranges/Range.js +3 -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/loader/DropZone.js +4 -2
- 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/RangesPanel/RangesHeader.js +10 -2
- package/lib/component/panels/databasePanel/DatabasePreferences.js +2 -2
- package/lib/component/panels/filtersPanel/FiltersTable.js +3 -2
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +1 -1
- 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 +9 -3
- package/lib/component/toolbar/FunctionToolBar.js +2 -1
- 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/data2d/Spectrum2D/get2DColor.d.ts +9 -2
- package/lib/data/data2d/Spectrum2D/get2DColor.js +13 -5
- 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 +3 -3
- package/lib/component/elements/formik/FormikColorInput.d.ts +0 -8
- package/lib/component/elements/formik/FormikColorInput.js +0 -15
|
@@ -7,6 +7,7 @@ export function Integration({ integral, nucleus, max }) {
|
|
|
7
7
|
const { x, y } = integral;
|
|
8
8
|
const { scaleRatio } = useActiveSpectrumIntegralsViewState();
|
|
9
9
|
const path = useIntegralPath({ x, y, max, scaleRatio });
|
|
10
|
+
const { showIntegralsValues } = useActiveSpectrumIntegralsViewState();
|
|
10
11
|
const integralPreferences = usePanelPreferences('integrals', nucleus);
|
|
11
|
-
return (_jsxs("g", { children: [_jsx("path", { className: "line", stroke: integralPreferences.color, strokeWidth: integralPreferences.strokeWidth, fill: "none", d: path }), _jsx(IntegralResizable, { integralData: integral, integralFormat: integralPreferences.relative.format })] }));
|
|
12
|
+
return (_jsxs("g", { children: [_jsx("path", { className: "line", stroke: integralPreferences.color, strokeWidth: integralPreferences.strokeWidth, fill: "none", d: path }), showIntegralsValues && (_jsx(IntegralResizable, { integralData: integral, integralFormat: integralPreferences.relative.format }))] }));
|
|
12
13
|
}
|
|
@@ -8,6 +8,7 @@ import { filterForIDsWithAssignment } from '../../assignment/utilities/filterFor
|
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
9
|
import { ResizerWithScale } from '../../elements/ResizerWithScale';
|
|
10
10
|
import { HighlightEventSource, useHighlight } from '../../highlight';
|
|
11
|
+
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
11
12
|
import { useResizerStatus } from '../../hooks/useResizerStatus';
|
|
12
13
|
import { options } from '../../toolbar/ToolTypes';
|
|
13
14
|
import { IntegralIndicator } from '../integral/IntegralIndicator';
|
|
@@ -32,6 +33,7 @@ function Range({ range, showMultiplicityTrees, selectedTool, relativeFormat, })
|
|
|
32
33
|
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE, extra: { id } });
|
|
33
34
|
const scaleX = useScaleX();
|
|
34
35
|
const dispatch = useDispatch();
|
|
36
|
+
const { showIntegralsValues } = useActiveSpectrumRangesViewState();
|
|
35
37
|
const isBlockedByEditing = selectedTool && selectedTool === options.editRange.id;
|
|
36
38
|
function handleOnStopResizing(position) {
|
|
37
39
|
dispatch({
|
|
@@ -74,7 +76,7 @@ function Range({ range, showMultiplicityTrees, selectedTool, relativeFormat, })
|
|
|
74
76
|
const isResizingActive = useResizerStatus('rangePicking');
|
|
75
77
|
return (_jsxs("g", { "data-testid": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, ...(!assignmentRange.isActive && { css: style }), children: [_jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isActive) => {
|
|
76
78
|
const width = x2 - x1;
|
|
77
|
-
return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), _jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 })] }));
|
|
79
|
+
return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
|
|
78
80
|
} }), showMultiplicityTrees && (_jsx(MultiplicityTree, { range: range, onUnlink: unAssignHandler })), _jsx(AssignmentActionsButtons, { isActive: !!(assignmentRange.isActive || diaIDs), x: scaleX()(from) - 16, onAssign: assignHandler, onUnAssign: () => unAssignHandler() })] }, id));
|
|
79
81
|
}
|
|
80
82
|
export default Range;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ColorPickerProps } from 'react-science/ui';
|
|
2
|
+
interface FormikColorPickerDropdownProps extends ColorPickerProps {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
declare function FormikColorPickerDropdown(props: FormikColorPickerDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default FormikColorPickerDropdown;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFormikContext } from 'formik';
|
|
3
|
+
import lodashGet from 'lodash/get';
|
|
4
|
+
import { ColorPickerDropdown } from 'react-science/ui';
|
|
5
|
+
function FormikColorPickerDropdown(props) {
|
|
6
|
+
const { onChangeComplete = () => null, name, ...colorPickerProps } = props;
|
|
7
|
+
const { values, setFieldValue } = useFormikContext();
|
|
8
|
+
function colorChangeHandler(color) {
|
|
9
|
+
onChangeComplete(color);
|
|
10
|
+
void setFieldValue(name, color.hex);
|
|
11
|
+
}
|
|
12
|
+
return (_jsx(ColorPickerDropdown, { ...colorPickerProps, onChangeComplete: colorChangeHandler, color: { hex: lodashGet(values, name) } }));
|
|
13
|
+
}
|
|
14
|
+
export default FormikColorPickerDropdown;
|
|
@@ -2,6 +2,7 @@ import { useChartData } from '../context/ChartContext';
|
|
|
2
2
|
import { useActiveSpectrum } from './useActiveSpectrum';
|
|
3
3
|
export const defaultIntegralsViewState = {
|
|
4
4
|
scaleRatio: 1,
|
|
5
|
+
showIntegralsValues: true,
|
|
5
6
|
};
|
|
6
7
|
export function useActiveSpectrumIntegralsViewState() {
|
|
7
8
|
const activeSpectrum = useActiveSpectrum();
|
|
@@ -50,7 +50,7 @@ const containerStyle = css `
|
|
|
50
50
|
function DropZone(props) {
|
|
51
51
|
const { width, height } = useChartData();
|
|
52
52
|
const dispatch = useDispatch();
|
|
53
|
-
const { dispatch: dispatchPreferences, current } = usePreferences();
|
|
53
|
+
const { dispatch: dispatchPreferences, current: workspacePreferences } = usePreferences();
|
|
54
54
|
const preferences = usePreferences();
|
|
55
55
|
const isToolEnabled = useCheckToolsVisibility();
|
|
56
56
|
const openImportMetaInformationModal = useMetaInformationImportationModal();
|
|
@@ -70,10 +70,11 @@ function DropZone(props) {
|
|
|
70
70
|
parseMetaFileResult = await parseMetaFile(metaFile);
|
|
71
71
|
}
|
|
72
72
|
const { nmrLoaders: sourceSelector } = preferences.current;
|
|
73
|
+
const { onLoadProcessing, spectraColors } = workspacePreferences;
|
|
73
74
|
const { nmriumState, containsNmrium } = await readDropFiles(fileCollection, {
|
|
74
75
|
sourceSelector,
|
|
75
76
|
logger: logger.child({ context: 'nmr-processing' }),
|
|
76
|
-
onLoadProcessing
|
|
77
|
+
onLoadProcessing,
|
|
77
78
|
experimentalFeatures,
|
|
78
79
|
});
|
|
79
80
|
if (nmriumState?.settings) {
|
|
@@ -91,6 +92,7 @@ function DropZone(props) {
|
|
|
91
92
|
nmriumState,
|
|
92
93
|
containsNmrium,
|
|
93
94
|
parseMetaFileResult,
|
|
95
|
+
spectraColors,
|
|
94
96
|
},
|
|
95
97
|
});
|
|
96
98
|
}
|
|
@@ -26,6 +26,7 @@ import GeneralTabContent from './settings-tabs/GeneralTabContent';
|
|
|
26
26
|
import ImportationFiltersTabContent from './settings-tabs/ImportationFiltersTabContent';
|
|
27
27
|
import InfoBlockTabContent from './settings-tabs/InfoBlockTabContent';
|
|
28
28
|
import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabContent';
|
|
29
|
+
import SpectraColorsTabContent from './settings-tabs/SpectraColorsTabContent';
|
|
29
30
|
import ToolsTabContent from './settings-tabs/ToolsTabContent';
|
|
30
31
|
import { validation } from './settingsValidation';
|
|
31
32
|
const styles = css `
|
|
@@ -235,7 +236,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
235
236
|
marginLeft: '10px',
|
|
236
237
|
}, children: _jsx(FaRegCopy, {}) }), _jsx(Button.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspaceAction, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
|
|
237
238
|
marginLeft: '10px',
|
|
238
|
-
}, children: _jsx(FaPaste, {}) })] })] }) }), _jsx(Modal.Body, { children: _jsx("div", { css: styles, style: { height }, children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { title: "General", tabid: "general", children: _jsx("div", { className: "inner-content", children: _jsx(GeneralTabContent, {}) }) }), _jsx(Tab, { title: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { title: "Panels", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, {}) }) }), _jsx(Tab, { title: "Tools", tabid: "tools", children: _jsx("div", { className: "inner-content", children: _jsx(ToolsTabContent, {}) }) }), _jsx(Tab, { title: "Databases", tabid: "databases", children: _jsx("div", { className: "inner-content", children: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }) }), _jsx(Tab, { title: "Import filters", tabid: "importation-filters", children: _jsx("div", { className: "inner-content", children: _jsx(ImportationFiltersTabContent, {}) }) }), _jsx(Tab, { title: "Title Block", tabid: "title-block", children: _jsx("div", { className: "inner-content", children: _jsx(InfoBlockTabContent, {}) }) }), _jsx(Tab, { title: "On Load Processing", tabid: "on-load-processing", children: _jsx("div", { className: "inner-content", children: _jsx(OnLoadProcessingTabContent, {}) }) })] }) }) }) }), _jsx(Modal.Footer, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
|
|
239
|
+
}, children: _jsx(FaPaste, {}) })] })] }) }), _jsx(Modal.Body, { children: _jsx("div", { css: styles, style: { height }, children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { title: "General", tabid: "general", children: _jsx("div", { className: "inner-content", children: _jsx(GeneralTabContent, {}) }) }), _jsx(Tab, { title: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { title: "Panels", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, {}) }) }), _jsx(Tab, { title: "Tools", tabid: "tools", children: _jsx("div", { className: "inner-content", children: _jsx(ToolsTabContent, {}) }) }), _jsx(Tab, { title: "Databases", tabid: "databases", children: _jsx("div", { className: "inner-content", children: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }) }), _jsx(Tab, { title: "Import filters", tabid: "importation-filters", children: _jsx("div", { className: "inner-content", children: _jsx(ImportationFiltersTabContent, {}) }) }), _jsx(Tab, { title: "Title Block", tabid: "title-block", children: _jsx("div", { className: "inner-content", children: _jsx(InfoBlockTabContent, {}) }) }), _jsx(Tab, { title: "On Load Processing", tabid: "on-load-processing", children: _jsx("div", { className: "inner-content", children: _jsx(OnLoadProcessingTabContent, {}) }) }), _jsx(Tab, { title: "Spectra colors", tabid: "spectra-colors", children: _jsx("div", { className: "inner-content", children: _jsx(SpectraColorsTabContent, {}) }) })] }) }) }) }), _jsx(Modal.Footer, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
|
|
239
240
|
closeDialog?.();
|
|
240
241
|
} }), _jsx(Button.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), _jsx(SaveSettingsModal, {}), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
|
|
241
242
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormikContext } from 'formik';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { FaPlus, FaTimes } from 'react-icons/fa';
|
|
5
|
+
import { useChartData } from '../../../context/ChartContext';
|
|
6
|
+
import Button from '../../../elements/Button';
|
|
7
|
+
import { GroupPane } from '../../../elements/GroupPane';
|
|
8
|
+
import ReactTable from '../../../elements/ReactTable/ReactTable';
|
|
9
|
+
import FormikColorPickerDropdown from '../../../elements/formik/FormikColorPickerDropdown';
|
|
10
|
+
import FormikInput from '../../../elements/formik/FormikInput';
|
|
11
|
+
import { convertPathArrayToString } from '../../../utility/convertPathArrayToString';
|
|
12
|
+
import { getSpectraObjectPaths } from '../../../utility/getSpectraObjectPaths';
|
|
13
|
+
const styles = {
|
|
14
|
+
input: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
},
|
|
17
|
+
column: {
|
|
18
|
+
padding: '2px',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const colorInputStyle = {
|
|
22
|
+
padding: 0,
|
|
23
|
+
minWidth: '80px',
|
|
24
|
+
width: '80px',
|
|
25
|
+
...styles.column,
|
|
26
|
+
};
|
|
27
|
+
function getObjectKey(key) {
|
|
28
|
+
return `spectraColors.${key}`;
|
|
29
|
+
}
|
|
30
|
+
function SpectraColorsTabContent() {
|
|
31
|
+
const { values, setFieldValue } = useFormikContext();
|
|
32
|
+
const { data } = useChartData();
|
|
33
|
+
const { datalist, paths } = useMemo(() => getSpectraObjectPaths(data), [data]);
|
|
34
|
+
const { oneDimension = [], twoDimensions = [] } = values?.spectraColors || {};
|
|
35
|
+
const addHandler = useCallback((data, index, key) => {
|
|
36
|
+
let columns = [];
|
|
37
|
+
const emptyField = key === 'oneDimension'
|
|
38
|
+
? {
|
|
39
|
+
value: null,
|
|
40
|
+
jpath: ['info', 'experiment'],
|
|
41
|
+
color: 'red',
|
|
42
|
+
}
|
|
43
|
+
: {
|
|
44
|
+
value: null,
|
|
45
|
+
jpath: ['info', 'experiment'],
|
|
46
|
+
positiveColor: 'red',
|
|
47
|
+
negativeColor: 'blue',
|
|
48
|
+
};
|
|
49
|
+
if (data && Array.isArray(data)) {
|
|
50
|
+
columns = [...data.slice(0, index), emptyField, ...data.slice(index)];
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
columns.push(emptyField);
|
|
54
|
+
}
|
|
55
|
+
void setFieldValue(getObjectKey(key), columns);
|
|
56
|
+
}, [setFieldValue]);
|
|
57
|
+
const deleteHandler = useCallback((data, index, key) => {
|
|
58
|
+
const _fields = data.filter((_, columnIndex) => columnIndex !== index);
|
|
59
|
+
void setFieldValue(getObjectKey(key), _fields);
|
|
60
|
+
}, [setFieldValue]);
|
|
61
|
+
return (_jsxs("div", { children: [_jsx(SpectraColorsFields, { groupLabel: "One dimension", baseObjectPath: "oneDimension", data: oneDimension, datalist: datalist, paths: paths, onAdd: addHandler, onDelete: deleteHandler }), _jsx(SpectraColorsFields, { groupLabel: "Two dimensions", baseObjectPath: "twoDimensions", data: twoDimensions, datalist: datalist, paths: paths, onAdd: addHandler, onDelete: deleteHandler })] }));
|
|
62
|
+
}
|
|
63
|
+
function SpectraColorsFields(props) {
|
|
64
|
+
const { onAdd, onDelete, datalist, paths, data, baseObjectPath, groupLabel } = props;
|
|
65
|
+
const COLUMNS = useMemo(() => {
|
|
66
|
+
const objectPath = getObjectKey(baseObjectPath);
|
|
67
|
+
const baseColumns = [
|
|
68
|
+
{
|
|
69
|
+
Header: '#',
|
|
70
|
+
style: { width: '25px', ...styles.column },
|
|
71
|
+
accessor: (_, index) => index + 1,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
Header: 'Field',
|
|
75
|
+
style: { padding: 0, ...styles.column },
|
|
76
|
+
Cell: ({ row }) => {
|
|
77
|
+
return (_jsx(FormikInput, { name: `${objectPath}.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => {
|
|
78
|
+
return paths?.[key.toString().trim()] || key;
|
|
79
|
+
}, mapValue: (paths) => convertPathArrayToString(paths), datalist: datalist }));
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
Header: 'Value',
|
|
84
|
+
style: { padding: 0, ...styles.column },
|
|
85
|
+
Cell: ({ row }) => {
|
|
86
|
+
return (_jsx(FormikInput, { name: `${objectPath}.${row.index}.value`, style: { input: styles.input } }));
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
const operationsField = {
|
|
91
|
+
Header: '',
|
|
92
|
+
style: { width: '70px', ...styles.column },
|
|
93
|
+
id: 'operation-button',
|
|
94
|
+
Cell: ({ data, row }) => {
|
|
95
|
+
const record = row.original;
|
|
96
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => onAdd(data, row.index + 1, baseObjectPath), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => onDelete(data, row.index, baseObjectPath), children: _jsx(FaTimes, {}) }))] }));
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
if (baseObjectPath === 'oneDimension') {
|
|
100
|
+
const colorField = {
|
|
101
|
+
Header: 'Color',
|
|
102
|
+
style: colorInputStyle,
|
|
103
|
+
Cell: ({ row }) => (_jsx(FormikColorPickerDropdown, { name: `${objectPath}.${row.index}.color` })),
|
|
104
|
+
};
|
|
105
|
+
return [...baseColumns, colorField, operationsField];
|
|
106
|
+
}
|
|
107
|
+
const colorFields = [
|
|
108
|
+
{
|
|
109
|
+
Header: 'Positive color',
|
|
110
|
+
style: colorInputStyle,
|
|
111
|
+
Cell: ({ row }) => (_jsx(FormikColorPickerDropdown, { name: `${objectPath}.${row.index}.positiveColor` })),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
Header: 'Negative color',
|
|
115
|
+
style: colorInputStyle,
|
|
116
|
+
Cell: ({ row }) => (_jsx(FormikColorPickerDropdown, { name: `${objectPath}.${row.index}.negativeColor` })),
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
return [...baseColumns, ...colorFields, operationsField];
|
|
120
|
+
}, [baseObjectPath, datalist, onAdd, onDelete, paths]);
|
|
121
|
+
return (_jsx(GroupPane, { text: groupLabel, renderHeader: (text) => {
|
|
122
|
+
return (_jsx(FieldsBlockHeader, { text: text, onAdd: () => onAdd(data, 0, baseObjectPath) }));
|
|
123
|
+
}, children: _jsx(ReactTable, { style: {
|
|
124
|
+
'table, table td, table th': { border: 'none' },
|
|
125
|
+
'table thead': { borderBottom: '1px solid #f9f9f9' },
|
|
126
|
+
}, data: data, columns: COLUMNS, emptyDataRowText: "No Fields" }) }));
|
|
127
|
+
}
|
|
128
|
+
function FieldsBlockHeader({ onAdd, text }) {
|
|
129
|
+
return (_jsxs("div", { className: "section-header", style: { display: 'flex' }, children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsx(Button.Done, { fill: "outline", size: "xSmall", onClick: onAdd, children: "Add custom color" })] }));
|
|
130
|
+
}
|
|
131
|
+
export default SpectraColorsTabContent;
|
|
@@ -49,7 +49,17 @@ const databasesValidation = object().shape({
|
|
|
49
49
|
const infoBlockValidation = object({
|
|
50
50
|
fields: array().of(object({
|
|
51
51
|
label: string().required(),
|
|
52
|
-
jpath: array().of(string()).min(1),
|
|
52
|
+
jpath: array().of(string()).required().min(1),
|
|
53
|
+
})),
|
|
54
|
+
});
|
|
55
|
+
const spectraColorsSchemaValidation = object({
|
|
56
|
+
oneDimension: array().of(object({
|
|
57
|
+
value: string().required(),
|
|
58
|
+
jpath: array().of(string()).required().min(1),
|
|
59
|
+
})),
|
|
60
|
+
twoDimensions: array().of(object({
|
|
61
|
+
value: string().required(),
|
|
62
|
+
jpath: array().of(string()).required().min(1),
|
|
53
63
|
})),
|
|
54
64
|
});
|
|
55
65
|
const generalValidation = object({
|
|
@@ -60,4 +70,5 @@ export const validation = lazy((obj) => object().shape({
|
|
|
60
70
|
databases: databasesValidation,
|
|
61
71
|
infoBlock: infoBlockValidation,
|
|
62
72
|
general: generalValidation,
|
|
73
|
+
spectraColors: spectraColorsSchemaValidation,
|
|
63
74
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { SvgNmrSum } from 'cheminfo-font';
|
|
4
|
+
import { SvgNmrIntegrate, SvgNmrSum } from 'cheminfo-font';
|
|
5
5
|
import lodashGet from 'lodash/get';
|
|
6
6
|
import { useCallback, useMemo, useState, useRef, memo } from 'react';
|
|
7
7
|
import { ImLink } from 'react-icons/im';
|
|
@@ -17,6 +17,7 @@ import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHe
|
|
|
17
17
|
import PreferencesHeader from '../header/PreferencesHeader';
|
|
18
18
|
import IntegralTable from './IntegralTable';
|
|
19
19
|
import IntegralsPreferences from './IntegralsPreferences';
|
|
20
|
+
import { useActiveSpectrumIntegralsViewState } from '../../hooks/useActiveSpectrumIntegralsViewState';
|
|
20
21
|
const style = css `
|
|
21
22
|
.sum-button {
|
|
22
23
|
width: 22px;
|
|
@@ -25,13 +26,24 @@ const style = css `
|
|
|
25
26
|
align-items: center;
|
|
26
27
|
justify-content: center;
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
button {
|
|
31
|
+
margin-right: 2px;
|
|
32
|
+
}
|
|
28
33
|
`;
|
|
29
34
|
function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
30
35
|
const [filterIsActive, setFilterIsActive] = useState(false);
|
|
31
36
|
const dispatch = useDispatch();
|
|
37
|
+
const { showIntegralsValues } = useActiveSpectrumIntegralsViewState();
|
|
32
38
|
const modal = useModal();
|
|
33
39
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
34
40
|
const settingRef = useRef();
|
|
41
|
+
function handleShowIntegralsValues() {
|
|
42
|
+
dispatch({
|
|
43
|
+
type: 'TOGGLE_INTEGRALS_VIEW_PROPERTY',
|
|
44
|
+
payload: { key: 'showIntegralsValues' },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
35
47
|
const yesHandler = useCallback(() => {
|
|
36
48
|
dispatch({ type: 'DELETE_INTEGRAL', payload: {} });
|
|
37
49
|
}, [dispatch]);
|
|
@@ -93,7 +105,9 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
93
105
|
`,
|
|
94
106
|
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredData?.length), onDelete: handleDeleteAll, deleteToolTip: "Delete All Integrals", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all integrals' : 'Hide integrals out of view', showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: currentSum
|
|
95
107
|
? `Change integration sum (${currentSum.toFixed(2)})`
|
|
96
|
-
: 'Change integration sum', popupPlacement: "right", children: _jsx(ChangeSumModal, { onSave: changeIntegralSumHandler, sumType: "integrals", currentSum: currentSum, sumOptions: integrals?.options, renderButton: (onClick) => (_jsx("button", { className: "sum-button", type: "button", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration values", popupPlacement: "right", onClick: toggleConstantSumHandler, value: integrals?.options?.isSumConstant || false, children: _jsx(ImLink, {}) })
|
|
108
|
+
: 'Change integration sum', popupPlacement: "right", children: _jsx(ChangeSumModal, { onSave: changeIntegralSumHandler, sumType: "integrals", currentSum: currentSum, sumOptions: integrals?.options, renderButton: (onClick) => (_jsx("button", { className: "sum-button", type: "button", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration values", popupPlacement: "right", onClick: toggleConstantSumHandler, value: integrals?.options?.isSumConstant || false, children: _jsx(ImLink, {}) }), _jsx(ActiveButton, { popupTitle: showIntegralsValues
|
|
109
|
+
? 'Hide integrals values'
|
|
110
|
+
: 'Show integrals values', popupPlacement: "right", onClick: handleShowIntegralsValues, value: showIntegralsValues, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(IntegralTable, { data: filteredData, info: info, activeTab: activeTab })) : (_jsx(IntegralsPreferences, { ref: settingRef })) })] }));
|
|
97
111
|
}
|
|
98
112
|
const MemoizedIntegralPanel = memo(IntegralPanelInner);
|
|
99
113
|
const emptyData = { integrals: {}, info: {} };
|
|
@@ -3,7 +3,7 @@ import { Formik } from 'formik';
|
|
|
3
3
|
import { useCallback, useImperativeHandle, useRef, memo, forwardRef, useMemo, } from 'react';
|
|
4
4
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
5
5
|
import Label from '../../elements/Label';
|
|
6
|
-
import
|
|
6
|
+
import FormikColorPickerDropdown from '../../elements/formik/FormikColorPickerDropdown';
|
|
7
7
|
import { formatFieldLabelStyle } from '../../elements/formik/FormikColumnFormatField';
|
|
8
8
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
9
9
|
import useNucleus from '../../hooks/useNucleus';
|
|
@@ -72,7 +72,7 @@ function IntegralsPreferences(props, ref) {
|
|
|
72
72
|
formRef.current.submitForm();
|
|
73
73
|
},
|
|
74
74
|
}));
|
|
75
|
-
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: preferencesByNuclei, onSubmit: saveHandler, innerRef: formRef, children: _jsx(_Fragment, { children: nuclei?.map((n) => (_jsx(NucleusPreferences, { nucleus: n, fields: formatFields, renderTop: () => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsxs("div", { style: { display: 'flex', padding: '2px 0' }, children: [_jsx("div", { style: { width: '23px' } }), _jsx(
|
|
75
|
+
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: preferencesByNuclei, onSubmit: saveHandler, innerRef: formRef, children: _jsx(_Fragment, { children: nuclei?.map((n) => (_jsx(NucleusPreferences, { nucleus: n, fields: formatFields, renderTop: () => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsxs("div", { style: { display: 'flex', padding: '2px 0' }, children: [_jsx("div", { style: { width: '23px' } }), _jsx(FormikColorPickerDropdown, { name: `nuclei.${n}.color` })] }) }), _jsx(Label, { title: "stroke width :", style: formatFieldLabelStyle, children: _jsxs("div", { style: { display: 'flex', padding: '2px 0' }, children: [_jsx("div", { style: { width: '23px' } }), _jsx(FormikInput, { name: `nuclei.${n}.strokeWidth`, type: "number", style: {
|
|
76
76
|
input: {
|
|
77
77
|
textAlign: 'center',
|
|
78
78
|
padding: '2px',
|
|
@@ -45,7 +45,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
45
45
|
const assignmentData = useAssignmentData();
|
|
46
46
|
const currentSum = lodashGet(ranges, 'options.sum', null);
|
|
47
47
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
48
|
-
const { showMultiplicityTrees, showJGraph, showIntegrals, showPeaks, displayingMode, } = useActiveSpectrumRangesViewState();
|
|
48
|
+
const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, } = useActiveSpectrumRangesViewState();
|
|
49
49
|
function changeRangesSumHandler(options) {
|
|
50
50
|
dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
|
|
51
51
|
modal.close();
|
|
@@ -82,6 +82,12 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
82
82
|
payload: { key: 'showMultiplicityTrees' },
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
+
function handleShowIntegralsValues() {
|
|
86
|
+
dispatch({
|
|
87
|
+
type: 'TOGGLE_RANGES_VIEW_PROPERTY',
|
|
88
|
+
payload: { key: 'showIntegralsValues' },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
85
91
|
function handleShowIntegrals() {
|
|
86
92
|
dispatch({
|
|
87
93
|
type: 'TOGGLE_RANGES_VIEW_PROPERTY',
|
|
@@ -127,6 +133,8 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
127
133
|
? `Change ranges sum (${currentSum.toFixed(2)})`
|
|
128
134
|
: 'Change ranges sum', popupPlacement: "right", className: "btn icon", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }), _jsx(Button, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
|
|
129
135
|
? 'Hide multiplicity trees in spectrum'
|
|
130
|
-
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, {
|
|
136
|
+
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegralsValues
|
|
137
|
+
? 'Hide integrals values'
|
|
138
|
+
: 'Show integrals values', popupPlacement: "right", onClick: handleShowIntegralsValues, value: showIntegralsValues, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration sum", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: _jsx(ImLink, {}) }), _jsx(PeaksToggleActions, { disbale: !hasRanges, showPeaks: showPeaks, onShowToggle: () => toggleViewProperty('showPeaks'), displayingMode: displayingMode, onDisplayingModeToggle: toggleDisplayingMode })] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
|
|
131
139
|
}
|
|
132
140
|
export default RangesHeader;
|
|
@@ -3,7 +3,7 @@ import { Formik } from 'formik';
|
|
|
3
3
|
import { useEffect, useCallback, useImperativeHandle, useRef, forwardRef, } from 'react';
|
|
4
4
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
5
5
|
import Label from '../../elements/Label';
|
|
6
|
-
import
|
|
6
|
+
import FormikColorPickerDropdown from '../../elements/formik/FormikColorPickerDropdown';
|
|
7
7
|
import FormikColumnFormatField, { formatFieldInputStyle, formatFieldLabelStyle, } from '../../elements/formik/FormikColumnFormatField';
|
|
8
8
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
9
9
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
@@ -27,6 +27,6 @@ function DatabasePreferences(props, ref) {
|
|
|
27
27
|
formRef.current.submitForm();
|
|
28
28
|
},
|
|
29
29
|
}));
|
|
30
|
-
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: {}, onSubmit: saveHandler, innerRef: formRef, children: _jsxs(_Fragment, { children: [_jsxs(PreferencesGroup, { children: [_jsx(FormikColumnFormatField, { label: "Preview jcamp", checkControllerName: "previewJcamp", hideFormatField: true }), _jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsx(
|
|
30
|
+
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: {}, onSubmit: saveHandler, innerRef: formRef, children: _jsxs(_Fragment, { children: [_jsxs(PreferencesGroup, { children: [_jsx(FormikColumnFormatField, { label: "Preview jcamp", checkControllerName: "previewJcamp", hideFormatField: true }), _jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsx(FormikColorPickerDropdown, { name: "color" }) }), _jsx(Label, { title: "Margin bottom (px) :", style: formatFieldLabelStyle, children: _jsx(FormikInput, { name: "marginBottom", type: "number", style: formatFieldInputStyle }) })] }), _jsxs(PreferencesGroup, { header: "Table Preferences", children: [_jsx(FormikColumnFormatField, { label: "Structure", checkControllerName: "showSmiles", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Solvent", checkControllerName: "showSolvent", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Names", checkControllerName: "showNames", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Range", checkControllerName: "range.show", formatControllerName: "range.format" }), _jsx(FormikColumnFormatField, { label: "\u03B4 (ppm)", checkControllerName: "delta.show", formatControllerName: "delta.format" }), _jsx(FormikColumnFormatField, { label: "Assignment", checkControllerName: "showAssignment", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "J (Hz)", checkControllerName: "coupling.show", formatControllerName: "coupling.format" }), _jsx(FormikColumnFormatField, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Save as nmrium", checkControllerName: "allowSaveAsNMRium", hideFormatField: true })] })] }) }) }));
|
|
31
31
|
}
|
|
32
32
|
export default forwardRef(DatabasePreferences);
|
|
@@ -33,7 +33,8 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
33
33
|
const modal = useModal();
|
|
34
34
|
const alert = useAlert();
|
|
35
35
|
const selectedFilterIndex = useRef();
|
|
36
|
-
const handelFilterCheck = useCallback((id,
|
|
36
|
+
const handelFilterCheck = useCallback((id, event) => {
|
|
37
|
+
const { checked: enabled } = event.target;
|
|
37
38
|
void (async () => {
|
|
38
39
|
const hideLoading = await alert.showLoading(`${enabled ? 'Enable' : 'Disable'} filter in progress`);
|
|
39
40
|
setTimeout(() => {
|
|
@@ -109,7 +110,7 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
109
110
|
style: { width: '30px' },
|
|
110
111
|
Cell: ({ row }) => {
|
|
111
112
|
const { flag, id } = row.original;
|
|
112
|
-
return (_jsx(ColumnWrapper, { children: _jsx(Checkbox, { onChange: (
|
|
113
|
+
return (_jsx(ColumnWrapper, { children: _jsx(Checkbox, { onChange: (event) => handelFilterCheck(id, event), checked: flag }) }));
|
|
113
114
|
},
|
|
114
115
|
},
|
|
115
116
|
{
|
|
@@ -173,6 +173,8 @@ function innerSpectrumReducer(draft, action) {
|
|
|
173
173
|
return IntegralsActions.handleChangeIntegralsRelativeValue(draft, action);
|
|
174
174
|
case 'CUT_INTEGRAL':
|
|
175
175
|
return IntegralsActions.handleCutIntegral(draft, action);
|
|
176
|
+
case 'TOGGLE_INTEGRALS_VIEW_PROPERTY':
|
|
177
|
+
return IntegralsActions.handleToggleIntegralsViewProperty(draft, action);
|
|
176
178
|
case 'SET_X_DOMAIN':
|
|
177
179
|
return DomainActions.handleSetXDomain(draft, action);
|
|
178
180
|
case 'SET_Y_DOMAIN':
|
|
@@ -13,7 +13,7 @@ function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
|
13
13
|
},
|
|
14
14
|
display: {
|
|
15
15
|
...spectrum.display,
|
|
16
|
-
...get1DColor(spectrum.display, draft.usedColors),
|
|
16
|
+
...get1DColor(spectrum.display, { usedColors: draft.usedColors }),
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
draft.data.push(spectrum);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { IntegralsViewState } from 'nmr-load-save';
|
|
2
3
|
import { Integral } from 'nmr-processing';
|
|
3
4
|
import { SetSumOptions } from '../../../data/data1d/Spectrum1D/SumManager';
|
|
4
5
|
import { State } from '../Reducer';
|
|
5
6
|
import { ActionType } from '../types/ActionType';
|
|
7
|
+
import { FilterType } from '../../utility/filterType';
|
|
6
8
|
type ChangeIntegralSumAction = ActionType<'CHANGE_INTEGRAL_SUM', {
|
|
7
9
|
options: SetSumOptions;
|
|
8
10
|
}>;
|
|
@@ -23,7 +25,10 @@ type ChangeIntegralRelativeValueAction = ActionType<'CHANGE_INTEGRAL_RELATIVE',
|
|
|
23
25
|
type CutIntegralAction = ActionType<'CUT_INTEGRAL', {
|
|
24
26
|
cutValue: number;
|
|
25
27
|
}>;
|
|
26
|
-
|
|
28
|
+
type ToggleIntegralsViewAction = ActionType<'TOGGLE_INTEGRALS_VIEW_PROPERTY', {
|
|
29
|
+
key: keyof FilterType<IntegralsViewState, boolean>;
|
|
30
|
+
}>;
|
|
31
|
+
export type IntegralsActions = ChangeIntegralSumAction | AddIntegralAction | DeleteIntegralAction | ChangeIntegralAction | ChangeIntegralRelativeValueAction | CutIntegralAction | ToggleIntegralsViewAction | ActionType<'CHANGE_INTEGRALS_SUM_FLAG'>;
|
|
27
32
|
declare function handleChangeIntegralSum(draft: Draft<State>, action: ChangeIntegralSumAction): void;
|
|
28
33
|
declare function handleAddIntegral(draft: Draft<State>, action: AddIntegralAction): void;
|
|
29
34
|
declare function handleDeleteIntegral(draft: Draft<State>, action: DeleteIntegralAction): void;
|
|
@@ -31,4 +36,5 @@ declare function handleChangeIntegral(draft: Draft<State>, action: ChangeIntegra
|
|
|
31
36
|
declare function handleChangeIntegralsRelativeValue(draft: Draft<State>, action: ChangeIntegralRelativeValueAction): void;
|
|
32
37
|
declare function handleChangeIntegralsSumFlag(draft: any): void;
|
|
33
38
|
declare function handleCutIntegral(draft: Draft<State>, action: CutIntegralAction): void;
|
|
34
|
-
|
|
39
|
+
declare function handleToggleIntegralsViewProperty(draft: Draft<State>, action: ToggleIntegralsViewAction): void;
|
|
40
|
+
export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, handleToggleIntegralsViewProperty, };
|
|
@@ -6,6 +6,7 @@ import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/
|
|
|
6
6
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
7
7
|
import getRange from '../helper/getRange';
|
|
8
8
|
import { getSpectrum } from '../helper/getSpectrum';
|
|
9
|
+
import { setIntegralsViewProperty } from '../helper/setIntegralsViewProperty';
|
|
9
10
|
function handleChangeIntegralSum(draft, action) {
|
|
10
11
|
const { options } = action.payload;
|
|
11
12
|
const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
@@ -121,4 +122,12 @@ function handleCutIntegral(draft, action) {
|
|
|
121
122
|
}
|
|
122
123
|
updateIntegralsRelativeValues(spectrum);
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
+
function toggleIntegralsViewProperty(draft, key) {
|
|
126
|
+
setIntegralsViewProperty(draft, key, (flag) => !flag);
|
|
127
|
+
}
|
|
128
|
+
//action
|
|
129
|
+
function handleToggleIntegralsViewProperty(draft, action) {
|
|
130
|
+
const { key } = action.payload;
|
|
131
|
+
toggleIntegralsViewProperty(draft, key);
|
|
132
|
+
}
|
|
133
|
+
export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, handleToggleIntegralsViewProperty, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
-
import { Spectrum, NmriumState } from 'nmr-load-save';
|
|
2
|
+
import { Spectrum, NmriumState, SpectraColors } from 'nmr-load-save';
|
|
3
3
|
import { ParseResult } from 'papaparse';
|
|
4
4
|
import { StateMoleculeExtended } from '../../../data/molecules/Molecule';
|
|
5
5
|
import { UsedColors } from '../../../types/UsedColors';
|
|
@@ -13,6 +13,7 @@ interface InputProps extends InitiateProps {
|
|
|
13
13
|
usedColors?: UsedColors;
|
|
14
14
|
parseMetaFileResult?: ParseResult<any> | null;
|
|
15
15
|
resetSourceObject?: boolean;
|
|
16
|
+
spectraColors?: SpectraColors;
|
|
16
17
|
}
|
|
17
18
|
type SetIsLoadingAction = ActionType<'SET_LOADING_FLAG', {
|
|
18
19
|
isLoading: boolean;
|
|
@@ -23,6 +24,7 @@ export type LoadActions = SetIsLoadingAction | LoadDropFilesAction | InitiateAct
|
|
|
23
24
|
declare function initSpectra(inputSpectra: Spectrum[], options: {
|
|
24
25
|
usedColors: UsedColors;
|
|
25
26
|
molecules: StateMoleculeExtended[];
|
|
27
|
+
spectraColors: SpectraColors;
|
|
26
28
|
}): any;
|
|
27
29
|
declare function handleSetIsLoading(draft: Draft<State>, action: SetIsLoadingAction): void;
|
|
28
30
|
declare function handleInitiate(draft: Draft<State>, action: InitiateAction): State | undefined;
|
|
@@ -42,7 +42,7 @@ function setCorrelation(draft, correlations) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function setData(draft, input) {
|
|
45
|
-
const { nmriumState: { data, view }, parseMetaFileResult = null, } = input || {
|
|
45
|
+
const { nmriumState: { data, view }, parseMetaFileResult = null, spectraColors = { oneDimension: [], twoDimensions: [] }, } = input || {
|
|
46
46
|
nmriumState: { data: { spectra: [], molecules: [], correlations: {} } },
|
|
47
47
|
multipleAnalysis: {},
|
|
48
48
|
};
|
|
@@ -62,6 +62,7 @@ function setData(draft, input) {
|
|
|
62
62
|
draft.data = draft.data.concat(initSpectra(spectra, {
|
|
63
63
|
usedColors: draft.usedColors,
|
|
64
64
|
molecules: draft.molecules,
|
|
65
|
+
spectraColors,
|
|
65
66
|
}));
|
|
66
67
|
setCorrelation(draft, correlations);
|
|
67
68
|
if (parseMetaFileResult) {
|
|
@@ -75,14 +76,18 @@ function setData(draft, input) {
|
|
|
75
76
|
}
|
|
76
77
|
function initSpectra(inputSpectra, options) {
|
|
77
78
|
const spectra = [];
|
|
78
|
-
const { usedColors, molecules } = options;
|
|
79
|
+
const { usedColors, molecules, spectraColors } = options;
|
|
79
80
|
for (const spectrum of inputSpectra) {
|
|
80
81
|
const { info } = spectrum;
|
|
81
82
|
if (info.dimension === 1) {
|
|
82
|
-
spectra.push(initiateDatum1D(spectrum, {
|
|
83
|
+
spectra.push(initiateDatum1D(spectrum, {
|
|
84
|
+
usedColors,
|
|
85
|
+
molecules,
|
|
86
|
+
colors: spectraColors.oneDimension,
|
|
87
|
+
}));
|
|
83
88
|
}
|
|
84
89
|
else if (info.dimension === 2) {
|
|
85
|
-
spectra.push(initiateDatum2D({ ...spectrum }, { usedColors }));
|
|
90
|
+
spectra.push(initiateDatum2D({ ...spectrum }, { usedColors, colors: spectraColors.twoDimensions }));
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
return spectra;
|
|
@@ -342,13 +342,19 @@ function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
|
|
|
342
342
|
}
|
|
343
343
|
else {
|
|
344
344
|
//reset spectra colors
|
|
345
|
-
const
|
|
345
|
+
const usedColors = { '1d': [], '2d': [] };
|
|
346
346
|
for (const spectrum of spectra) {
|
|
347
347
|
if (isSpectrum1D(spectrum)) {
|
|
348
|
-
spectrum.display.color = get1DColor(spectrum,
|
|
348
|
+
spectrum.display.color = get1DColor(spectrum, {
|
|
349
|
+
usedColors,
|
|
350
|
+
regenerate: true,
|
|
351
|
+
}).color;
|
|
349
352
|
}
|
|
350
353
|
else {
|
|
351
|
-
const { positiveColor, negativeColor } = get2DColor(spectrum,
|
|
354
|
+
const { positiveColor, negativeColor } = get2DColor(spectrum, {
|
|
355
|
+
usedColors,
|
|
356
|
+
regenerate: true,
|
|
357
|
+
});
|
|
352
358
|
spectrum.display.positiveColor = positiveColor;
|
|
353
359
|
spectrum.display.negativeColor = negativeColor;
|
|
354
360
|
}
|
|
@@ -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',
|
|
@@ -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
|
+
}
|
|
@@ -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']) {
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import { Spectrum2D } from 'nmr-load-save';
|
|
2
|
-
|
|
1
|
+
import { Spectrum2D, SpectrumTwoDimensionsColor } from 'nmr-load-save';
|
|
2
|
+
import { UsedColors } from '../../../types/UsedColors';
|
|
3
|
+
export interface InitiateDatum2DOptions {
|
|
4
|
+
usedColors?: UsedColors;
|
|
5
|
+
colors?: SpectrumTwoDimensionsColor[];
|
|
6
|
+
}
|
|
7
|
+
export declare function initiateDatum2D(spectrum: any, options?: InitiateDatum2DOptions): Spectrum2D;
|
|
@@ -5,7 +5,8 @@ import { DEFAULT_CONTOURS_OPTIONS } from './contours';
|
|
|
5
5
|
import { get2DColor } from './get2DColor';
|
|
6
6
|
import { initiateZones } from './zones/initiateZones';
|
|
7
7
|
const defaultMinMax = { z: [], minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
|
8
|
-
export function initiateDatum2D(spectrum,
|
|
8
|
+
export function initiateDatum2D(spectrum, options = {}) {
|
|
9
|
+
const { usedColors, colors } = options;
|
|
9
10
|
const datum = { ...spectrum };
|
|
10
11
|
datum.id = spectrum.id || v4();
|
|
11
12
|
datum.display = {
|
|
@@ -15,7 +16,7 @@ export function initiateDatum2D(spectrum, usedColors = {}) {
|
|
|
15
16
|
contourOptions: DEFAULT_CONTOURS_OPTIONS,
|
|
16
17
|
dimension: 2,
|
|
17
18
|
...spectrum.display,
|
|
18
|
-
...get2DColor(spectrum, usedColors),
|
|
19
|
+
...get2DColor(spectrum, { usedColors, colors }),
|
|
19
20
|
};
|
|
20
21
|
datum.info = {
|
|
21
22
|
nucleus: ['1H', '1H'],
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Color2D, Spectrum1D, Spectrum2D, SpectrumOneDimensionColor, SpectrumTwoDimensionsColor } from 'nmr-load-save';
|
|
2
|
+
type ReturnColor<ColorType> = ColorType extends SpectrumOneDimensionColor ? string : Color2D;
|
|
3
|
+
export declare function getCustomColor<SpectrumType extends Spectrum1D | Spectrum2D, ColorType extends SpectrumOneDimensionColor | SpectrumTwoDimensionsColor>(spectrum: SpectrumType, colors?: ColorType[]): ReturnColor<ColorType> | null;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import lodashGet from 'lodash/get';
|
|
2
|
+
function getValue(spectrum, jpath) {
|
|
3
|
+
const value = lodashGet(spectrum, jpath);
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
if (['number', 'boolean'].includes(typeof value)) {
|
|
8
|
+
return String(value);
|
|
9
|
+
}
|
|
10
|
+
if (value) {
|
|
11
|
+
return JSON.stringify(value);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function isInstanceOfOneDimensionColor(item) {
|
|
16
|
+
return 'color' in item;
|
|
17
|
+
}
|
|
18
|
+
export function getCustomColor(spectrum, colors) {
|
|
19
|
+
if (!colors || colors.length === 0)
|
|
20
|
+
return null;
|
|
21
|
+
let color = null;
|
|
22
|
+
for (const item of colors) {
|
|
23
|
+
const value = getValue(spectrum, item.jpath);
|
|
24
|
+
if (value &&
|
|
25
|
+
item.value &&
|
|
26
|
+
value.toLocaleLowerCase().includes(item.value.toLocaleLowerCase())) {
|
|
27
|
+
if (isInstanceOfOneDimensionColor(item)) {
|
|
28
|
+
color = item.color;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { negativeColor, positiveColor } = item;
|
|
32
|
+
color = { negativeColor, positiveColor };
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return color;
|
|
38
|
+
}
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.47.0' };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.47.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "lib/component/main/index.js",
|
|
7
7
|
"types": "lib/component/main/index.d.ts",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"ml-stat": "^1.3.3",
|
|
87
87
|
"multiplet-analysis": "^2.1.2",
|
|
88
88
|
"nmr-correlation": "^2.3.3",
|
|
89
|
-
"nmr-load-save": "^0.
|
|
89
|
+
"nmr-load-save": "^0.24.0",
|
|
90
90
|
"nmr-processing": "^11.7.0",
|
|
91
91
|
"nmredata": "^0.9.9",
|
|
92
92
|
"numeral": "^2.0.6",
|
|
@@ -148,4 +148,4 @@
|
|
|
148
148
|
"vite": "^5.0.10",
|
|
149
149
|
"vitest": "^1.0.4"
|
|
150
150
|
}
|
|
151
|
-
}
|
|
151
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ColorInputProps } from '../ColorInput';
|
|
3
|
-
interface FormikColorPickerProps extends ColorInputProps {
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
declare function FormikColorPicker(props: FormikColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
declare const _default: import("react").MemoExoticComponent<typeof FormikColorPicker>;
|
|
8
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useFormikContext } from 'formik';
|
|
3
|
-
import lodashGet from 'lodash/get';
|
|
4
|
-
import { useCallback, memo } from 'react';
|
|
5
|
-
import ColorInput from '../ColorInput';
|
|
6
|
-
function FormikColorPicker(props) {
|
|
7
|
-
const { onColorChange = () => null, name, ...colorPickerProps } = props;
|
|
8
|
-
const { values, setFieldValue } = useFormikContext();
|
|
9
|
-
const colorChangeHandler = useCallback((color) => {
|
|
10
|
-
onColorChange(color);
|
|
11
|
-
void setFieldValue(name, color.hex);
|
|
12
|
-
}, [name, onColorChange, setFieldValue]);
|
|
13
|
-
return (_jsx(ColorInput, { ...colorPickerProps, name: name, onColorChange: colorChangeHandler, value: lodashGet(values, name) }));
|
|
14
|
-
}
|
|
15
|
-
export default memo(FormikColorPicker);
|