brukerconverter
Advanced tools
Comparing version 6.0.9 to 6.0.10-pre.1678714014
@@ -29,4 +29,4 @@ 'use strict'; | ||
} = options; | ||
const experiments = {}; | ||
const fileList = fileCollection.files.map((file) => file.relativePath); | ||
for (let file of fileCollection) { | ||
@@ -38,2 +38,3 @@ let procno; | ||
let id; | ||
// console.log(file.name); | ||
const parts = file.relativePath.split('/'); | ||
@@ -47,3 +48,3 @@ if (file.relativePath.match(/\/pdata\/\d+\//)) { | ||
id = parts.slice(0, -3).join('/'); | ||
} else if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) { | ||
} else if (isRawOrAcquisitionFile(file, fileList)) { | ||
const firstLevel = parts.indexOf(file.name); | ||
@@ -107,2 +108,6 @@ expno = Number(parts[firstLevel - 1]); | ||
} | ||
if (file.name === 'QuantFactorSample.xml') { | ||
experiment.quantFactorSample = file; | ||
} | ||
} | ||
@@ -196,2 +201,10 @@ if (processingNumbers) { | ||
function isRawOrAcquisitionFile(file, fileList) { | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s|QuantFactorSample.xml)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
); | ||
} | ||
function joinInfoMeta(target, toAppend) { | ||
@@ -384,2 +397,4 @@ for (let key in toAppend.meta) { | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files['1r'] || files['1i']) { | ||
@@ -400,2 +415,11 @@ await setProcessedSpectrumData( | ||
async function addEreticFactor(result, files) { | ||
const quantFactorSample = (await files.quantFactorSample.text()).match( | ||
/<Application[\w\W]+<Eretic_Factor>(?<ereticFactor>[\d.]+)/, | ||
); | ||
if (quantFactorSample) { | ||
result.info.ereticFactor = Number(quantFactorSample.groups.ereticFactor); | ||
} | ||
} | ||
function mergeMetadata(main, complement) { | ||
@@ -402,0 +426,0 @@ for (let key in complement.meta) { |
{ | ||
"name": "brukerconverter", | ||
"version": "6.0.9", | ||
"version": "6.0.10-pre.1678714014", | ||
"description": "Parse and convert Bruker raw data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -15,2 +15,13 @@ import { join } from 'path'; | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'ereticMethod'), | ||
); | ||
const results = await convertFileCollection(fileCollection, { | ||
converter: { keepFiles: true }, | ||
}); | ||
expect(results[0].info).toHaveProperty('ereticFactor'); | ||
expect(results[0].info.ereticFactor).toBeCloseTo(2441.11043387, 4); | ||
}); | ||
it('convert folder without expno level', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/withoutExpno'), | ||
@@ -38,2 +49,39 @@ ); | ||
}); | ||
it('keep only fid', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/withoutExpno'), | ||
); | ||
const results = await convertFileCollection(fileCollection, { | ||
converter: { keepFiles: true }, | ||
filter: { dataSelection: 'fid' }, | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].source).toMatchCloseTo({ | ||
name: 'withoutExpno', | ||
expno: 0, | ||
is1D: true, | ||
isFID: true, | ||
}); | ||
expect(results[0].spectra[0].data.re).toHaveLength(65536 / 2); | ||
}); | ||
it('keep only ft', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/withoutExpno'), | ||
); | ||
const results = await convertFileCollection(fileCollection, { | ||
converter: { keepFiles: true }, | ||
filter: { dataSelection: 'ft' }, | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].source).toMatchCloseTo({ | ||
name: 'withoutExpno', | ||
expno: 0, | ||
procno: 1, | ||
is1D: true, | ||
isFT: true, | ||
}); | ||
expect(results[0].spectra[0].data.re).toHaveLength(65536 / 2); | ||
}); | ||
it('advanced example', async () => { | ||
@@ -40,0 +88,0 @@ const fileCollection = await getCoffee(); |
@@ -68,2 +68,24 @@ import { join } from 'path'; | ||
}); | ||
it('keep only ft', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'ft', | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].expno).toBe(10); | ||
expect(results[0].procno).toBe(1); | ||
}); | ||
it('keep only FID', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'fid', | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].expno).toBe(10); | ||
expect(results[0]).not.toHaveProperty('procno'); | ||
}); | ||
}); | ||
@@ -70,0 +92,0 @@ describe('groupByExperiments', () => { |
@@ -21,4 +21,4 @@ /** | ||
} = options; | ||
const experiments = {}; | ||
const fileList = fileCollection.files.map((file) => file.relativePath); | ||
for (let file of fileCollection) { | ||
@@ -30,2 +30,3 @@ let procno; | ||
let id; | ||
// console.log(file.name); | ||
const parts = file.relativePath.split('/'); | ||
@@ -39,3 +40,3 @@ if (file.relativePath.match(/\/pdata\/\d+\//)) { | ||
id = parts.slice(0, -3).join('/'); | ||
} else if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) { | ||
} else if (isRawOrAcquisitionFile(file, fileList)) { | ||
const firstLevel = parts.indexOf(file.name); | ||
@@ -99,2 +100,6 @@ expno = Number(parts[firstLevel - 1]); | ||
} | ||
if (file.name === 'QuantFactorSample.xml') { | ||
experiment.quantFactorSample = file; | ||
} | ||
} | ||
@@ -187,1 +192,9 @@ if (processingNumbers) { | ||
} | ||
function isRawOrAcquisitionFile(file, fileList) { | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s|QuantFactorSample.xml)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
); | ||
} |
@@ -11,2 +11,4 @@ import { joinInfoMeta } from './joinMetaInfo.js'; | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files['1r'] || files['1i']) { | ||
@@ -26,1 +28,10 @@ await setProcessedSpectrumData( | ||
} | ||
async function addEreticFactor(result, files) { | ||
const quantFactorSample = (await files.quantFactorSample.text()).match( | ||
/<Application[\w\W]+<Eretic_Factor>(?<ereticFactor>[\d.]+)/, | ||
); | ||
if (quantFactorSample) { | ||
result.info.ereticFactor = Number(quantFactorSample.groups.ereticFactor); | ||
} | ||
} |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
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
1438136
41
1750
2
7