brukerconverter
Advanced tools
Comparing version 6.0.8 to 6.0.9
@@ -31,22 +31,12 @@ import { DoubleArray } from 'cheminfo-types'; | ||
/** | ||
* should we ignore fid | ||
* @default false | ||
* should we keep 1D spectra | ||
* @default true | ||
*/ | ||
ignoreFID?: boolean; | ||
keep1D?: boolean; | ||
/** | ||
* should we ignore the ft transformed fid | ||
* @default false | ||
* should we keep 2D spectra | ||
* @default true | ||
*/ | ||
ignoreFT?: boolean; | ||
keep2D?: boolean; | ||
/** | ||
* should we ignore 1D spectra | ||
* @default false | ||
*/ | ||
ignore1D?: boolean; | ||
/** | ||
* should we ignore 2D spectra | ||
* @default false | ||
*/ | ||
ignore2D?: boolean; | ||
/** | ||
* should we take only the first processed data (procno). | ||
@@ -56,2 +46,8 @@ * @default true | ||
onlyFirstProcessedData?: boolean; | ||
/** | ||
* allow filter by only processed (FT) or raw data (FID), set a preference for | ||
* FT or FID if both exists, or always load both. | ||
* @default 'both' | ||
*/ | ||
dataSelection?: 'ft' | 'fid' | 'both' | 'preferFT' | 'preferFID'; | ||
} | ||
@@ -121,7 +117,7 @@ | ||
export interface Files { | ||
relativePath: string; | ||
export interface File { | ||
relativePath?: string; | ||
name: string; | ||
lastModified: number; | ||
size: number; | ||
size?: number; | ||
} | ||
@@ -137,3 +133,3 @@ | ||
shiftOffsetNum: 0; | ||
source: BrukerSource & { | ||
source: GeneralBrukerSource & { | ||
is1D: boolean; | ||
@@ -171,3 +167,3 @@ }; | ||
isFID: boolean; | ||
files?: Files; | ||
files?: File[]; | ||
} | ||
@@ -184,3 +180,3 @@ | ||
shiftOffsetNum: 0; | ||
source: BrukerSource & { is2D: boolean }; | ||
source: GeneralBrukerSource & { is2D: boolean }; | ||
} | ||
@@ -187,0 +183,0 @@ |
@@ -11,8 +11,6 @@ 'use strict'; | ||
* Retrieve the list of files for further process | ||
* @param {FileCollection[]} fileCollection | ||
* @param {FileCollection} fileCollection | ||
* @param {object} [options={}] | ||
* @param {number[]} [options.processingNumbers] - processing number to select, default the smallest number | ||
* @param {number[]} [options.experimentNumbers] - experiment number to select, default all | ||
* @param {boolean} [options.keepFID=true] - should we keep fid | ||
* @param {boolean} [options.keepFT=true] - should we keep the ft transformed fid | ||
* @param {boolean} [options.keep1D=true] - should we keep 1D spectra | ||
@@ -27,4 +25,3 @@ * @param {boolean} [options.keep2D=true] - should we keep 2D spectra | ||
experimentNumbers, | ||
keepFID = true, | ||
keepFT = true, | ||
dataSelection = 'both', | ||
keep1D = true, | ||
@@ -141,11 +138,18 @@ keep2D = true, | ||
const { processedData: processed, ...experiment } = { ...experiments[key] }; | ||
if (experiment.ser || experiment.fid) { | ||
if (Object.keys(processed).length > 0) { | ||
const firstProcessed = processed[Object.keys(processed)[0]]; | ||
const processedKeys = Object.keys(processed); | ||
const hasRawData = experiment.ser || experiment.fid; | ||
if ( | ||
(hasRawData && dataSelection !== 'ft' && dataSelection !== 'preferFT') || | ||
(dataSelection === 'preferFT' && !processedKeys.length) | ||
) { | ||
if (processedKeys.length > 0) { | ||
const firstProcessed = processed[processedKeys[0]]; | ||
if (firstProcessed.procs) { | ||
experiment.fileCollectionItems.push(firstProcessed.procs); //seems useless | ||
experiment.fileCollectionItems.push(firstProcessed.procs); | ||
experiment.procs = firstProcessed.procs; | ||
} | ||
if (firstProcessed.proc2s) { | ||
// experiment.fileCollectionItems.push(firstProcessed.proc2s); //seems useless | ||
experiment.fileCollectionItems.push(firstProcessed.proc2s); | ||
experiment.proc2s = firstProcessed.proc2s; | ||
@@ -156,2 +160,9 @@ } | ||
} | ||
if ( | ||
dataSelection === 'fid' || | ||
(dataSelection === 'preferFID' && hasRawData) | ||
) { | ||
continue; | ||
} | ||
for (let processedKey in processed) { | ||
@@ -175,8 +186,2 @@ const oneProcessed = processed[processedKey]; | ||
// we can not easily filter | ||
if (!keepFID) { | ||
experimentsArray = experimentsArray.filter((item) => !item.isFID); | ||
} | ||
if (!keepFT) { | ||
experimentsArray = experimentsArray.filter((item) => !item.isFT); | ||
} | ||
if (!keep1D) { | ||
@@ -594,4 +599,2 @@ experimentsArray = experimentsArray.filter((item) => !item.is1D); | ||
} | ||
// todo we could as well keep the FileList at this level if | ||
// we want to keep the original data | ||
} | ||
@@ -598,0 +601,0 @@ |
{ | ||
"name": "brukerconverter", | ||
"version": "6.0.8", | ||
"version": "6.0.9", | ||
"description": "Parse and convert Bruker raw data", | ||
@@ -47,3 +47,3 @@ "main": "lib/index.js", | ||
"cheminfo-types": "^1.4.0", | ||
"filelist-utils": "^1.7.0", | ||
"filelist-utils": "^1.7.0-pre.1676560930", | ||
"iobuffer": "^5.3.2", | ||
@@ -54,2 +54,2 @@ "is-any-array": "^2.0.0", | ||
} | ||
} | ||
} |
@@ -32,2 +32,39 @@ import { join } from 'path'; | ||
describe('dataSelection', () => { | ||
it('priorize FT', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'preferFT', | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].expno).toBe(10); | ||
expect(results[0].procno).toBe(1); | ||
}); | ||
it('priorize FID', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'preferFID', | ||
}); | ||
expect(results).toHaveLength(1); | ||
expect(results[0].expno).toBe(10); | ||
expect(results[0]).not.toHaveProperty('procno'); | ||
}); | ||
it('keep both', async () => { | ||
const fileCollection = await fileCollectionFromPath( | ||
join(__dirname, 'data/10'), | ||
); | ||
const results = groupByExperiments(fileCollection, { | ||
dataSelection: 'both', | ||
}); | ||
expect(results).toHaveLength(2); | ||
expect(results[0].expno).toBe(10); | ||
expect(results[0].name).toBe('10'); | ||
expect(results[1].expno).toBe(10); | ||
expect(results[1].name).toBe('10'); | ||
}); | ||
}); | ||
describe('groupByExperiments', () => { | ||
@@ -43,3 +80,3 @@ it('no options', async () => { | ||
keep2D: false, | ||
keepFID: false, | ||
dataSelection: 'ft', | ||
}); | ||
@@ -60,3 +97,3 @@ expect(results).toHaveLength(8); | ||
keep2D: false, | ||
keepFT: false, | ||
dataSelection: 'fid', | ||
}); | ||
@@ -77,3 +114,3 @@ expect(results).toHaveLength(7); | ||
keep1D: false, | ||
keepFID: false, | ||
dataSelection: 'ft', | ||
}); | ||
@@ -86,3 +123,3 @@ expect(results).toHaveLength(1); | ||
keep1D: false, | ||
keepFT: false, | ||
dataSelection: 'fid', | ||
}); | ||
@@ -102,3 +139,3 @@ expect(results).toHaveLength(2); | ||
onlyFirstProcessedData: false, | ||
keepFID: false, | ||
dataSelection: 'ft', | ||
}); | ||
@@ -111,3 +148,3 @@ expect(results).toHaveLength(9); | ||
processingNumbers: [2], | ||
keepFID: false, | ||
dataSelection: 'ft', | ||
}); | ||
@@ -120,3 +157,3 @@ expect(results).toHaveLength(0); | ||
processingNumbers: [1], | ||
keepFID: false, | ||
dataSelection: 'ft', | ||
}); | ||
@@ -123,0 +160,0 @@ expect(results).toHaveLength(9); |
/** | ||
* Retrieve the list of files for further process | ||
* @param {FileCollection[]} fileCollection | ||
* @param {FileCollection} fileCollection | ||
* @param {object} [options={}] | ||
* @param {number[]} [options.processingNumbers] - processing number to select, default the smallest number | ||
* @param {number[]} [options.experimentNumbers] - experiment number to select, default all | ||
* @param {boolean} [options.keepFID=true] - should we keep fid | ||
* @param {boolean} [options.keepFT=true] - should we keep the ft transformed fid | ||
* @param {boolean} [options.keep1D=true] - should we keep 1D spectra | ||
@@ -18,4 +16,3 @@ * @param {boolean} [options.keep2D=true] - should we keep 2D spectra | ||
experimentNumbers, | ||
keepFID = true, | ||
keepFT = true, | ||
dataSelection = 'both', | ||
keep1D = true, | ||
@@ -132,11 +129,18 @@ keep2D = true, | ||
const { processedData: processed, ...experiment } = { ...experiments[key] }; | ||
if (experiment.ser || experiment.fid) { | ||
if (Object.keys(processed).length > 0) { | ||
const firstProcessed = processed[Object.keys(processed)[0]]; | ||
const processedKeys = Object.keys(processed); | ||
const hasRawData = experiment.ser || experiment.fid; | ||
if ( | ||
(hasRawData && dataSelection !== 'ft' && dataSelection !== 'preferFT') || | ||
(dataSelection === 'preferFT' && !processedKeys.length) | ||
) { | ||
if (processedKeys.length > 0) { | ||
const firstProcessed = processed[processedKeys[0]]; | ||
if (firstProcessed.procs) { | ||
experiment.fileCollectionItems.push(firstProcessed.procs); //seems useless | ||
experiment.fileCollectionItems.push(firstProcessed.procs); | ||
experiment.procs = firstProcessed.procs; | ||
} | ||
if (firstProcessed.proc2s) { | ||
// experiment.fileCollectionItems.push(firstProcessed.proc2s); //seems useless | ||
experiment.fileCollectionItems.push(firstProcessed.proc2s); | ||
experiment.proc2s = firstProcessed.proc2s; | ||
@@ -147,2 +151,9 @@ } | ||
} | ||
if ( | ||
dataSelection === 'fid' || | ||
(dataSelection === 'preferFID' && hasRawData) | ||
) { | ||
continue; | ||
} | ||
for (let processedKey in processed) { | ||
@@ -166,8 +177,2 @@ const oneProcessed = processed[processedKey]; | ||
// we can not easily filter | ||
if (!keepFID) { | ||
experimentsArray = experimentsArray.filter((item) => !item.isFID); | ||
} | ||
if (!keepFT) { | ||
experimentsArray = experimentsArray.filter((item) => !item.isFT); | ||
} | ||
if (!keep1D) { | ||
@@ -174,0 +179,0 @@ experimentsArray = experimentsArray.filter((item) => !item.is1D); |
@@ -31,4 +31,2 @@ import { convert1D } from './convert1D'; | ||
} | ||
// todo we could as well keep the FileList at this level if | ||
// we want to keep the original data | ||
} | ||
@@ -35,0 +33,0 @@ |
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
1151586
1641