jcampconverter 8.2.0 → 8.2.4
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/2d/add2D.d.ts +2 -0
- package/lib/2d/add2D.d.ts.map +1 -0
- package/lib/2d/add2D.js +17 -0
- package/lib/2d/add2D.js.map +1 -0
- package/lib/2d/convertTo3DZ.d.ts +11 -0
- package/lib/2d/convertTo3DZ.d.ts.map +1 -0
- package/lib/2d/convertTo3DZ.js +59 -0
- package/lib/2d/convertTo3DZ.js.map +1 -0
- package/lib/2d/generateContourLines.d.ts +8 -0
- package/lib/2d/generateContourLines.d.ts.map +1 -0
- package/lib/2d/generateContourLines.js +163 -0
- package/lib/2d/generateContourLines.js.map +1 -0
- package/lib/complexChromatogram.d.ts +4 -0
- package/lib/complexChromatogram.d.ts.map +1 -0
- package/lib/complexChromatogram.js +49 -0
- package/lib/complexChromatogram.js.map +1 -0
- package/lib/convert.d.ts +147 -0
- package/lib/convert.d.ts.map +1 -0
- package/lib/convert.js +391 -0
- package/lib/convert.js.map +1 -0
- package/lib/convertToFloatArray.d.ts +2 -0
- package/lib/convertToFloatArray.d.ts.map +1 -0
- package/lib/convertToFloatArray.js +11 -0
- package/lib/convertToFloatArray.js.map +1 -0
- package/lib/createTree.d.ts +29 -0
- package/lib/createTree.d.ts.map +1 -0
- package/lib/createTree.js +98 -0
- package/lib/createTree.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -1213
- package/lib/index.js.map +1 -0
- package/lib/parse/fastParseXYData.d.ts +2 -0
- package/lib/parse/fastParseXYData.d.ts.map +1 -0
- package/lib/parse/fastParseXYData.js +192 -0
- package/lib/parse/fastParseXYData.js.map +1 -0
- package/lib/parse/parsePeakTable.d.ts +2 -0
- package/lib/parse/parsePeakTable.d.ts.map +1 -0
- package/lib/parse/parsePeakTable.js +67 -0
- package/lib/parse/parsePeakTable.js.map +1 -0
- package/lib/parse/parseXYA.d.ts +2 -0
- package/lib/parse/parseXYA.d.ts.map +1 -0
- package/lib/parse/parseXYA.js +17 -0
- package/lib/parse/parseXYA.js.map +1 -0
- package/lib/postProcessing.d.ts +2 -0
- package/lib/postProcessing.d.ts.map +1 -0
- package/lib/postProcessing.js +50 -0
- package/lib/postProcessing.js.map +1 -0
- package/lib/postProcessingNMR.d.ts +2 -0
- package/lib/postProcessingNMR.d.ts.map +1 -0
- package/lib/postProcessingNMR.js +94 -0
- package/lib/postProcessingNMR.js.map +1 -0
- package/lib/prepareNtuplesDatatable.d.ts +2 -0
- package/lib/prepareNtuplesDatatable.d.ts.map +1 -0
- package/lib/prepareNtuplesDatatable.js +87 -0
- package/lib/prepareNtuplesDatatable.js.map +1 -0
- package/lib/prepareSpectrum.d.ts +2 -0
- package/lib/prepareSpectrum.d.ts.map +1 -0
- package/lib/prepareSpectrum.js +10 -0
- package/lib/prepareSpectrum.js.map +1 -0
- package/lib/profiling.d.ts +2 -0
- package/lib/profiling.d.ts.map +1 -0
- package/lib/profiling.js +12 -0
- package/lib/profiling.js.map +1 -0
- package/lib/simpleChromatogram.d.ts +2 -0
- package/lib/simpleChromatogram.d.ts.map +1 -0
- package/lib/simpleChromatogram.js +16 -0
- package/lib/simpleChromatogram.js.map +1 -0
- package/lib-esm/2d/add2D.d.ts +2 -0
- package/lib-esm/2d/add2D.d.ts.map +1 -0
- package/lib-esm/2d/add2D.js +11 -0
- package/lib-esm/2d/add2D.js.map +1 -0
- package/lib-esm/2d/convertTo3DZ.d.ts +11 -0
- package/lib-esm/2d/convertTo3DZ.d.ts.map +1 -0
- package/lib-esm/2d/convertTo3DZ.js +53 -0
- package/lib-esm/2d/convertTo3DZ.js.map +1 -0
- package/lib-esm/2d/generateContourLines.d.ts +8 -0
- package/lib-esm/2d/generateContourLines.d.ts.map +1 -0
- package/lib-esm/2d/generateContourLines.js +160 -0
- package/lib-esm/2d/generateContourLines.js.map +1 -0
- package/lib-esm/complexChromatogram.d.ts +4 -0
- package/lib-esm/complexChromatogram.d.ts.map +1 -0
- package/lib-esm/complexChromatogram.js +43 -0
- package/lib-esm/complexChromatogram.js.map +1 -0
- package/lib-esm/convert.d.ts +147 -0
- package/lib-esm/convert.d.ts.map +1 -0
- package/lib-esm/convert.js +384 -0
- package/lib-esm/convert.js.map +1 -0
- package/lib-esm/convertToFloatArray.d.ts +2 -0
- package/lib-esm/convertToFloatArray.d.ts.map +1 -0
- package/lib-esm/convertToFloatArray.js +8 -0
- package/lib-esm/convertToFloatArray.js.map +1 -0
- package/lib-esm/createTree.d.ts +29 -0
- package/lib-esm/createTree.d.ts.map +1 -0
- package/lib-esm/createTree.js +94 -0
- package/lib-esm/createTree.js.map +1 -0
- package/lib-esm/index.d.ts +3 -0
- package/lib-esm/index.d.ts.map +1 -0
- package/lib-esm/index.js +3 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/parse/fastParseXYData.d.ts +2 -0
- package/lib-esm/parse/fastParseXYData.d.ts.map +1 -0
- package/lib-esm/parse/fastParseXYData.js +189 -0
- package/lib-esm/parse/fastParseXYData.js.map +1 -0
- package/lib-esm/parse/parsePeakTable.d.ts +2 -0
- package/lib-esm/parse/parsePeakTable.d.ts.map +1 -0
- package/lib-esm/parse/parsePeakTable.js +64 -0
- package/lib-esm/parse/parsePeakTable.js.map +1 -0
- package/lib-esm/parse/parseXYA.d.ts +2 -0
- package/lib-esm/parse/parseXYA.d.ts.map +1 -0
- package/lib-esm/parse/parseXYA.js +14 -0
- package/lib-esm/parse/parseXYA.js.map +1 -0
- package/lib-esm/postProcessing.d.ts +2 -0
- package/lib-esm/postProcessing.d.ts.map +1 -0
- package/lib-esm/postProcessing.js +44 -0
- package/lib-esm/postProcessing.js.map +1 -0
- package/lib-esm/postProcessingNMR.d.ts +2 -0
- package/lib-esm/postProcessingNMR.d.ts.map +1 -0
- package/lib-esm/postProcessingNMR.js +91 -0
- package/lib-esm/postProcessingNMR.js.map +1 -0
- package/lib-esm/prepareNtuplesDatatable.d.ts +2 -0
- package/lib-esm/prepareNtuplesDatatable.d.ts.map +1 -0
- package/lib-esm/prepareNtuplesDatatable.js +84 -0
- package/lib-esm/prepareNtuplesDatatable.js.map +1 -0
- package/lib-esm/prepareSpectrum.d.ts +2 -0
- package/lib-esm/prepareSpectrum.d.ts.map +1 -0
- package/lib-esm/prepareSpectrum.js +7 -0
- package/lib-esm/prepareSpectrum.js.map +1 -0
- package/lib-esm/profiling.d.ts +2 -0
- package/lib-esm/profiling.d.ts.map +1 -0
- package/lib-esm/profiling.js +9 -0
- package/lib-esm/profiling.js.map +1 -0
- package/lib-esm/simpleChromatogram.d.ts +2 -0
- package/lib-esm/simpleChromatogram.d.ts.map +1 -0
- package/lib-esm/simpleChromatogram.js +13 -0
- package/lib-esm/simpleChromatogram.js.map +1 -0
- package/package.json +28 -23
- package/src/complexChromatogram.js +1 -1
- package/src/convert.js +92 -37
- package/src/convertToFloatArray.js +1 -1
- package/src/createTree.js +20 -6
- package/src/index.js +2 -2
- package/src/parse/parsePeakTable.js +4 -6
- package/src/parse/parseXYA.js +2 -2
- package/CHANGELOG.md +0 -412
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jcampconverter",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.4",
|
|
4
4
|
"description": "Parse and convert JCAMP data",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "lib-esm/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"lib",
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"lib-esm"
|
|
10
12
|
],
|
|
11
13
|
"prettier": {
|
|
12
14
|
"arrowParens": "always",
|
|
@@ -17,13 +19,20 @@
|
|
|
17
19
|
},
|
|
18
20
|
"scripts": {
|
|
19
21
|
"build": "cheminfo-build --entry src/index.js --root JcampConverter",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
+
"check-types": "tsc --noEmit",
|
|
23
|
+
"clean": "rimraf lib lib-esm",
|
|
22
24
|
"eslint": "eslint src __tests__",
|
|
23
25
|
"eslint-fix": "npm run eslint -- --fix",
|
|
24
|
-
"
|
|
26
|
+
"jscpd": "jscpd -l 10 -i \"**/__tests__/**\" -t 1 src",
|
|
27
|
+
"prepack": "npm run tsc",
|
|
28
|
+
"prettier": "prettier --check src",
|
|
29
|
+
"prettier-write": "prettier --write src",
|
|
30
|
+
"test": "npm run test-coverage && npm run eslint && npm run prettier && npm run check-types",
|
|
25
31
|
"test-coverage": "jest --coverage",
|
|
26
32
|
"test-only": "jest",
|
|
33
|
+
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
|
|
34
|
+
"tsc-cjs": "tsc --project tsconfig.cjs.json",
|
|
35
|
+
"tsc-esm": "tsc --project tsconfig.esm.json",
|
|
27
36
|
"benchmark": "node benchmark/benchmark.js",
|
|
28
37
|
"deopt": "node --trace-opt --trace-deopt --code-comments debug/deoptimize.js > deopt.log",
|
|
29
38
|
"hydra": "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm debug/deoptimize.js"
|
|
@@ -42,29 +51,25 @@
|
|
|
42
51
|
"url": "https://github.com/cheminfo/jcampconverter/issues"
|
|
43
52
|
},
|
|
44
53
|
"homepage": "https://github.com/cheminfo/jcampconverter#readme",
|
|
45
|
-
"jest": {
|
|
46
|
-
"testEnvironment": "node"
|
|
47
|
-
},
|
|
48
54
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@types/jest": "^27.0.1",
|
|
55
|
+
"@types/jest": "^27.0.3",
|
|
51
56
|
"benchmark": "^2.1.4",
|
|
52
57
|
"cheminfo-build": "^1.1.11",
|
|
53
|
-
"eslint": "^
|
|
54
|
-
"eslint-config-cheminfo": "^
|
|
55
|
-
"eslint-plugin-import": "^2.24.2",
|
|
56
|
-
"eslint-plugin-jest": "^24.4.0",
|
|
57
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
58
|
+
"eslint": "^8.4.1",
|
|
59
|
+
"eslint-config-cheminfo-typescript": "^10.2.4",
|
|
58
60
|
"esm": "^3.2.25",
|
|
59
|
-
"jest": "^27.
|
|
60
|
-
"jest-matcher-deep-close-to": "^
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"jest": "^27.4.5",
|
|
62
|
+
"jest-matcher-deep-close-to": "^3.0.2",
|
|
63
|
+
"jscpd": "^3.4.2",
|
|
64
|
+
"prettier": "^2.5.1",
|
|
65
|
+
"rimraf": "^3.0.2",
|
|
66
|
+
"ts-jest": "^27.1.1",
|
|
67
|
+
"typescript": "^4.5.4"
|
|
63
68
|
},
|
|
64
69
|
"dependencies": {
|
|
65
|
-
"dynamic-typing": "^0.1.
|
|
66
|
-
"ensure-string": "^1.
|
|
70
|
+
"dynamic-typing": "^0.1.3",
|
|
71
|
+
"ensure-string": "^1.1.0",
|
|
67
72
|
"ml-array-median": "^1.1.5",
|
|
68
|
-
"nmr-processing": "^
|
|
73
|
+
"nmr-processing": "^6.0.2"
|
|
69
74
|
}
|
|
70
75
|
}
|
|
@@ -29,7 +29,7 @@ export function complexChromatogram(result) {
|
|
|
29
29
|
let spectrum = spectra[i];
|
|
30
30
|
chromatogram.times[i] = spectrum.pageValue;
|
|
31
31
|
for (let j = 0; j < existingGCMSFields.length; j++) {
|
|
32
|
-
chromatogram.series[existingGCMSFields[j]].data[i] =
|
|
32
|
+
chromatogram.series[existingGCMSFields[j]].data[i] = Number(
|
|
33
33
|
spectrum[existingGCMSFields[j]],
|
|
34
34
|
);
|
|
35
35
|
}
|
package/src/convert.js
CHANGED
|
@@ -14,8 +14,6 @@ import profiling from './profiling';
|
|
|
14
14
|
// the following RegExp can only be used for XYdata, some peakTables have values with a "E-5" ...
|
|
15
15
|
const ntuplesSeparatorRegExp = /[ \t]*,[ \t]*/;
|
|
16
16
|
|
|
17
|
-
class Spectrum {}
|
|
18
|
-
|
|
19
17
|
const defaultOptions = {
|
|
20
18
|
keepRecordsRegExp: /^$/,
|
|
21
19
|
canonicDataLabels: true,
|
|
@@ -32,22 +30,79 @@ const defaultOptions = {
|
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
*
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
46
|
-
* @
|
|
47
|
-
|
|
33
|
+
* @typedef {object} ConvertOptions
|
|
34
|
+
* @property {RegExp} [options.keepRecordsRegExp=/^$/] - By default we don't keep meta information.
|
|
35
|
+
* @property {boolean} [options.canonicDataLabels=true] - Canonize the Labels (uppercase without symbol).
|
|
36
|
+
* @property {boolean} [options.canonicMetadataLabels=false] - Canonize the metadata Labels (uppercase without symbol).
|
|
37
|
+
* @property {boolean} [options.dynamicTyping=false] - Convert numbers to Number.
|
|
38
|
+
* @property {boolean} [options.withoutXY=false] - Remove the XY data.
|
|
39
|
+
* @property {boolean} [options.chromatogram=false] - Special post-processing for GC / HPLC / MS.
|
|
40
|
+
* @property {boolean} [options.keepSpectra=false] - Force to keep the spectra in case of 2D.
|
|
41
|
+
* @property {boolean} [options.noContour=false] - Don't calculate countour in case of 2D.
|
|
42
|
+
* @property {number} [options.nbContourLevels=7] - Number of positive / negative contour levels to calculate.
|
|
43
|
+
* @property {number} [options.noiseMultiplier=5] - Define for 2D the level as 5 times the median as default.
|
|
44
|
+
* @property {boolean} [options.profiling=false] - Add profiling information.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @typedef {object} Ntuples
|
|
50
|
+
* @property {string[]} [varname]
|
|
51
|
+
* @property {string[]} [symbol]
|
|
52
|
+
* @property {string[]} [vartype]
|
|
53
|
+
* @property {string[]} [varform]
|
|
54
|
+
* @property {number[]} [vardim]
|
|
55
|
+
* @property {string[]} [units]
|
|
56
|
+
* @property {number[]} [factor]
|
|
57
|
+
* @property {number[]} [first]
|
|
58
|
+
* @property {number[]} [last]
|
|
59
|
+
* @property {number[]} [min]
|
|
60
|
+
* @property {number[]} [max]
|
|
61
|
+
* @property {string[]} [nucleus]
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @typedef { Record<string, any> } Spectrum
|
|
66
|
+
* @property {Record<string, number[]>} [data]
|
|
67
|
+
* @property {number} [firstX]
|
|
68
|
+
* @property {number} [lastX]
|
|
69
|
+
* @property {number} [deltaX]
|
|
70
|
+
* @property {number} [yFactor]
|
|
71
|
+
* @property {number} [xFactor]
|
|
72
|
+
* @property {number} [nbPoints]
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @typedef {object} Entry
|
|
78
|
+
* @property {Spectrum[]} spectra
|
|
79
|
+
* @property {Ntuples} ntuples
|
|
80
|
+
* @property {object} meta
|
|
81
|
+
* @property {object} tmp
|
|
82
|
+
* @property {string} [title]
|
|
83
|
+
* @property {string} [dataType]
|
|
84
|
+
* @property {string} [dataClass]
|
|
85
|
+
* @property {boolean} [twoD]
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @typedef { object } ConvertResult
|
|
91
|
+
* @property { object[] | boolean } profiling
|
|
92
|
+
* @property { string[] } logs
|
|
93
|
+
* @property { object[] } entries
|
|
94
|
+
* @property { Entry[] } flatten
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parse a jcamp.
|
|
99
|
+
*
|
|
100
|
+
* @param {string|ArrayBuffer|Uint8Array} jcamp
|
|
101
|
+
* @param {ConvertOptions} [options]
|
|
102
|
+
* @returns {ConvertResult}
|
|
48
103
|
*/
|
|
49
104
|
|
|
50
|
-
export
|
|
105
|
+
export function convert(jcamp, options = {}) {
|
|
51
106
|
jcamp = ensureString(jcamp);
|
|
52
107
|
options = { ...defaultOptions, ...options };
|
|
53
108
|
options.wantXY = !options.withoutXY;
|
|
@@ -65,7 +120,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
65
120
|
let currentEntry = tmpResult;
|
|
66
121
|
let parentsStack = [];
|
|
67
122
|
|
|
68
|
-
let spectrum =
|
|
123
|
+
let spectrum = {};
|
|
69
124
|
|
|
70
125
|
if (typeof jcamp !== 'string') {
|
|
71
126
|
throw new TypeError('the JCAMP should be a string');
|
|
@@ -125,7 +180,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
125
180
|
parsePeakTable(spectrum, dataValue, result);
|
|
126
181
|
}
|
|
127
182
|
currentEntry.spectra.push(spectrum);
|
|
128
|
-
spectrum =
|
|
183
|
+
spectrum = {};
|
|
129
184
|
}
|
|
130
185
|
continue;
|
|
131
186
|
} else if (canonicDataLabel === 'PEAKTABLE') {
|
|
@@ -133,7 +188,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
133
188
|
prepareSpectrum(spectrum);
|
|
134
189
|
parsePeakTable(spectrum, dataValue, result);
|
|
135
190
|
currentEntry.spectra.push(spectrum);
|
|
136
|
-
spectrum =
|
|
191
|
+
spectrum = {};
|
|
137
192
|
}
|
|
138
193
|
continue;
|
|
139
194
|
}
|
|
@@ -144,7 +199,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
144
199
|
parseXYA(spectrum, dataValue);
|
|
145
200
|
}
|
|
146
201
|
currentEntry.spectra.push(spectrum);
|
|
147
|
-
spectrum =
|
|
202
|
+
spectrum = {};
|
|
148
203
|
}
|
|
149
204
|
continue;
|
|
150
205
|
}
|
|
@@ -181,35 +236,35 @@ export default function convert(jcamp, options = {}) {
|
|
|
181
236
|
} else if (canonicDataLabel === 'YUNITS') {
|
|
182
237
|
spectrum.yUnits = dataValue;
|
|
183
238
|
} else if (canonicDataLabel === 'FIRSTX') {
|
|
184
|
-
spectrum.firstX =
|
|
239
|
+
spectrum.firstX = Number(dataValue);
|
|
185
240
|
} else if (canonicDataLabel === 'LASTX') {
|
|
186
|
-
spectrum.lastX =
|
|
241
|
+
spectrum.lastX = Number(dataValue);
|
|
187
242
|
} else if (canonicDataLabel === 'FIRSTY') {
|
|
188
|
-
spectrum.firstY =
|
|
243
|
+
spectrum.firstY = Number(dataValue);
|
|
189
244
|
} else if (canonicDataLabel === 'LASTY') {
|
|
190
|
-
spectrum.lastY =
|
|
245
|
+
spectrum.lastY = Number(dataValue);
|
|
191
246
|
} else if (canonicDataLabel === 'NPOINTS') {
|
|
192
|
-
spectrum.nbPoints =
|
|
247
|
+
spectrum.nbPoints = Number(dataValue);
|
|
193
248
|
} else if (canonicDataLabel === 'XFACTOR') {
|
|
194
|
-
spectrum.xFactor =
|
|
249
|
+
spectrum.xFactor = Number(dataValue);
|
|
195
250
|
} else if (canonicDataLabel === 'YFACTOR') {
|
|
196
|
-
spectrum.yFactor =
|
|
251
|
+
spectrum.yFactor = Number(dataValue);
|
|
197
252
|
} else if (canonicDataLabel === 'MAXX') {
|
|
198
|
-
spectrum.maxX =
|
|
253
|
+
spectrum.maxX = Number(dataValue);
|
|
199
254
|
} else if (canonicDataLabel === 'MINX') {
|
|
200
|
-
spectrum.minX =
|
|
255
|
+
spectrum.minX = Number(dataValue);
|
|
201
256
|
} else if (canonicDataLabel === 'MAXY') {
|
|
202
|
-
spectrum.maxY =
|
|
257
|
+
spectrum.maxY = Number(dataValue);
|
|
203
258
|
} else if (canonicDataLabel === 'MINY') {
|
|
204
|
-
spectrum.minY =
|
|
259
|
+
spectrum.minY = Number(dataValue);
|
|
205
260
|
} else if (canonicDataLabel === 'DELTAX') {
|
|
206
|
-
spectrum.deltaX =
|
|
261
|
+
spectrum.deltaX = Number(dataValue);
|
|
207
262
|
} else if (
|
|
208
263
|
canonicDataLabel === '.OBSERVEFREQUENCY' ||
|
|
209
264
|
canonicDataLabel === '$SFO1'
|
|
210
265
|
) {
|
|
211
266
|
if (!spectrum.observeFrequency) {
|
|
212
|
-
spectrum.observeFrequency =
|
|
267
|
+
spectrum.observeFrequency = Number(dataValue);
|
|
213
268
|
}
|
|
214
269
|
} else if (canonicDataLabel === '.OBSERVENUCLEUS') {
|
|
215
270
|
if (!spectrum.xType) {
|
|
@@ -219,7 +274,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
219
274
|
// OFFSET for Bruker spectra
|
|
220
275
|
currentEntry.shiftOffsetNum = 0;
|
|
221
276
|
if (!spectrum.shiftOffsetVal) {
|
|
222
|
-
spectrum.shiftOffsetVal =
|
|
277
|
+
spectrum.shiftOffsetVal = Number(dataValue);
|
|
223
278
|
}
|
|
224
279
|
} else if (canonicDataLabel === '$REFERENCEPOINT') {
|
|
225
280
|
// OFFSET for Varian spectra
|
|
@@ -227,7 +282,7 @@ export default function convert(jcamp, options = {}) {
|
|
|
227
282
|
// } else if (canonicDataLabel=='.SHIFTREFERENCE') { // OFFSET FOR Bruker Spectra
|
|
228
283
|
// var parts = dataValue.split(/ *, */);
|
|
229
284
|
// currentEntry.shiftOffsetNum = parseInt(parts[2].trim());
|
|
230
|
-
// spectrum.shiftOffsetVal =
|
|
285
|
+
// spectrum.shiftOffsetVal = Number(parts[3].trim());
|
|
231
286
|
} else if (canonicDataLabel === 'VARNAME') {
|
|
232
287
|
currentEntry.ntuples.varname = dataValue.split(ntuplesSeparatorRegExp);
|
|
233
288
|
} else if (canonicDataLabel === 'SYMBOL') {
|
|
@@ -268,10 +323,10 @@ export default function convert(jcamp, options = {}) {
|
|
|
268
323
|
}
|
|
269
324
|
} else if (canonicDataLabel === 'PAGE') {
|
|
270
325
|
spectrum.page = dataValue.trim();
|
|
271
|
-
spectrum.pageValue =
|
|
326
|
+
spectrum.pageValue = Number(dataValue.replace(/^.*=/, ''));
|
|
272
327
|
spectrum.pageSymbol = spectrum.page.replace(/[=].*/, '');
|
|
273
328
|
} else if (canonicDataLabel === 'RETENTIONTIME') {
|
|
274
|
-
spectrum.pageValue =
|
|
329
|
+
spectrum.pageValue = Number(dataValue);
|
|
275
330
|
} else if (isMSField(canonicDataLabel)) {
|
|
276
331
|
spectrum[convertMSFieldToLabel(canonicDataLabel)] = dataValue;
|
|
277
332
|
} else if (canonicDataLabel === 'SAMPLEDESCRIPTION') {
|
package/src/createTree.js
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { ensureString } from 'ensure-string';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
* @param {boolean} [options.flatten=false]
|
|
8
|
-
* @returns
|
|
4
|
+
*
|
|
5
|
+
* @typedef {object} CreateTreeOptions
|
|
6
|
+
* @property {boolean} [flatten=false]
|
|
9
7
|
*/
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @typedef {object} Tree
|
|
12
|
+
* @property {string} title
|
|
13
|
+
* @property {string} jcamp
|
|
14
|
+
* @property {Tree[]} [children]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parse the jcamp to extract the structure as a tree.
|
|
19
|
+
*
|
|
20
|
+
* @param {string|ArrayBuffer|Uint8Array} jcamp
|
|
21
|
+
* @param {CreateTreeOptions} [options={}]
|
|
22
|
+
* @returns {Tree[]}
|
|
23
|
+
*/
|
|
24
|
+
export function createTree(jcamp, options = {}) {
|
|
11
25
|
jcamp = ensureString(jcamp);
|
|
12
26
|
const { flatten = false } = options;
|
|
13
27
|
if (typeof jcamp !== 'string') {
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { createTree } from './createTree';
|
|
2
|
+
export { convert } from './convert';
|
|
@@ -32,9 +32,9 @@ function parseXY(spectrum, value, result) {
|
|
|
32
32
|
.split(peakTableSplitRegExp);
|
|
33
33
|
if (values.length % 2 === 0) {
|
|
34
34
|
for (let j = 0; j < values.length; j = j + 2) {
|
|
35
|
-
// takes around 40% of the time to add and parse the 2 values nearly exclusively because of
|
|
36
|
-
currentData.x.push(
|
|
37
|
-
currentData.y.push(
|
|
35
|
+
// takes around 40% of the time to add and parse the 2 values nearly exclusively because of Number
|
|
36
|
+
currentData.x.push(Number(values[j]) * spectrum.xFactor);
|
|
37
|
+
currentData.y.push(Number(values[j + 1]) * spectrum.yFactor);
|
|
38
38
|
}
|
|
39
39
|
} else {
|
|
40
40
|
result.logs.push(`Format error: ${values}`);
|
|
@@ -60,9 +60,7 @@ function parseXYZ(spectrum, value, result) {
|
|
|
60
60
|
if (values.length % numberOfVariables === 0) {
|
|
61
61
|
for (let j = 0; j < values.length; j++) {
|
|
62
62
|
// todo should try to find a xFactor (y, ...)
|
|
63
|
-
currentData[variables[j % numberOfVariables]].push(
|
|
64
|
-
parseFloat(values[j]),
|
|
65
|
-
);
|
|
63
|
+
currentData[variables[j % numberOfVariables]].push(Number(values[j]));
|
|
66
64
|
}
|
|
67
65
|
} else {
|
|
68
66
|
result.logs.push(`Format error: ${values}`);
|
package/src/parse/parseXYA.js
CHANGED
|
@@ -10,7 +10,7 @@ export default function parseXYA(spectrum, value) {
|
|
|
10
10
|
|
|
11
11
|
for (let i = 1; i < lines.length; i++) {
|
|
12
12
|
values = lines[i].trim().replace(removeSymbolRegExp, '').split(',');
|
|
13
|
-
currentData.x.push(
|
|
14
|
-
currentData.y.push(
|
|
13
|
+
currentData.x.push(Number(values[0]));
|
|
14
|
+
currentData.y.push(Number(values[1]));
|
|
15
15
|
}
|
|
16
16
|
}
|