jcampconverter
Advanced tools
Comparing version 9.0.2 to 9.0.3
@@ -179,3 +179,3 @@ import { parseString } from 'dynamic-typing'; | ||
if (options.wantXY) { | ||
if (dataValue.match(/.*(XYA).*/)) { | ||
if (dataValue.match(/.*([^A-Z]*).*/)) { | ||
// ex: (XYA) | ||
@@ -182,0 +182,0 @@ parseXYA(spectrum, dataValue); |
@@ -0,14 +1,48 @@ | ||
/* | ||
(5.4.4) ##РЕАК ASSIGNMENTS= (STRING). List | ||
of peak assignments for components or functional groups | ||
in the forms ##РЕАК ASSIGNMENTS= (ХУА), | ||
(XYW А), (ХУМА), (XYMW А). Each entry is surrounded Ьу parentheses and starts а new line. У, W (peak | ||
width), and М (multiplicity) values are optional. The | ||
symbol А stands for а string detailing the assignment | ||
and must Ье enclosed Ьу angle brackets. If the peak width | ||
value is included, then the function used to calculate the | ||
peak width must Ье detailed in а $$ comment on the | ||
line(s) below ##PEAKASSIGNMENTS=. Priority OPTIONAL. N.B.: ##РЕАК ASSIGNMENTS= is the preferred method of transmitting peak information when | ||
the assignments are known. | ||
*/ | ||
export default function parseXYA(spectrum, value) { | ||
let removeSymbolRegExp = /(\(+|\)+|<+|>+|\s+)/g; | ||
spectrum.isXYAdata = true; | ||
let values; | ||
let currentData = { x: [], y: [] }; | ||
const currentData = {}; | ||
spectrum.data = currentData; | ||
let lines = value.split(/,? *,?[;\r\n]+ */); | ||
let lines = value.split(/\r?\n/); | ||
const variables = lines[0] | ||
.replace(/^.*?([A-Z]+).*$/, '$1') | ||
.split('') | ||
.map((variable) => variable.toLowerCase()); | ||
for (let i = 1; i < lines.length; i++) { | ||
values = lines[i].trim().replace(removeSymbolRegExp, '').split(','); | ||
currentData.x.push(Number(values[0])); | ||
currentData.y.push(Number(values[1])); | ||
const fields = lines[i].replace(/^\((.*)\)$/, '$1').split(/ *, */); | ||
for (let j = 0; j < variables.length; j++) { | ||
let value = fields[j]; | ||
switch (variables[j]) { | ||
case 'x': | ||
case 'y': | ||
case 'w': | ||
value = Number.parseFloat(value); | ||
break; | ||
case 'a': | ||
value = value.replace(/^<(.*)>$/, '$1'); | ||
break; | ||
case 'm': | ||
break; | ||
default: | ||
continue; | ||
} | ||
if (!currentData[variables[j]]) { | ||
currentData[variables[j]] = []; | ||
} | ||
currentData[variables[j]].push(value); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=parseXYA.js.map |
@@ -185,3 +185,3 @@ "use strict"; | ||
if (options.wantXY) { | ||
if (dataValue.match(/.*(XYA).*/)) { | ||
if (dataValue.match(/.*([^A-Z]*).*/)) { | ||
// ex: (XYA) | ||
@@ -188,0 +188,0 @@ (0, parseXYA_1.default)(spectrum, dataValue); |
"use strict"; | ||
/* | ||
(5.4.4) ##РЕАК ASSIGNMENTS= (STRING). List | ||
of peak assignments for components or functional groups | ||
in the forms ##РЕАК ASSIGNMENTS= (ХУА), | ||
(XYW А), (ХУМА), (XYMW А). Each entry is surrounded Ьу parentheses and starts а new line. У, W (peak | ||
width), and М (multiplicity) values are optional. The | ||
symbol А stands for а string detailing the assignment | ||
and must Ье enclosed Ьу angle brackets. If the peak width | ||
value is included, then the function used to calculate the | ||
peak width must Ье detailed in а $$ comment on the | ||
line(s) below ##PEAKASSIGNMENTS=. Priority OPTIONAL. N.B.: ##РЕАК ASSIGNMENTS= is the preferred method of transmitting peak information when | ||
the assignments are known. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function parseXYA(spectrum, value) { | ||
let removeSymbolRegExp = /(\(+|\)+|<+|>+|\s+)/g; | ||
spectrum.isXYAdata = true; | ||
let values; | ||
let currentData = { x: [], y: [] }; | ||
const currentData = {}; | ||
spectrum.data = currentData; | ||
let lines = value.split(/,? *,?[;\r\n]+ */); | ||
let lines = value.split(/\r?\n/); | ||
const variables = lines[0] | ||
.replace(/^.*?([A-Z]+).*$/, '$1') | ||
.split('') | ||
.map((variable) => variable.toLowerCase()); | ||
for (let i = 1; i < lines.length; i++) { | ||
values = lines[i].trim().replace(removeSymbolRegExp, '').split(','); | ||
currentData.x.push(Number(values[0])); | ||
currentData.y.push(Number(values[1])); | ||
const fields = lines[i].replace(/^\((.*)\)$/, '$1').split(/ *, */); | ||
for (let j = 0; j < variables.length; j++) { | ||
let value = fields[j]; | ||
switch (variables[j]) { | ||
case 'x': | ||
case 'y': | ||
case 'w': | ||
value = Number.parseFloat(value); | ||
break; | ||
case 'a': | ||
value = value.replace(/^<(.*)>$/, '$1'); | ||
break; | ||
case 'm': | ||
break; | ||
default: | ||
continue; | ||
} | ||
if (!currentData[variables[j]]) { | ||
currentData[variables[j]] = []; | ||
} | ||
currentData[variables[j]].push(value); | ||
} | ||
} | ||
@@ -15,0 +49,0 @@ } |
{ | ||
"name": "jcampconverter", | ||
"version": "9.0.2", | ||
"version": "9.0.3", | ||
"description": "Parse and convert JCAMP data", | ||
@@ -47,22 +47,24 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^28.1.1", | ||
"@types/jest": "^29.1.1", | ||
"@vitest/coverage-c8": "^0.23.4", | ||
"benchmark": "^2.1.4", | ||
"c8": "^7.11.3", | ||
"c8": "^7.12.0", | ||
"cheminfo-build": "^1.1.11", | ||
"eslint": "^8.17.0", | ||
"eslint-config-cheminfo-typescript": "^11.0.1", | ||
"eslint": "^8.24.0", | ||
"eslint-config-cheminfo-typescript": "^11.1.0", | ||
"esm": "^3.2.25", | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"jscpd": "^3.4.5", | ||
"prettier": "^2.6.2", | ||
"jscpd": "^3.5.0", | ||
"prettier": "^2.7.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.7.3", | ||
"vitest": "^0.14.1" | ||
"typescript": "^4.8.4", | ||
"vitest": "^0.23.4" | ||
}, | ||
"dependencies": { | ||
"dynamic-typing": "^0.1.3", | ||
"dynamic-typing": "^1.0.0", | ||
"ensure-string": "^1.2.0", | ||
"gyromagnetic-ratio": "^1.0.0", | ||
"ml-array-median": "^1.1.6" | ||
"ml-array-median": "^1.1.6", | ||
"ml-spectra-processing": "^11.12.0" | ||
} | ||
} |
@@ -99,5 +99,5 @@ # JCAMP converter | ||
[codecov-url]: https://codecov.io/gh/cheminfo/jcampconverter | ||
[ci-image]: https://github.com/cheminfo/jcampconverter/workflows/Node.js%20CI/badge.svg?branch=master | ||
[ci-image]: https://github.com/cheminfo/jcampconverter/workflows/Node.js%20CI/badge.svg?branch=main | ||
[ci-url]: https://github.com/cheminfo/jcampconverter/actions?query=workflow%3A%22Node.js+CI%22 | ||
[download-image]: https://img.shields.io/npm/dm/jcampconverter.svg | ||
[download-url]: https://npmjs.org/package/jcampconverter |
@@ -202,3 +202,3 @@ import { parseString } from 'dynamic-typing'; | ||
if (options.wantXY) { | ||
if (dataValue.match(/.*(XYA).*/)) { | ||
if (dataValue.match(/.*([^A-Z]*).*/)) { | ||
// ex: (XYA) | ||
@@ -205,0 +205,0 @@ parseXYA(spectrum, dataValue); |
@@ -0,16 +1,50 @@ | ||
/* | ||
(5.4.4) ##РЕАК ASSIGNMENTS= (STRING). List | ||
of peak assignments for components or functional groups | ||
in the forms ##РЕАК ASSIGNMENTS= (ХУА), | ||
(XYW А), (ХУМА), (XYMW А). Each entry is surrounded Ьу parentheses and starts а new line. У, W (peak | ||
width), and М (multiplicity) values are optional. The | ||
symbol А stands for а string detailing the assignment | ||
and must Ье enclosed Ьу angle brackets. If the peak width | ||
value is included, then the function used to calculate the | ||
peak width must Ье detailed in а $$ comment on the | ||
line(s) below ##PEAKASSIGNMENTS=. Priority OPTIONAL. N.B.: ##РЕАК ASSIGNMENTS= is the preferred method of transmitting peak information when | ||
the assignments are known. | ||
*/ | ||
export default function parseXYA(spectrum, value) { | ||
let removeSymbolRegExp = /(\(+|\)+|<+|>+|\s+)/g; | ||
spectrum.isXYAdata = true; | ||
let values; | ||
let currentData = { x: [], y: [] }; | ||
const currentData = {}; | ||
spectrum.data = currentData; | ||
let lines = value.split(/,? *,?[;\r\n]+ */); | ||
let lines = value.split(/\r?\n/); | ||
const variables = lines[0] | ||
.replace(/^.*?([A-Z]+).*$/, '$1') | ||
.split('') | ||
.map((variable) => variable.toLowerCase()); | ||
for (let i = 1; i < lines.length; i++) { | ||
values = lines[i].trim().replace(removeSymbolRegExp, '').split(','); | ||
currentData.x.push(Number(values[0])); | ||
currentData.y.push(Number(values[1])); | ||
const fields = lines[i].replace(/^\((.*)\)$/, '$1').split(/ *, */); | ||
for (let j = 0; j < variables.length; j++) { | ||
let value = fields[j]; | ||
switch (variables[j]) { | ||
case 'x': | ||
case 'y': | ||
case 'w': | ||
value = Number.parseFloat(value); | ||
break; | ||
case 'a': | ||
value = value.replace(/^<(.*)>$/, '$1'); | ||
break; | ||
case 'm': | ||
break; | ||
default: | ||
continue; | ||
} | ||
if (!currentData[variables[j]]) { | ||
currentData[variables[j]] = []; | ||
} | ||
currentData[variables[j]].push(value); | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
259563
4307
5
14
+ Addedbinary-search@1.3.6(transitive)
+ Addedd3-array@0.7.1(transitive)
+ Addeddynamic-typing@1.0.1(transitive)
+ Addedfft.js@4.0.4(transitive)
+ Addedml-array-max@1.2.4(transitive)
+ Addedml-array-min@1.2.3(transitive)
+ Addedml-array-rescale@1.3.7(transitive)
+ Addedml-matrix@6.12.0(transitive)
+ Addedml-spectra-processing@11.17.0(transitive)
+ Addedml-xsadd@2.0.0(transitive)
+ Addedspline-interpolator@1.0.0(transitive)
- Removeddynamic-typing@0.1.3(transitive)
Updateddynamic-typing@^1.0.0