brukerconverter
Advanced tools
Comparing version 6.1.5-pre.1691494258 to 6.2.0
@@ -214,43 +214,2 @@ 'use strict'; | ||
async function addIntegrals(result, files) { | ||
const integralFile = files.integrals; | ||
let text = await integralFile.text(); | ||
text = text.split(/\n/); | ||
const info = text[1] | ||
.replace(/^\s*/, '') | ||
.replace(/(?<=\w)[\t]+/g, ';') | ||
.replace(/(?<==)[\t\s]*/g, '') | ||
.match( | ||
/(?<name>(?<=[NAME] =)[\w\d]*);EXPNO =(?<expno>[\d]*);PROCNO =(?<procno>[\d]*)/, | ||
); | ||
const { expno, procno, name } = info?.groups || {}; | ||
const directory = text[2].replace(/\s*DU\s*=\t*([\w/.\d]+)/, '$1'); | ||
const integrals = []; | ||
const integralData = text.slice(3).filter((t) => t); | ||
for (let i = 1; i < integralData.length; i++) { | ||
const data = integralData[i] | ||
.replace(/^\s*/, '') | ||
.replace(/[\s\t]+/g, ';') | ||
.match(/\d+;(?<from>[0-9.]+);(?<to>[0-9.]+);(?<integration>[0-9.]+)/); | ||
if (data) { | ||
const { from, to, integration } = data.groups; | ||
integrals.push({ | ||
from: parseFloat(from), | ||
to: parseFloat(to), | ||
integration: parseFloat(integration), | ||
}); | ||
} | ||
} | ||
result.integrals = { | ||
directory, | ||
name, | ||
expno: Number(expno), | ||
procno: Number(procno), | ||
integrals, | ||
}; | ||
} | ||
function joinInfoMeta(target, toAppend) { | ||
@@ -294,2 +253,27 @@ for (let key in toAppend.meta) { | ||
async function parseIntegrals(files) { | ||
const integralData = (await files.integrals.text()) | ||
.split(/\r?\n/) | ||
.slice(3) | ||
.filter((t) => t); | ||
const integrals = []; | ||
for (let i = 1; i < integralData.length; i++) { | ||
const data = integralData[i] | ||
.replace(/^\s*/, '') | ||
.replace(/[\s\t]+/g, ';') | ||
.match(/\d+;(?<from>[0-9.]+);(?<to>[0-9.]+);(?<integration>[0-9.]+)/); | ||
if (data) { | ||
const { from, to, integration } = data.groups; | ||
integrals.push({ | ||
from: parseFloat(from), | ||
to: parseFloat(to), | ||
integration: parseFloat(integration), | ||
}); | ||
} | ||
} | ||
return integrals; | ||
} | ||
const QSEQ = 2; | ||
@@ -445,3 +429,3 @@ | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files.integrals) await addIntegrals(result, files); | ||
if (files.integrals) result.integrals = await parseIntegrals(files); | ||
@@ -448,0 +432,0 @@ if (files['1r'] || files['1i']) { |
{ | ||
"name": "brukerconverter", | ||
"version": "6.1.5-pre.1691494258", | ||
"version": "6.2.0", | ||
"description": "Parse and convert Bruker raw data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -136,16 +136,10 @@ import { join } from 'path'; | ||
expect(pdata.integrals).toEqual( | ||
expect.objectContaining({ | ||
directory: '/opt/topspin4.3.0/examdata', | ||
name: 'exam_CMCse_1', | ||
procno: 1, | ||
expno: 10, | ||
integrals: expect.arrayContaining([ | ||
{ | ||
from: 6.633, | ||
to: 6.56, | ||
integration: 1, | ||
}, | ||
]), | ||
}), | ||
expect.arrayContaining([ | ||
{ | ||
from: 6.633, | ||
to: 6.56, | ||
integration: 1, | ||
}, | ||
]), | ||
); | ||
}); |
@@ -1,4 +0,4 @@ | ||
import { addIntegrals } from './addIntegrals.js'; | ||
import { joinInfoMeta } from './joinMetaInfo.js'; | ||
import { parseData } from './parseData'; | ||
import { parseIntegrals } from './parseIntegrals.js'; | ||
import { setFIDSpectrumData } from './setFIDSpectrumData'; | ||
@@ -13,3 +13,3 @@ import { setProcessedSpectrumData } from './setProcessedSpectrumData'; | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files.integrals) await addIntegrals(result, files); | ||
if (files.integrals) result.integrals = await parseIntegrals(files); | ||
@@ -16,0 +16,0 @@ if (files['1r'] || files['1i']) { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
1728074
1871