nmrium 0.30.0 → 0.32.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 (273) hide show
  1. package/lib/component/1d/ApodizationLine.js +3 -1
  2. package/lib/component/1d/FooterBanner.js +20 -11
  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 +4 -2
  17. package/lib/component/2d/FooterBanner.js +3 -1
  18. package/lib/component/2d/Left1DChart.js +1 -1
  19. package/lib/component/2d/Top1DChart.js +1 -1
  20. package/lib/component/2d/Viewer2D.js +4 -4
  21. package/lib/component/2d/XAxis.js +2 -2
  22. package/lib/component/2d/YAxis.js +2 -2
  23. package/lib/component/2d/tools/XYLabelPointer.js +3 -1
  24. package/lib/component/2d/tools/slicing/SlicingView.js +3 -1
  25. package/lib/component/2d/zones/IndicationLines.js +1 -1
  26. package/lib/component/2d/zones/Zones.js +14 -19
  27. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  28. package/lib/component/NMRium.d.ts +2 -0
  29. package/lib/component/NMRium.js +14 -3
  30. package/lib/component/SplitPaneWrapper.js +1 -1
  31. package/lib/component/elements/EditableColumn.d.ts +3 -1
  32. package/lib/component/elements/EditableColumn.js +18 -3
  33. package/lib/component/elements/popup/Modal/Provider.d.ts +3 -3
  34. package/lib/component/elements/popup/Modal/Provider.js +8 -11
  35. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -1
  36. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  37. package/lib/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  38. package/lib/component/hooks/useExport.d.ts +0 -1
  39. package/lib/component/hooks/useExport.js +1 -17
  40. package/lib/component/hooks/useIntegralPath.js +5 -2
  41. package/lib/component/hooks/useNucleus.js +4 -4
  42. package/lib/component/hooks/useSpectraPerNucleus.js +1 -1
  43. package/lib/component/hooks/useSpectrum.js +3 -1
  44. package/lib/component/loader/DropZone.js +15 -147
  45. package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
  46. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  47. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  48. package/lib/component/modal/setting/ToolsTabContent.js +4 -0
  49. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  50. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  51. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  52. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  53. package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  54. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  55. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
  56. package/lib/component/panels/RangesPanel/RangesHeader.js +10 -9
  57. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -3
  58. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  59. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  60. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  61. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  62. package/lib/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  63. package/lib/component/panels/ZonesPanel/ZonesPanel.js +19 -10
  64. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  65. package/lib/component/reducer/IgnoreActions.js +1 -0
  66. package/lib/component/reducer/Reducer.d.ts +110 -96
  67. package/lib/component/reducer/Reducer.js +45 -41
  68. package/lib/component/reducer/actions/DomainActions.d.ts +1 -1
  69. package/lib/component/reducer/actions/DomainActions.js +12 -9
  70. package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
  71. package/lib/component/reducer/actions/FiltersActions.js +227 -232
  72. package/lib/component/reducer/actions/IntegralsActions.js +14 -8
  73. package/lib/component/reducer/actions/LoadActions.d.ts +2 -5
  74. package/lib/component/reducer/actions/LoadActions.js +19 -34
  75. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -1
  76. package/lib/component/reducer/actions/MoleculeActions.js +22 -6
  77. package/lib/component/reducer/actions/PeaksActions.js +19 -12
  78. package/lib/component/reducer/actions/PreferencesActions.js +9 -10
  79. package/lib/component/reducer/actions/RangesActions.d.ts +4 -4
  80. package/lib/component/reducer/actions/RangesActions.js +89 -29
  81. package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  82. package/lib/component/reducer/actions/SpectrumsActions.js +14 -10
  83. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  84. package/lib/component/reducer/actions/ToolsActions.js +44 -27
  85. package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
  86. package/lib/component/reducer/actions/ZonesActions.js +69 -17
  87. package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
  88. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  89. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  90. package/lib/component/reducer/helper/getActiveSpectrumOrFail.d.ts +3 -0
  91. package/lib/component/reducer/helper/getActiveSpectrumOrFail.js +6 -0
  92. package/lib/component/reducer/helper/getSpectrum.js +3 -2
  93. package/lib/component/reducer/helper/getStrongestPeak.js +2 -1
  94. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  95. package/lib/component/reducer/types/Types.d.ts +5 -0
  96. package/lib/component/reducer/types/Types.js +5 -0
  97. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +6 -0
  98. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  99. package/lib/component/tool/FloatMoleculeStructures/index.js +14 -8
  100. package/lib/component/toolbar/BasicToolBar.js +12 -13
  101. package/lib/component/toolbar/FunctionToolBar.js +3 -1
  102. package/lib/component/utility/Export.js +7 -1
  103. package/lib/component/utility/assert.d.ts +1 -0
  104. package/lib/component/utility/assert.js +5 -0
  105. package/lib/component/workspaces/Workspace.d.ts +1 -1
  106. package/lib/component/workspaces/exercise.js +9 -3
  107. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  108. package/lib/data/Filters.d.ts +1 -2
  109. package/lib/data/Filters.js +1 -2
  110. package/lib/data/SpectraManager.d.ts +0 -4
  111. package/lib/data/SpectraManager.js +2 -87
  112. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  113. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  114. package/lib/data/data1d/filter1d/fft.js +11 -0
  115. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  116. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.d.ts +2 -0
  117. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
  118. package/lib/data/data2d/Processing2D.js +3 -2
  119. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
  120. package/lib/data/molecules/Molecule.d.ts +5 -0
  121. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  122. package/lib/data/utilities/calculateSanPlot.js +31 -0
  123. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  124. package/lib/versionInfo.js +1 -1
  125. package/lib-cjs/component/1d/ApodizationLine.js +3 -1
  126. package/lib-cjs/component/1d/FooterBanner.js +19 -10
  127. package/lib-cjs/component/1d/IntegralsSeries.js +3 -1
  128. package/lib-cjs/component/1d/LinesSeries.js +3 -1
  129. package/lib-cjs/component/1d/SpectraTracker.js +1 -1
  130. package/lib-cjs/component/1d/Viewer1D.js +3 -1
  131. package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +5 -1
  132. package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  133. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  134. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +3 -1
  135. package/lib-cjs/component/1d/peaks/PeaksShapes.js +4 -2
  136. package/lib-cjs/component/1d/peaks/usePeakShapesPath.js +7 -3
  137. package/lib-cjs/component/1d/ranges/Ranges.js +7 -1
  138. package/lib-cjs/component/1d/tool/PeakPointer.js +3 -1
  139. package/lib-cjs/component/1d/tool/XLabelPointer.js +3 -1
  140. package/lib-cjs/component/2d/Contours.js +4 -2
  141. package/lib-cjs/component/2d/FooterBanner.js +3 -1
  142. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  143. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  144. package/lib-cjs/component/2d/Viewer2D.js +4 -4
  145. package/lib-cjs/component/2d/XAxis.js +2 -2
  146. package/lib-cjs/component/2d/YAxis.js +2 -2
  147. package/lib-cjs/component/2d/tools/XYLabelPointer.js +3 -1
  148. package/lib-cjs/component/2d/tools/slicing/SlicingView.js +3 -1
  149. package/lib-cjs/component/2d/zones/IndicationLines.js +1 -1
  150. package/lib-cjs/component/2d/zones/Zones.js +13 -18
  151. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  152. package/lib-cjs/component/NMRium.js +14 -3
  153. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  154. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  155. package/lib-cjs/component/elements/popup/Modal/Provider.js +8 -11
  156. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -1
  157. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  158. package/lib-cjs/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  159. package/lib-cjs/component/hooks/useExport.js +0 -16
  160. package/lib-cjs/component/hooks/useIntegralPath.js +5 -2
  161. package/lib-cjs/component/hooks/useNucleus.js +4 -4
  162. package/lib-cjs/component/hooks/useSpectraPerNucleus.js +1 -1
  163. package/lib-cjs/component/hooks/useSpectrum.js +3 -1
  164. package/lib-cjs/component/loader/DropZone.js +14 -149
  165. package/lib-cjs/component/modal/changeSum/SelectMolecule.js +1 -1
  166. package/lib-cjs/component/modal/editRange/EditRangeModal.js +1 -1
  167. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  168. package/lib-cjs/component/modal/setting/ToolsTabContent.js +4 -0
  169. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  170. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  171. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  172. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  173. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  174. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  175. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +10 -9
  176. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -3
  177. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  178. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  179. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  180. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  181. package/lib-cjs/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  182. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +18 -9
  183. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  184. package/lib-cjs/component/reducer/IgnoreActions.js +1 -0
  185. package/lib-cjs/component/reducer/Reducer.js +48 -43
  186. package/lib-cjs/component/reducer/actions/DomainActions.js +12 -9
  187. package/lib-cjs/component/reducer/actions/FiltersActions.js +228 -233
  188. package/lib-cjs/component/reducer/actions/IntegralsActions.js +14 -8
  189. package/lib-cjs/component/reducer/actions/LoadActions.js +18 -36
  190. package/lib-cjs/component/reducer/actions/MoleculeActions.js +23 -6
  191. package/lib-cjs/component/reducer/actions/PeaksActions.js +19 -12
  192. package/lib-cjs/component/reducer/actions/PreferencesActions.js +9 -10
  193. package/lib-cjs/component/reducer/actions/RangesActions.js +89 -29
  194. package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  195. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +14 -10
  196. package/lib-cjs/component/reducer/actions/ToolsActions.js +44 -27
  197. package/lib-cjs/component/reducer/actions/ZonesActions.js +72 -17
  198. package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
  199. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  200. package/lib-cjs/component/reducer/helper/getActiveSpectrumOrFail.js +10 -0
  201. package/lib-cjs/component/reducer/helper/getSpectrum.js +3 -2
  202. package/lib-cjs/component/reducer/helper/getStrongestPeak.js +2 -1
  203. package/lib-cjs/component/reducer/types/Types.js +8 -3
  204. package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  205. package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +14 -8
  206. package/lib-cjs/component/toolbar/BasicToolBar.js +11 -12
  207. package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
  208. package/lib-cjs/component/utility/Export.js +7 -1
  209. package/lib-cjs/component/utility/assert.js +9 -0
  210. package/lib-cjs/component/workspaces/exercise.js +9 -3
  211. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  212. package/lib-cjs/data/Filters.js +1 -3
  213. package/lib-cjs/data/SpectraManager.js +3 -92
  214. package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  215. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  216. package/lib-cjs/data/data1d/filter1d/fft.js +11 -0
  217. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  218. package/lib-cjs/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +39 -0
  219. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  220. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  221. package/lib-cjs/versionInfo.js +1 -1
  222. package/package.json +26 -25
  223. package/lib/component/utility/nmredataToNmrium.d.ts +0 -4
  224. package/lib/component/utility/nmredataToNmrium.js +0 -66
  225. package/lib/component/utility/nmriumToNmredata.d.ts +0 -2
  226. package/lib/component/utility/nmriumToNmredata.js +0 -80
  227. package/lib/component/utility/util/nmredata/addRanges.d.ts +0 -1
  228. package/lib/component/utility/util/nmredata/addRanges.js +0 -52
  229. package/lib/component/utility/util/nmredata/addSource.d.ts +0 -6
  230. package/lib/component/utility/util/nmredata/addSource.js +0 -54
  231. package/lib/component/utility/util/nmredata/addZones.d.ts +0 -1
  232. package/lib/component/utility/util/nmredata/addZones.js +0 -41
  233. package/lib/component/utility/util/nmredata/flat2DSignals.d.ts +0 -1
  234. package/lib/component/utility/util/nmredata/flat2DSignals.js +0 -7
  235. package/lib/component/utility/util/nmredata/get1DSignals.d.ts +0 -10
  236. package/lib/component/utility/util/nmredata/get1DSignals.js +0 -96
  237. package/lib/component/utility/util/nmredata/get2DSignals.d.ts +0 -8
  238. package/lib/component/utility/util/nmredata/get2DSignals.js +0 -59
  239. package/lib/component/utility/util/nmredata/getCouplingObserved.d.ts +0 -1
  240. package/lib/component/utility/util/nmredata/getCouplingObserved.js +0 -11
  241. package/lib/component/utility/util/nmredata/getLabels.d.ts +0 -9
  242. package/lib/component/utility/util/nmredata/getLabels.js +0 -66
  243. package/lib/component/utility/util/nmredata/getToFix.d.ts +0 -1
  244. package/lib/component/utility/util/nmredata/getToFix.js +0 -19
  245. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  246. package/lib/data/data1d/filter1d/absolute.js +0 -26
  247. package/lib/data/migration/MigrationManager.d.ts +0 -2
  248. package/lib/data/migration/MigrationManager.js +0 -19
  249. package/lib/data/migration/changeKeys.d.ts +0 -1
  250. package/lib/data/migration/changeKeys.js +0 -9
  251. package/lib/data/migration/migrateToVersion1.d.ts +0 -11
  252. package/lib/data/migration/migrateToVersion1.js +0 -32
  253. package/lib/data/migration/migrateToVersion2.d.ts +0 -1
  254. package/lib/data/migration/migrateToVersion2.js +0 -111
  255. package/lib/data/migration/migrateToVersion3.d.ts +0 -1
  256. package/lib/data/migration/migrateToVersion3.js +0 -55
  257. package/lib-cjs/component/utility/nmredataToNmrium.js +0 -73
  258. package/lib-cjs/component/utility/nmriumToNmredata.js +0 -87
  259. package/lib-cjs/component/utility/util/nmredata/addRanges.js +0 -56
  260. package/lib-cjs/component/utility/util/nmredata/addSource.js +0 -61
  261. package/lib-cjs/component/utility/util/nmredata/addZones.js +0 -45
  262. package/lib-cjs/component/utility/util/nmredata/flat2DSignals.js +0 -11
  263. package/lib-cjs/component/utility/util/nmredata/get1DSignals.js +0 -100
  264. package/lib-cjs/component/utility/util/nmredata/get2DSignals.js +0 -63
  265. package/lib-cjs/component/utility/util/nmredata/getCouplingObserved.js +0 -15
  266. package/lib-cjs/component/utility/util/nmredata/getLabels.js +0 -70
  267. package/lib-cjs/component/utility/util/nmredata/getToFix.js +0 -23
  268. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
  269. package/lib-cjs/data/migration/MigrationManager.js +0 -26
  270. package/lib-cjs/data/migration/changeKeys.js +0 -13
  271. package/lib-cjs/data/migration/migrateToVersion1.js +0 -35
  272. package/lib-cjs/data/migration/migrateToVersion2.js +0 -114
  273. package/lib-cjs/data/migration/migrateToVersion3.js +0 -58
@@ -1,111 +0,0 @@
1
- import { changeKeys } from './changeKeys';
2
- /*
3
- * changes from version 1 to version 2:
4
- 1- peaks :
5
- delta => x , originDelta => originalX, intensity => y,
6
- paths:
7
- - peak
8
-
9
- 2- range/signals :
10
- atomIDs => atoms , intensity => y,
11
-
12
- paths:
13
- - range > signals
14
- - range > signals > js
15
- - range > signals > peaks
16
-
17
- 3- zone/signals :
18
- we have two cases the
19
- a)
20
- get out the inner object fromTo:{from,to} => {from,to}
21
- paths:
22
- - zone > signals > x
23
- - zone > signals > y
24
- b)
25
- { fromTo,deltaX,resolutionX,nucleusX,deltaY,resolutionY,nucleusY,shiftX,shiftY} =>
26
- {
27
- x: {
28
- from: fromTo[0].from,
29
- to: fromTo[0].to,
30
- delta: deltaX,
31
- resolution: resolutionX,
32
- nucleus: nucleusX,
33
- },
34
- y: {
35
- from: fromTo[1].from,
36
- to: fromTo[1].to,
37
- delta: deltaY,
38
- resolution: resolutionY,
39
- nucleus: nucleusY,
40
- },
41
- }
42
-
43
- paths:
44
- -zone>signals
45
- */
46
- export default function migrateToVersion2(data) {
47
- if (data?.version === 2)
48
- return data;
49
- const newData = { ...data, version: 2 };
50
- const changedKeys = {
51
- peaks: {
52
- delta: 'x',
53
- originDelta: 'originalX',
54
- intensity: 'y',
55
- },
56
- ranges: {
57
- atomIDs: 'atoms',
58
- intensity: 'y', // signal > peaks
59
- },
60
- };
61
- for (const spectrum of newData.spectra) {
62
- if (spectrum.peaks) {
63
- spectrum.peaks = changeKeys(spectrum.peaks, changedKeys.peaks);
64
- }
65
- else if (spectrum.ranges) {
66
- spectrum.ranges = changeKeys(spectrum.ranges, changedKeys.ranges);
67
- }
68
- else if (spectrum.zones) {
69
- spectrum.zones.values = mapZones(spectrum.zones.values);
70
- }
71
- }
72
- return newData;
73
- }
74
- function mapZones(zones) {
75
- return zones.map((zone) => {
76
- if (zone.signals) {
77
- zone.signals = zone.signals.map((signal) => {
78
- if (signal.x && signal.y) {
79
- const { x: { fromTo: fromToX, ...resX }, y: { fromTo: fromToY, ...resY }, } = signal;
80
- signal = {
81
- ...signal,
82
- x: { ...resX, ...fromToX },
83
- y: { ...resY, ...fromToY },
84
- };
85
- }
86
- else {
87
- const { fromTo, deltaX, resolutionX, nucleusX, deltaY, resolutionY, nucleusY, shiftX, shiftY, ...resSignal } = signal;
88
- signal = {
89
- ...resSignal,
90
- x: {
91
- from: fromTo[0].from,
92
- to: fromTo[0].to,
93
- delta: deltaX,
94
- resolution: resolutionX,
95
- nucleus: nucleusX,
96
- },
97
- y: {
98
- from: fromTo[1].from,
99
- to: fromTo[1].to,
100
- delta: deltaY,
101
- resolution: resolutionY,
102
- nucleus: nucleusY,
103
- },
104
- };
105
- }
106
- return signal;
107
- }, []);
108
- }
109
- return zone;
110
- }, []);
111
- }
@@ -1 +0,0 @@
1
- export default function migrateToVersion3(data: any): any;
@@ -1,55 +0,0 @@
1
- /*
2
- * changes from version 2 to version 3:
3
- change the filters, replace the line broadening filter with the apodization filter and the order should apodization filter > zero filling instead of zero filling > line broadening
4
-
5
- - line broadening filter object
6
- {
7
- "name": "lineBroadening",
8
- "value": 1,
9
- ... other props
10
- }
11
-
12
- - apodization filter object
13
-
14
- {
15
- "name": "apodization",
16
- "value": {
17
- "lineBroadening": 1,
18
- "gaussBroadening": 0,
19
- "lineBroadeningCenter": 0
20
- },
21
- ... other props
22
- }
23
-
24
- */
25
- const apodizationObject = {
26
- name: 'apodization',
27
- label: 'Apodization',
28
- value: {
29
- lineBroadening: 1,
30
- gaussBroadening: 0,
31
- lineBroadeningCenter: 0,
32
- },
33
- };
34
- export default function migrateToVersion3(data) {
35
- if (data?.version === 3)
36
- return data;
37
- const newData = { ...data, version: 3 };
38
- for (const spectrum of newData.spectra) {
39
- if (Array.isArray(spectrum?.filters) && spectrum?.filters.length > 0) {
40
- // look for the index of lineBroadening filter
41
- const lineBroadeningFilterIndex = spectrum.filters.findIndex((filter) => filter.name === 'lineBroadening');
42
- if (lineBroadeningFilterIndex !== -1) {
43
- //replace lineBroadening filter with apodization filter and swipe zero filling filter with apodization filter
44
- const temp = {
45
- ...spectrum.filters[lineBroadeningFilterIndex],
46
- ...apodizationObject,
47
- };
48
- spectrum.filters[lineBroadeningFilterIndex] =
49
- spectrum.filters[lineBroadeningFilterIndex - 1];
50
- spectrum.filters[lineBroadeningFilterIndex - 1] = temp;
51
- }
52
- }
53
- }
54
- return newData;
55
- }
@@ -1,73 +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.nmredataToNmrium = void 0;
7
- const jszip_1 = __importDefault(require("jszip"));
8
- const nmredata_1 = require("nmredata");
9
- const SpectraManager_1 = require("../../data/SpectraManager");
10
- const addRanges_1 = require("./util/nmredata/addRanges");
11
- const addZones_1 = require("./util/nmredata/addZones");
12
- async function nmredataToNmrium(file, usedColors) {
13
- const jszip = new jszip_1.default();
14
- const zip = await jszip.loadAsync(file.binary);
15
- const sdfFiles = await getSDF(zip.files);
16
- const jsonData = await nmredata_1.NmrRecord.toJSON({
17
- sdf: sdfFiles[0],
18
- zipFiles: zip.files,
19
- });
20
- let { spectra, molecules = [] } = jsonData;
21
- let nmrium = {
22
- spectra: [],
23
- molecules,
24
- };
25
- for (const data of spectra) {
26
- const { file, jcampURL } = data.source;
27
- let spectrum = (await getSpectra(file, { jcampURL }, usedColors)) || [];
28
- for (const spectrumData of spectrum) {
29
- const { info } = spectrumData;
30
- if (info.isFid)
31
- continue;
32
- if (info.dimension > 1) {
33
- (0, addZones_1.addZones)(data.signals, spectrumData);
34
- }
35
- else {
36
- (0, addRanges_1.addRanges)(data.signals, spectrumData);
37
- }
38
- }
39
- nmrium.spectra.push(...spectrum);
40
- }
41
- return nmrium;
42
- }
43
- exports.nmredataToNmrium = nmredataToNmrium;
44
- async function getSpectra(file, options = {}, usedColors = {}) {
45
- const { xy = true, noContours = true, keepOriginal = true, jcampURL, } = options;
46
- switch (file.extension) {
47
- case 'jdx':
48
- case 'dx':
49
- return (0, SpectraManager_1.addJcamps)([file], usedColors);
50
- case 'zip':
51
- return (0, SpectraManager_1.addBruker)({ xy, noContours, keepOriginal }, file.binary, usedColors);
52
- default:
53
- if (!jcampURL) {
54
- throw new Error('file extension is not supported');
55
- }
56
- }
57
- }
58
- async function getSDF(zipFiles) {
59
- let result = [];
60
- for (const file in zipFiles) {
61
- const pathFile = file.split('/');
62
- if (/^[^.].+sdf$/.exec(pathFile[pathFile.length - 1])) {
63
- const filename = pathFile[pathFile.length - 1].replace(/\.sdf/, '');
64
- const root = pathFile.slice(0, pathFile.length - 1).join('/');
65
- const sdf = await zipFiles[file].async('string');
66
- let parserResult = (0, nmredata_1.parseSDF)(`${sdf}`, { mixedEOL: true });
67
- parserResult.filename = filename;
68
- parserResult.root = root !== '' ? `${root}/` : '';
69
- result.push(parserResult);
70
- }
71
- }
72
- return result;
73
- }
@@ -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;