brukerconverter
Advanced tools
Comparing version
@@ -79,3 +79,3 @@ 'use strict'; | ||
processedData.fileCollectionItems.push(file); // check if it can be moved into the conditional block | ||
if (file.name.match(/^(1r|1i|2rr|procs|proc2s)$/)) { | ||
if (file.name.match(/^(1r|1i|2rr|procs|proc2s|integrals.txt)$/)) { | ||
processedData[file.name] = file; | ||
@@ -175,2 +175,3 @@ } | ||
experimentsArray.push({ | ||
integrals: oneProcessed['integrals.txt'], | ||
acqus: experiment.acqus, | ||
@@ -190,3 +191,2 @@ acqu2s: experiment.acqu2s, | ||
} | ||
return experimentsArray; | ||
@@ -217,2 +217,43 @@ } | ||
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) { | ||
@@ -406,2 +447,3 @@ for (let key in toAppend.meta) { | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files.integrals) await addIntegrals(result, files); | ||
@@ -408,0 +450,0 @@ if (files['1r'] || files['1i']) { |
{ | ||
"name": "brukerconverter", | ||
"version": "6.1.4", | ||
"version": "6.1.5-pre.1691494258", | ||
"description": "Parse and convert Bruker raw data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -126,1 +126,26 @@ import { join } from 'path'; | ||
}); | ||
test('integrals.txt parsing', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = await convertFileCollection(fileCollection); | ||
expect(results).toHaveLength(2); | ||
const pdata = results.find((result) => 'integrals' in result); | ||
expect(pdata).toBeDefined(); | ||
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, | ||
}, | ||
]), | ||
}), | ||
); | ||
}); |
@@ -8,2 +8,12 @@ import { join } from 'path'; | ||
test('integrals.txt parsing', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection); | ||
expect(results).toHaveLength(2); | ||
const pdata = results.find((result) => 'integrals' in result); | ||
expect(pdata).toBeDefined(); | ||
}); | ||
test('groupByExperiment without expno', async () => { | ||
@@ -10,0 +20,0 @@ const fileCollection = await fileCollectionFromPath( |
@@ -71,3 +71,3 @@ /** | ||
processedData.fileCollectionItems.push(file); // check if it can be moved into the conditional block | ||
if (file.name.match(/^(1r|1i|2rr|procs|proc2s)$/)) { | ||
if (file.name.match(/^(1r|1i|2rr|procs|proc2s|integrals.txt)$/)) { | ||
processedData[file.name] = file; | ||
@@ -167,2 +167,3 @@ } | ||
experimentsArray.push({ | ||
integrals: oneProcessed['integrals.txt'], | ||
acqus: experiment.acqus, | ||
@@ -182,3 +183,2 @@ acqu2s: experiment.acqu2s, | ||
} | ||
return experimentsArray; | ||
@@ -185,0 +185,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { addIntegrals } from './addIntegrals.js'; | ||
import { joinInfoMeta } from './joinMetaInfo.js'; | ||
@@ -12,2 +13,3 @@ import { parseData } from './parseData'; | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files.integrals) await addIntegrals(result, files); | ||
@@ -14,0 +16,0 @@ if (files['1r'] || files['1i']) { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1729247
0.22%49
4.26%1907
6.24%2
100%