nmrium 0.30.0 → 0.31.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.
Files changed (230) hide show
  1. package/lib/component/1d/ApodizationLine.js +3 -1
  2. package/lib/component/1d/FooterBanner.js +3 -1
  3. package/lib/component/1d/IntegralsSeries.js +3 -1
  4. package/lib/component/1d/LinesSeries.js +3 -1
  5. package/lib/component/1d/SpectraTracker.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +3 -1
  7. package/lib/component/1d/jCouplingGraph/JGraph.js +5 -1
  8. package/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  9. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  10. package/lib/component/1d/peaks/PeakAnnotations.js +3 -1
  11. package/lib/component/1d/peaks/PeaksShapes.js +4 -2
  12. package/lib/component/1d/peaks/usePeakShapesPath.js +7 -3
  13. package/lib/component/1d/ranges/Ranges.js +8 -2
  14. package/lib/component/1d/tool/PeakPointer.js +3 -1
  15. package/lib/component/1d/tool/XLabelPointer.js +3 -1
  16. package/lib/component/2d/Contours.js +3 -1
  17. package/lib/component/2d/FooterBanner.js +3 -1
  18. package/lib/component/2d/Viewer2D.js +4 -4
  19. package/lib/component/2d/XAxis.js +2 -2
  20. package/lib/component/2d/YAxis.js +2 -2
  21. package/lib/component/2d/tools/XYLabelPointer.js +3 -1
  22. package/lib/component/2d/tools/slicing/SlicingView.js +3 -1
  23. package/lib/component/2d/zones/IndicationLines.js +1 -1
  24. package/lib/component/2d/zones/Zones.js +14 -19
  25. package/lib/component/NMRium.d.ts +2 -0
  26. package/lib/component/NMRium.js +14 -3
  27. package/lib/component/elements/popup/Modal/Provider.d.ts +3 -3
  28. package/lib/component/elements/popup/Modal/Provider.js +8 -11
  29. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -1
  30. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +2 -2
  31. package/lib/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  32. package/lib/component/hooks/useExport.d.ts +0 -1
  33. package/lib/component/hooks/useExport.js +1 -17
  34. package/lib/component/hooks/useIntegralPath.js +5 -2
  35. package/lib/component/hooks/useNucleus.js +4 -4
  36. package/lib/component/hooks/useSpectraPerNucleus.js +1 -1
  37. package/lib/component/hooks/useSpectrum.js +3 -1
  38. package/lib/component/loader/DropZone.js +7 -147
  39. package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
  40. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  41. package/lib/component/modal/setting/ToolsTabContent.js +4 -0
  42. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  43. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  44. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  45. package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  46. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
  47. package/lib/component/panels/RangesPanel/RangesHeader.js +10 -9
  48. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -3
  49. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  50. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  51. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  52. package/lib/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  53. package/lib/component/panels/ZonesPanel/ZonesPanel.js +19 -10
  54. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  55. package/lib/component/reducer/IgnoreActions.js +1 -0
  56. package/lib/component/reducer/Reducer.d.ts +108 -49
  57. package/lib/component/reducer/Reducer.js +45 -41
  58. package/lib/component/reducer/actions/DomainActions.d.ts +1 -1
  59. package/lib/component/reducer/actions/DomainActions.js +11 -9
  60. package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
  61. package/lib/component/reducer/actions/FiltersActions.js +218 -232
  62. package/lib/component/reducer/actions/IntegralsActions.js +13 -8
  63. package/lib/component/reducer/actions/LoadActions.d.ts +2 -5
  64. package/lib/component/reducer/actions/LoadActions.js +19 -34
  65. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -1
  66. package/lib/component/reducer/actions/MoleculeActions.js +22 -6
  67. package/lib/component/reducer/actions/PeaksActions.js +18 -12
  68. package/lib/component/reducer/actions/PreferencesActions.js +8 -10
  69. package/lib/component/reducer/actions/RangesActions.d.ts +3 -3
  70. package/lib/component/reducer/actions/RangesActions.js +85 -27
  71. package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  72. package/lib/component/reducer/actions/SpectrumsActions.js +13 -10
  73. package/lib/component/reducer/actions/ToolsActions.js +38 -23
  74. package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
  75. package/lib/component/reducer/actions/ZonesActions.js +68 -17
  76. package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
  77. package/lib/component/reducer/helper/getActiveSpectrumOrFail.d.ts +3 -0
  78. package/lib/component/reducer/helper/getActiveSpectrumOrFail.js +6 -0
  79. package/lib/component/reducer/helper/getSpectrum.js +3 -2
  80. package/lib/component/reducer/helper/getStrongestPeak.js +2 -1
  81. package/lib/component/reducer/types/Types.d.ts +5 -0
  82. package/lib/component/reducer/types/Types.js +5 -0
  83. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +6 -0
  84. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  85. package/lib/component/tool/FloatMoleculeStructures/index.js +14 -8
  86. package/lib/component/toolbar/BasicToolBar.js +4 -6
  87. package/lib/component/toolbar/FunctionToolBar.js +3 -1
  88. package/lib/component/utility/assert.d.ts +1 -0
  89. package/lib/component/utility/assert.js +5 -0
  90. package/lib/component/workspaces/exercise.js +6 -0
  91. package/lib/data/SpectraManager.d.ts +0 -4
  92. package/lib/data/SpectraManager.js +2 -87
  93. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  94. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  95. package/lib/data/data1d/filter1d/fft.js +11 -0
  96. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.d.ts +2 -0
  97. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
  98. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
  99. package/lib/data/molecules/Molecule.d.ts +5 -0
  100. package/lib/versionInfo.js +1 -1
  101. package/lib-cjs/component/1d/ApodizationLine.js +3 -1
  102. package/lib-cjs/component/1d/FooterBanner.js +3 -1
  103. package/lib-cjs/component/1d/IntegralsSeries.js +3 -1
  104. package/lib-cjs/component/1d/LinesSeries.js +3 -1
  105. package/lib-cjs/component/1d/SpectraTracker.js +1 -1
  106. package/lib-cjs/component/1d/Viewer1D.js +3 -1
  107. package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +5 -1
  108. package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  109. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  110. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +3 -1
  111. package/lib-cjs/component/1d/peaks/PeaksShapes.js +4 -2
  112. package/lib-cjs/component/1d/peaks/usePeakShapesPath.js +7 -3
  113. package/lib-cjs/component/1d/ranges/Ranges.js +7 -1
  114. package/lib-cjs/component/1d/tool/PeakPointer.js +3 -1
  115. package/lib-cjs/component/1d/tool/XLabelPointer.js +3 -1
  116. package/lib-cjs/component/2d/Contours.js +3 -1
  117. package/lib-cjs/component/2d/FooterBanner.js +3 -1
  118. package/lib-cjs/component/2d/Viewer2D.js +4 -4
  119. package/lib-cjs/component/2d/XAxis.js +2 -2
  120. package/lib-cjs/component/2d/YAxis.js +2 -2
  121. package/lib-cjs/component/2d/tools/XYLabelPointer.js +3 -1
  122. package/lib-cjs/component/2d/tools/slicing/SlicingView.js +3 -1
  123. package/lib-cjs/component/2d/zones/IndicationLines.js +1 -1
  124. package/lib-cjs/component/2d/zones/Zones.js +13 -18
  125. package/lib-cjs/component/NMRium.js +14 -3
  126. package/lib-cjs/component/elements/popup/Modal/Provider.js +8 -11
  127. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -1
  128. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +2 -2
  129. package/lib-cjs/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  130. package/lib-cjs/component/hooks/useExport.js +0 -16
  131. package/lib-cjs/component/hooks/useIntegralPath.js +5 -2
  132. package/lib-cjs/component/hooks/useNucleus.js +4 -4
  133. package/lib-cjs/component/hooks/useSpectraPerNucleus.js +1 -1
  134. package/lib-cjs/component/hooks/useSpectrum.js +3 -1
  135. package/lib-cjs/component/loader/DropZone.js +6 -149
  136. package/lib-cjs/component/modal/changeSum/SelectMolecule.js +1 -1
  137. package/lib-cjs/component/modal/editRange/EditRangeModal.js +1 -1
  138. package/lib-cjs/component/modal/setting/ToolsTabContent.js +4 -0
  139. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  140. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  141. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  142. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  143. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +10 -9
  144. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -3
  145. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  146. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  147. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  148. package/lib-cjs/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  149. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +18 -9
  150. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  151. package/lib-cjs/component/reducer/IgnoreActions.js +1 -0
  152. package/lib-cjs/component/reducer/Reducer.js +48 -43
  153. package/lib-cjs/component/reducer/actions/DomainActions.js +11 -9
  154. package/lib-cjs/component/reducer/actions/FiltersActions.js +219 -233
  155. package/lib-cjs/component/reducer/actions/IntegralsActions.js +13 -8
  156. package/lib-cjs/component/reducer/actions/LoadActions.js +18 -36
  157. package/lib-cjs/component/reducer/actions/MoleculeActions.js +23 -6
  158. package/lib-cjs/component/reducer/actions/PeaksActions.js +18 -12
  159. package/lib-cjs/component/reducer/actions/PreferencesActions.js +8 -10
  160. package/lib-cjs/component/reducer/actions/RangesActions.js +85 -27
  161. package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  162. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +13 -10
  163. package/lib-cjs/component/reducer/actions/ToolsActions.js +38 -23
  164. package/lib-cjs/component/reducer/actions/ZonesActions.js +71 -17
  165. package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
  166. package/lib-cjs/component/reducer/helper/getActiveSpectrumOrFail.js +10 -0
  167. package/lib-cjs/component/reducer/helper/getSpectrum.js +3 -2
  168. package/lib-cjs/component/reducer/helper/getStrongestPeak.js +2 -1
  169. package/lib-cjs/component/reducer/types/Types.js +8 -3
  170. package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  171. package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +14 -8
  172. package/lib-cjs/component/toolbar/BasicToolBar.js +4 -6
  173. package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
  174. package/lib-cjs/component/utility/assert.js +9 -0
  175. package/lib-cjs/component/workspaces/exercise.js +6 -0
  176. package/lib-cjs/data/SpectraManager.js +3 -92
  177. package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  178. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  179. package/lib-cjs/data/data1d/filter1d/fft.js +11 -0
  180. package/lib-cjs/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +39 -0
  181. package/lib-cjs/versionInfo.js +1 -1
  182. package/package.json +22 -22
  183. package/lib/component/utility/nmredataToNmrium.d.ts +0 -4
  184. package/lib/component/utility/nmredataToNmrium.js +0 -66
  185. package/lib/component/utility/nmriumToNmredata.d.ts +0 -2
  186. package/lib/component/utility/nmriumToNmredata.js +0 -80
  187. package/lib/component/utility/util/nmredata/addRanges.d.ts +0 -1
  188. package/lib/component/utility/util/nmredata/addRanges.js +0 -52
  189. package/lib/component/utility/util/nmredata/addSource.d.ts +0 -6
  190. package/lib/component/utility/util/nmredata/addSource.js +0 -54
  191. package/lib/component/utility/util/nmredata/addZones.d.ts +0 -1
  192. package/lib/component/utility/util/nmredata/addZones.js +0 -41
  193. package/lib/component/utility/util/nmredata/flat2DSignals.d.ts +0 -1
  194. package/lib/component/utility/util/nmredata/flat2DSignals.js +0 -7
  195. package/lib/component/utility/util/nmredata/get1DSignals.d.ts +0 -10
  196. package/lib/component/utility/util/nmredata/get1DSignals.js +0 -96
  197. package/lib/component/utility/util/nmredata/get2DSignals.d.ts +0 -8
  198. package/lib/component/utility/util/nmredata/get2DSignals.js +0 -59
  199. package/lib/component/utility/util/nmredata/getCouplingObserved.d.ts +0 -1
  200. package/lib/component/utility/util/nmredata/getCouplingObserved.js +0 -11
  201. package/lib/component/utility/util/nmredata/getLabels.d.ts +0 -9
  202. package/lib/component/utility/util/nmredata/getLabels.js +0 -66
  203. package/lib/component/utility/util/nmredata/getToFix.d.ts +0 -1
  204. package/lib/component/utility/util/nmredata/getToFix.js +0 -19
  205. package/lib/data/migration/MigrationManager.d.ts +0 -2
  206. package/lib/data/migration/MigrationManager.js +0 -19
  207. package/lib/data/migration/changeKeys.d.ts +0 -1
  208. package/lib/data/migration/changeKeys.js +0 -9
  209. package/lib/data/migration/migrateToVersion1.d.ts +0 -11
  210. package/lib/data/migration/migrateToVersion1.js +0 -32
  211. package/lib/data/migration/migrateToVersion2.d.ts +0 -1
  212. package/lib/data/migration/migrateToVersion2.js +0 -111
  213. package/lib/data/migration/migrateToVersion3.d.ts +0 -1
  214. package/lib/data/migration/migrateToVersion3.js +0 -55
  215. package/lib-cjs/component/utility/nmredataToNmrium.js +0 -73
  216. package/lib-cjs/component/utility/nmriumToNmredata.js +0 -87
  217. package/lib-cjs/component/utility/util/nmredata/addRanges.js +0 -56
  218. package/lib-cjs/component/utility/util/nmredata/addSource.js +0 -61
  219. package/lib-cjs/component/utility/util/nmredata/addZones.js +0 -45
  220. package/lib-cjs/component/utility/util/nmredata/flat2DSignals.js +0 -11
  221. package/lib-cjs/component/utility/util/nmredata/get1DSignals.js +0 -100
  222. package/lib-cjs/component/utility/util/nmredata/get2DSignals.js +0 -63
  223. package/lib-cjs/component/utility/util/nmredata/getCouplingObserved.js +0 -15
  224. package/lib-cjs/component/utility/util/nmredata/getLabels.js +0 -70
  225. package/lib-cjs/component/utility/util/nmredata/getToFix.js +0 -23
  226. package/lib-cjs/data/migration/MigrationManager.js +0 -26
  227. package/lib-cjs/data/migration/changeKeys.js +0 -13
  228. package/lib-cjs/data/migration/migrateToVersion1.js +0 -35
  229. package/lib-cjs/data/migration/migrateToVersion2.js +0 -114
  230. package/lib-cjs/data/migration/migrateToVersion3.js +0 -58
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.nmriumToNmredata = void 0;
7
- const jszip_1 = __importDefault(require("jszip"));
8
- const openchemlib_utils_1 = require("openchemlib-utils");
9
- const full_1 = require("openchemlib/full");
10
- const get1DSignals_1 = require("./util/nmredata/get1DSignals");
11
- const get2DSignals_1 = require("./util/nmredata/get2DSignals");
12
- const getLabels_1 = require("./util/nmredata/getLabels");
13
- const tags = {
14
- solvent: 'SOLVENT',
15
- temperature: 'TEMPERATURE',
16
- assignment: 'ASSIGNMENT',
17
- j: 'J',
18
- signals: 'SIGNALS',
19
- id: 'ID',
20
- };
21
- async function nmriumToNmredata(state, options = {}) {
22
- const { data, // it would be changed depending of the final location
23
- molecules, } = state || {
24
- data: [],
25
- molecules: [],
26
- };
27
- let nmrRecord = new jszip_1.default();
28
- for (const molecule of molecules) {
29
- await addNMReDATA(data, nmrRecord, {
30
- ...options,
31
- molecule,
32
- });
33
- }
34
- if (!molecules.length)
35
- await addNMReDATA(data, nmrRecord, options);
36
- return nmrRecord;
37
- }
38
- exports.nmriumToNmredata = nmriumToNmredata;
39
- async function addNMReDATA(data, nmrRecord, options = {}) {
40
- let { id, prefix = '\n> <NMREDATA_', filename = 'nmredata', molecule, } = options;
41
- let sdfResult = '';
42
- let groupedDiaIDs;
43
- if (molecule) {
44
- molecule = full_1.Molecule.fromMolfile(molecule.molfile);
45
- sdfResult += molecule.toMolfile();
46
- molecule.addImplicitHydrogens();
47
- groupedDiaIDs = (0, openchemlib_utils_1.getGroupedDiastereotopicAtomIDs)(molecule);
48
- }
49
- let labels = molecule
50
- ? (0, getLabels_1.getLabels)(data, { groupedDiaIDs, molecule })
51
- : { byDiaID: undefined, byAssignNumber: undefined };
52
- sdfResult += `${prefix}VERSION>\n1.1\\\n`;
53
- sdfResult += putTag(data, 'temperature', { prefix });
54
- sdfResult += putTag(data, 'solvent', { prefix });
55
- if (id)
56
- sdfResult += `${prefix + tags.id}>\nid\\\n`;
57
- sdfResult += formatAssignments(labels.byDiaID, { prefix });
58
- sdfResult += await (0, get1DSignals_1.get1DSignals)(data, nmrRecord, { prefix, labels });
59
- sdfResult += await (0, get2DSignals_1.get2DSignals)(data, nmrRecord, { prefix, labels });
60
- sdfResult += '\n$$$$\n';
61
- nmrRecord.file(`${filename}.sdf`, sdfResult);
62
- }
63
- function formatAssignments(labels, options) {
64
- if (!labels)
65
- return '';
66
- const { prefix } = options;
67
- let str = `${prefix + tags.assignment}>\n`;
68
- for (let l in labels) {
69
- let atoms = labels[l].atoms;
70
- str += `${labels[l].label}, ${labels[l].shift}`; // change to add label
71
- for (let atom of atoms)
72
- str += `, ${atom}`;
73
- str += '\\\n';
74
- }
75
- return str;
76
- }
77
- function putTag(spectra, tag, options = { prefix: '' }) {
78
- const { prefix } = options;
79
- let str = '';
80
- for (let spectrum of spectra) {
81
- if (spectrum.info[tag]) {
82
- str += `${prefix + tags[tag]}>\n${String(spectrum.info[tag])}\\\n`;
83
- break;
84
- }
85
- }
86
- return str;
87
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addRanges = void 0;
4
- const Spectrum1D_1 = require("../../../../data/data1d/Spectrum1D");
5
- function addRanges(signals, datum) {
6
- let ranges = [];
7
- const { baseFrequency: frequency = 500 } = datum;
8
- for (const signal of signals) {
9
- const { jCoupling: js, delta, diaIDs = [], multiplicity, integration, } = signal;
10
- const fromTo = computeFromTo({ delta, js, frequency });
11
- if (js && multiplicity) {
12
- if (js.length === multiplicity.length) {
13
- js.sort((a, b) => b - a);
14
- for (let i = 0; i < js.length; i++) {
15
- js[i].multiplicity = multiplicity[i];
16
- }
17
- }
18
- }
19
- ranges.push({
20
- ...fromTo,
21
- integration,
22
- signals: [
23
- {
24
- js,
25
- delta,
26
- diaIDs,
27
- multiplicity,
28
- },
29
- ],
30
- });
31
- }
32
- datum.ranges.values = (0, Spectrum1D_1.mapRanges)(joinRanges(ranges), datum);
33
- }
34
- exports.addRanges = addRanges;
35
- function computeFromTo(options = {}) {
36
- const { delta, js: couplings = [], frequency } = options;
37
- let width = 0.5;
38
- for (let j of couplings) {
39
- width += j.coupling;
40
- }
41
- width /= frequency;
42
- return { from: delta - width, to: delta + width };
43
- }
44
- function joinRanges(ranges) {
45
- ranges.sort((a, b) => a.from - b.from);
46
- for (let i = 0; i < ranges.length - 1; i++) {
47
- if (ranges[i].to > ranges[i + 1].from) {
48
- ranges[i].to = Math.max(ranges[i + 1].to, ranges[i].to);
49
- ranges[i].signals = ranges[i].signals.concat(ranges[i + 1].signals);
50
- ranges[i].integration += ranges[i + 1].integration;
51
- ranges.splice(i + 1, 1);
52
- i--;
53
- }
54
- }
55
- return ranges;
56
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addSource = void 0;
7
- const jszip_1 = __importDefault(require("jszip"));
8
- const jszip = new jszip_1.default();
9
- async function addSource(nmrRecord, options = {}) {
10
- const { spectrum, source } = options;
11
- const { file = {}, jcampURL } = source;
12
- let tag = '';
13
- const dimension = `${spectrum.info.dimension}d`;
14
- switch (file.extension) {
15
- case 'jdx':
16
- case 'dx':
17
- tag += `\nJcamp_Location=file:jcamp/${dimension}/${spectrum.display.name}\\`;
18
- nmrRecord.file(`jcamp/${dimension}/${spectrum.display.name}`, file.binary);
19
- break;
20
- case 'zip':
21
- if (!file.binary)
22
- return;
23
- void jszip.loadAsync(file.binary).then(async (zip) => {
24
- for (const file in zip.files) {
25
- if (file.endsWith('/'))
26
- continue;
27
- nmrRecord.file(`Bruker/${file}`, await zip.file(file)?.async('arraybuffer'));
28
- }
29
- tag += `\nSpectrum_Location=file:Bruker/${getPathFromZip(zip)}\\`;
30
- });
31
- break;
32
- default:
33
- if (!jcampURL)
34
- break;
35
- await fetch(jcampURL).then(async (jcamp) => {
36
- if (!jcamp)
37
- return;
38
- let name = jcampURL.split('/').slice(-1);
39
- const path = `jcamp/${dimension}/${name}`;
40
- tag += `\nJcamp_Location=file:${path}\\`;
41
- nmrRecord.file(path, await jcamp.arrayBuffer());
42
- });
43
- }
44
- return tag;
45
- }
46
- exports.addSource = addSource;
47
- function getPathFromZip(zip) {
48
- let files = zip.filter((relativePath) => {
49
- if (relativePath.match('__MACOSX'))
50
- return false;
51
- if (relativePath.endsWith('fid') ||
52
- relativePath.endsWith('1r') ||
53
- relativePath.endsWith('ser') ||
54
- relativePath.endsWith('2rr')) {
55
- return true;
56
- }
57
- return false;
58
- });
59
- const index = files.findIndex((file) => file.name.endsWith('1r') || file.name.endsWith('2rr'));
60
- return index > -1 ? files[index].name : files[0].name;
61
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addZones = void 0;
4
- const uuid_1 = require("@lukeed/uuid");
5
- const Spectrum2D_1 = require("../../../../data/data2d/Spectrum2D");
6
- const axisLabels = ['y', 'x'];
7
- function addZones(signals, datum) {
8
- let zones = [];
9
- const shift = (0, Spectrum2D_1.getShift)(datum);
10
- const { baseFrequency } = datum.info;
11
- const frequency = { x: baseFrequency[0], y: baseFrequency[1] };
12
- for (const signal of signals) {
13
- let zone = { x: {}, y: {}, id: (0, uuid_1.v4)(), kind: 'signal' };
14
- let signalFormated = { id: (0, uuid_1.v4)(), kind: 'signal', peaks: [] };
15
- let width = { x: 10, y: 10 };
16
- for (let axis of axisLabels) {
17
- let { coupling = [], delta, diaIDs = [] } = signal[axis];
18
- for (let j of coupling) {
19
- width[axis] += j.coupling;
20
- }
21
- if (signal.activeCoupling) {
22
- const { activeCoupling = [] } = signal;
23
- for (let j of activeCoupling) {
24
- width[axis] += j.coupling;
25
- }
26
- }
27
- width[axis] /= frequency[axis];
28
- zone[axis] = {
29
- from: delta - width[axis],
30
- to: delta + width[axis],
31
- };
32
- signalFormated[axis] = {
33
- delta,
34
- diaIDs,
35
- originDelta: delta - shift[`${axis}Shift`],
36
- };
37
- }
38
- zones.push({
39
- ...zone,
40
- signals: [signalFormated],
41
- });
42
- }
43
- datum.zones.values = zones;
44
- }
45
- exports.addZones = addZones;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flat2DSignals = void 0;
4
- function flat2DSignals(signals) {
5
- let flattedSignal = [];
6
- for (const { x, y } of signals) {
7
- flattedSignal.push(x, y);
8
- }
9
- return flattedSignal;
10
- }
11
- exports.flat2DSignals = flat2DSignals;
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.get1DSignals = void 0;
4
- const addSource_1 = require("./addSource");
5
- const getToFix_1 = require("./getToFix");
6
- async function get1DSignals(data, nmrRecord, options = { labels: { byDiaID: [] } }) {
7
- let { prefix = '', labels } = options;
8
- let str = '';
9
- let nucleusArray = [];
10
- for (let spectrum of data) {
11
- const { info } = spectrum;
12
- if (info.isFid || info.dimension > 1)
13
- continue;
14
- let partTag = '';
15
- let ranges = spectrum.ranges.values || [];
16
- let nucleus = spectrum.info.nucleus;
17
- let counter = 1;
18
- let subfix = '';
19
- nucleusArray.forEach((e) => {
20
- if (e === nucleus)
21
- counter++;
22
- });
23
- nucleusArray.push(nucleus);
24
- if (counter > 1)
25
- subfix = `#${counter}`;
26
- partTag += `${prefix}1D_${nucleus.toUpperCase()}${subfix}>`;
27
- if (spectrum.info.baseFrequency) {
28
- partTag += `\nLarmor=${Number(spectrum.info.baseFrequency).toFixed(2)}\\`;
29
- }
30
- const { source = {} } = spectrum;
31
- partTag += await (0, addSource_1.addSource)(nmrRecord, {
32
- spectrum,
33
- source,
34
- });
35
- let toFix = (0, getToFix_1.getToFix)(nucleus)[0];
36
- for (let range of ranges) {
37
- let signals = range.signals;
38
- for (let signal of signals) {
39
- let { multiplicity } = signal;
40
- if ((!multiplicity || multiplicity === 'm') && nucleus === '1H') {
41
- partTag += `\n${Number(range.from).toFixed(toFix)}-${Number(range.to).toFixed(toFix)}`;
42
- }
43
- else if (signal.delta) {
44
- partTag += `\n${Number(signal.delta).toFixed(toFix)}`;
45
- }
46
- else {
47
- continue;
48
- }
49
- let signalLabel = '';
50
- if (signal.diaIDs && signal.diaIDs.length > 0) {
51
- signal.diaIDs.forEach((diaID, i, arr) => {
52
- let separator = ', ';
53
- if (i === arr.length - 1)
54
- separator = '';
55
- let label = labels.byDiaID[diaID].label || diaID;
56
- signalLabel += `${label}${separator}`;
57
- });
58
- partTag += `, L=${signalLabel}`;
59
- }
60
- if (nucleus === '1H') {
61
- if (signal.multiplicity)
62
- partTag += `, S=${signal.multiplicity}`;
63
- let jCoupling = signal.js;
64
- if (Array.isArray(jCoupling) && jCoupling.length) {
65
- let separator = ', J=';
66
- for (const jCouplingElement of jCoupling) {
67
- partTag += `${separator}${Number(jCouplingElement.coupling).toFixed(3)}`;
68
- if (jCouplingElement.diaIDs) {
69
- let { diaIDs } = jCouplingElement;
70
- if (!Array.isArray(diaIDs))
71
- diaIDs = [diaIDs];
72
- if (!diaIDs.length)
73
- continue;
74
- let jCouple = labels.byDiaID[diaIDs[0]].label || String(diaIDs[0]);
75
- partTag += `(${jCouple})`;
76
- }
77
- separator = ', ';
78
- }
79
- }
80
- if (range.integration) {
81
- partTag += `, E=${Number(range.integration).toFixed(toFix)}`;
82
- }
83
- else if (range.nbAtoms) {
84
- partTag += `, E=${range.nbAtoms.toFixed(toFix)}`;
85
- }
86
- else if (range.signals[0].nbAtoms !== undefined) {
87
- partTag += `, E=${range.signals[0].nbAtoms}`;
88
- }
89
- }
90
- }
91
- if (signals.length)
92
- partTag += '\\';
93
- }
94
- partTag += '\n';
95
- if (/\n/.exec(partTag))
96
- str += partTag;
97
- }
98
- return str;
99
- }
100
- exports.get1DSignals = get1DSignals;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.get2DSignals = void 0;
4
- const addSource_1 = require("./addSource");
5
- const getCouplingObserved_1 = require("./getCouplingObserved");
6
- const getToFix_1 = require("./getToFix");
7
- const isArray = Array.isArray;
8
- async function get2DSignals(data, nmrRecord, options = { labels: {} }) {
9
- const { byDiaID } = options.labels;
10
- let str = '';
11
- let nucleusRecorded = [];
12
- const prefix = `\n> <NMREDATA_2D_`;
13
- for (let spectrum of data) {
14
- if (spectrum.info.dimension < 2)
15
- continue;
16
- let partTag = '';
17
- const { info, source } = spectrum;
18
- let { nucleus, experiment, pulseSequence } = info;
19
- nucleusRecorded.push(nucleus);
20
- let couplingObserved = (0, getCouplingObserved_1.getCouplingObserved)(experiment);
21
- if (nucleus) {
22
- partTag += `${prefix}${nucleus[1]}_${couplingObserved}_${nucleus[0]}>`;
23
- }
24
- let toFix = (0, getToFix_1.getToFix)(nucleus);
25
- partTag += await (0, addSource_1.addSource)(nmrRecord, {
26
- spectrum,
27
- source,
28
- });
29
- if (experiment)
30
- partTag += `\nCorType=${experiment} \\`;
31
- if (pulseSequence)
32
- partTag += `\nPulseProgram=${pulseSequence} \\`;
33
- if (spectrum.info.baseFrequency) {
34
- partTag += `\nLarmor=${Number(spectrum.info.baseFrequency[0]).toFixed(2)}\\`;
35
- }
36
- let zones = spectrum.zones.values || [];
37
- for (let zone of zones) {
38
- let signals = zone.signals;
39
- for (let signal of signals) {
40
- let { x, y, peaks } = signal;
41
- let xLabel = getAssignment(x, byDiaID, toFix[0]);
42
- let yLabel = getAssignment(y, byDiaID, toFix[1]);
43
- let intensity = Math.max(...peaks.map((e) => e.z));
44
- partTag += `\n${xLabel}/${yLabel}, I=${intensity.toFixed(2)}\\`;
45
- }
46
- }
47
- str += partTag;
48
- }
49
- return str.length > 0 ? `${str}\n` : '';
50
- }
51
- exports.get2DSignals = get2DSignals;
52
- function getAssignment(axis, labels, toFix) {
53
- let { diaIDs, delta } = axis;
54
- if (diaIDs) {
55
- if (!isArray(diaIDs))
56
- diaIDs = [diaIDs];
57
- if (diaIDs.length < 1)
58
- return Number(delta).toFixed(toFix);
59
- let label = diaIDs.map((diaID) => labels[diaID].label).join(',');
60
- return diaIDs.length > 1 ? `(${label})` : label;
61
- }
62
- return Number(delta).toFixed(toFix);
63
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCouplingObserved = void 0;
4
- function getCouplingObserved(experiment) {
5
- switch (experiment.toLowerCase()) {
6
- case 'hsqc':
7
- case 'cosy':
8
- return '1J';
9
- case 'hmbc':
10
- return 'NJ';
11
- default:
12
- return 'NJ';
13
- }
14
- }
15
- exports.getCouplingObserved = getCouplingObserved;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLabels = void 0;
4
- const openchemlib_utils_1 = require("openchemlib-utils");
5
- const flat2DSignals_1 = require("./flat2DSignals");
6
- const getToFix_1 = require("./getToFix");
7
- function getLabels(data, options = { groupedDiaIDs: [] }) {
8
- const { groupedDiaIDs, molecule } = options;
9
- let connections = (0, openchemlib_utils_1.getShortestPaths)(molecule, { toLabel: 'H', maxLength: 1 });
10
- let byDiaID = {};
11
- let byAssignNumber = {};
12
- for (let spectrum of data) {
13
- let { dimension, nucleus } = spectrum.info;
14
- let toFix = (0, getToFix_1.getToFix)(nucleus);
15
- let [roiKey, flatSignals] = dimension > 1 ? ['zones', flat2DSignals_1.flat2DSignals] : ['ranges', (s) => s || []];
16
- let rois = spectrum[roiKey].values || [];
17
- for (let roi of rois) {
18
- let signals = flatSignals(roi.signals);
19
- for (let i = 0; i < signals.length; i++) {
20
- let diaIDs = signals[i].diaIDs || [];
21
- for (let diaID of diaIDs) {
22
- let delta = Number(signals[i].delta).toFixed(toFix[i % dimension]);
23
- // get atomLabel
24
- let groupedOclID = groupedDiaIDs.find((dia) => {
25
- if (dia.oclID === diaID)
26
- return true;
27
- return false;
28
- });
29
- // the addition of one in atom number it is because the atoms enumeration starts from zero
30
- let labelOptions = {
31
- atom: groupedOclID.atoms[0],
32
- molecule,
33
- connections,
34
- atomLabel: groupedOclID.atomLabel,
35
- };
36
- byDiaID[diaID] = {
37
- atoms: groupedOclID.atoms.map((e) => e + 1),
38
- shift: delta,
39
- label: createLabel(labelOptions),
40
- };
41
- for (let atom of groupedOclID.atoms) {
42
- labelOptions.atom = atom;
43
- byAssignNumber[atom] = {
44
- shift: delta,
45
- diaID,
46
- label: createLabel(labelOptions),
47
- };
48
- }
49
- }
50
- }
51
- }
52
- }
53
- return { byAssignNumber, byDiaID };
54
- }
55
- exports.getLabels = getLabels;
56
- function createLabel(options) {
57
- const { atom, molecule, atomLabel, connections } = options;
58
- let label = '';
59
- if (atomLabel !== 'C') {
60
- let connectedTo = connections[atom];
61
- let path = connectedTo.find((e) => e && e.length > 1);
62
- let pLabel = `${atomLabel}${path[0] + 1}`;
63
- let hLabel = `${molecule.getAtomLabel(path[1])}${path[1] + 1}`;
64
- label = `${pLabel}${hLabel}`;
65
- }
66
- else {
67
- label = `${atomLabel}${atom + 1}`;
68
- }
69
- return label;
70
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getToFix = void 0;
4
- function getToFix(nucleusArray) {
5
- if (!Array.isArray(nucleusArray))
6
- nucleusArray = [nucleusArray];
7
- let toFix = [];
8
- for (let nucleus of nucleusArray) {
9
- toFix.push(chooseDecimal(nucleus));
10
- }
11
- return toFix;
12
- }
13
- exports.getToFix = getToFix;
14
- function chooseDecimal(nucleus) {
15
- switch (nucleus.toUpperCase()) {
16
- case '1H':
17
- return 2;
18
- case '13C':
19
- return 1;
20
- default:
21
- return 1;
22
- }
23
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.migrate = exports.CURRENT_EXPORT_VERSION = void 0;
7
- const migrateToVersion1_1 = __importDefault(require("./migrateToVersion1"));
8
- const migrateToVersion2_1 = __importDefault(require("./migrateToVersion2"));
9
- const migrateToVersion3_1 = __importDefault(require("./migrateToVersion3"));
10
- exports.CURRENT_EXPORT_VERSION = 3;
11
- function migrationPipe(functions) {
12
- return (input) => functions.reduce((input, func) => func(input), input);
13
- }
14
- function migrate(data) {
15
- let migrationsFuncs = [
16
- migrateToVersion1_1.default,
17
- migrateToVersion2_1.default,
18
- migrateToVersion3_1.default,
19
- ];
20
- let index = data?.version || 0;
21
- if (index > exports.CURRENT_EXPORT_VERSION) {
22
- throw new Error('This file can not be imported using the current NMRium version, Please move to the new one !!! ');
23
- }
24
- return migrationPipe(migrationsFuncs.slice(index))(data);
25
- }
26
- exports.migrate = migrate;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.changeKeys = void 0;
4
- function changeKeys(data, changedKeys) {
5
- return JSON.parse(JSON.stringify(data), function reviver(key, value) {
6
- if (key in changedKeys) {
7
- this[changedKeys[key]] = value;
8
- return;
9
- }
10
- return value;
11
- });
12
- }
13
- exports.changeKeys = changeKeys;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const changeKeys_1 = require("./changeKeys");
4
- /**
5
- * changes from version 0 to version 1:
6
- * all change done on objects keys naming
7
- * j => js
8
- * signal => signals
9
- * integral => integration
10
- * peak => peaks
11
- * diaID => diaIDs
12
- *
13
- */
14
- function migrateToVersion1(data) {
15
- if (data?.version === 1)
16
- return data;
17
- const newData = { ...data, version: 1 };
18
- const changedKeys = {
19
- j: 'js',
20
- signal: 'signals',
21
- integral: 'integration',
22
- peak: 'peaks',
23
- diaID: 'diaIDs',
24
- };
25
- for (const spectrum of newData.spectra) {
26
- if (spectrum.ranges) {
27
- spectrum.ranges = (0, changeKeys_1.changeKeys)(spectrum.ranges, changedKeys);
28
- }
29
- else if (spectrum.zones) {
30
- spectrum.zones = (0, changeKeys_1.changeKeys)(spectrum.zones, changedKeys);
31
- }
32
- }
33
- return newData;
34
- }
35
- exports.default = migrateToVersion1;