brukerconverter
Advanced tools
Comparing version 6.0.10 to 6.1.0
@@ -29,3 +29,2 @@ 'use strict'; | ||
} = options; | ||
const experiments = {}; | ||
@@ -106,2 +105,6 @@ const fileList = fileCollection.files.map((file) => file.relativePath); | ||
} | ||
if (file.name === 'QuantFactorSample.xml') { | ||
experiment.quantFactorSample = file; | ||
} | ||
} | ||
@@ -140,9 +143,4 @@ if (processingNumbers) { | ||
const processedKeys = Object.keys(processed); | ||
const hasRawData = experiment.ser || experiment.fid; | ||
if ( | ||
(hasRawData && dataSelection !== 'ft' && dataSelection !== 'preferFT') || | ||
(dataSelection === 'preferFT' && !processedKeys.length) | ||
) { | ||
if (shouldAddRawData(experiments[key], dataSelection)) { | ||
const processedKeys = Object.keys(processed); | ||
if (processedKeys.length > 0) { | ||
@@ -162,2 +160,3 @@ const firstProcessed = processed[processedKeys[0]]; | ||
const hasRawData = 'ser' in experiment || 'fid' in experiment; | ||
if ( | ||
@@ -199,3 +198,3 @@ dataSelection === 'fid' || | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s)$/) || | ||
file.name.match(/^(ser|acqus|acqu2s|QuantFactorSample.xml)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
@@ -206,2 +205,18 @@ fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
function shouldAddRawData(experiment, dataSelection) { | ||
const { processedData: processed } = experiment; | ||
const processedKeys = Object.keys(processed); | ||
const hasProcessData = | ||
processedKeys.length > 0 && | ||
('1r' in processed[processedKeys[0]] || | ||
'1i' in processed[processedKeys[0]]); | ||
const hasRawData = 'ser' in experiment || 'fid' in experiment; | ||
const notPreferFt = dataSelection !== 'ft' && dataSelection !== 'preferFT'; | ||
const preferFtWithoutProcessedData = | ||
dataSelection === 'preferFT' && !hasProcessData; | ||
return hasRawData && (notPreferFt || preferFtWithoutProcessedData); | ||
} | ||
function joinInfoMeta(target, toAppend) { | ||
@@ -394,2 +409,4 @@ for (let key in toAppend.meta) { | ||
if (files.quantFactorSample) addEreticFactor(result, files); | ||
if (files['1r'] || files['1i']) { | ||
@@ -410,2 +427,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) { | ||
@@ -412,0 +438,0 @@ for (let key in complement.meta) { |
{ | ||
"name": "brukerconverter", | ||
"version": "6.0.10", | ||
"version": "6.1.0", | ||
"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'), | ||
@@ -17,0 +28,0 @@ ); |
@@ -44,2 +44,13 @@ import { join } from 'path'; | ||
}); | ||
it('priorize FT without processed data', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/11'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'preferFT', | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].expno).toBe(11); | ||
expect(results[0]).toHaveProperty('fid'); | ||
}); | ||
it('priorize FID', async () => { | ||
@@ -46,0 +57,0 @@ const fileCollection = await fileCollectionFromPath( |
@@ -21,3 +21,2 @@ /** | ||
} = options; | ||
const experiments = {}; | ||
@@ -98,2 +97,6 @@ const fileList = fileCollection.files.map((file) => file.relativePath); | ||
} | ||
if (file.name === 'QuantFactorSample.xml') { | ||
experiment.quantFactorSample = file; | ||
} | ||
} | ||
@@ -132,9 +135,4 @@ if (processingNumbers) { | ||
const processedKeys = Object.keys(processed); | ||
const hasRawData = experiment.ser || experiment.fid; | ||
if ( | ||
(hasRawData && dataSelection !== 'ft' && dataSelection !== 'preferFT') || | ||
(dataSelection === 'preferFT' && !processedKeys.length) | ||
) { | ||
if (shouldAddRawData(experiments[key], dataSelection)) { | ||
const processedKeys = Object.keys(processed); | ||
if (processedKeys.length > 0) { | ||
@@ -154,2 +152,3 @@ const firstProcessed = processed[processedKeys[0]]; | ||
const hasRawData = 'ser' in experiment || 'fid' in experiment; | ||
if ( | ||
@@ -191,3 +190,3 @@ dataSelection === 'fid' || | ||
return ( | ||
file.name.match(/^(ser|acqus|acqu2s)$/) || | ||
file.name.match(/^(ser|acqus|acqu2s|QuantFactorSample.xml)$/) || | ||
(file.name.match(/^(fid)$/) && | ||
@@ -197,1 +196,17 @@ fileList.includes(file.relativePath.replace(/fid$/, 'acqus'))) | ||
} | ||
function shouldAddRawData(experiment, dataSelection) { | ||
const { processedData: processed } = experiment; | ||
const processedKeys = Object.keys(processed); | ||
const hasProcessData = | ||
processedKeys.length > 0 && | ||
('1r' in processed[processedKeys[0]] || | ||
'1i' in processed[processedKeys[0]]); | ||
const hasRawData = 'ser' in experiment || 'fid' in experiment; | ||
const notPreferFt = dataSelection !== 'ft' && dataSelection !== 'preferFT'; | ||
const preferFtWithoutProcessedData = | ||
dataSelection === 'preferFT' && !hasProcessData; | ||
return hasRawData && (notPreferFt || preferFtWithoutProcessedData); | ||
} |
@@ -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 2 instances 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
1724544
46
1779
8