brukerconverter
Advanced tools
Comparing version 6.0.9 to 6.0.10
@@ -31,2 +31,3 @@ 'use strict'; | ||
const experiments = {}; | ||
const fileList = fileCollection.files.map((file) => file.relativePath); | ||
for (let file of fileCollection) { | ||
@@ -46,3 +47,3 @@ let procno; | ||
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); | ||
@@ -194,2 +195,10 @@ expno = Number(parts[firstLevel - 1]); | ||
function isRawOrAcquisitionFile(file, fileList) { | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
); | ||
} | ||
function joinInfoMeta(target, toAppend) { | ||
@@ -196,0 +205,0 @@ for (let key in toAppend.meta) { |
{ | ||
"name": "brukerconverter", | ||
"version": "6.0.9", | ||
"version": "6.0.10", | ||
"description": "Parse and convert Bruker raw data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -37,2 +37,39 @@ import { join } from 'path'; | ||
}); | ||
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 () => { | ||
@@ -39,0 +76,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', () => { |
@@ -23,2 +23,3 @@ /** | ||
const experiments = {}; | ||
const fileList = fileCollection.files.map((file) => file.relativePath); | ||
for (let file of fileCollection) { | ||
@@ -38,3 +39,3 @@ let procno; | ||
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); | ||
@@ -185,1 +186,9 @@ expno = Number(parts[firstLevel - 1]); | ||
} | ||
function isRawOrAcquisitionFile(file, fileList) { | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
); | ||
} |
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
1153973
1714