Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brukerconverter

Package Overview
Dependencies
Maintainers
6
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brukerconverter - npm Package Compare versions

Comparing version 6.0.5 to 6.0.6-pre.1675950152

src/__tests__/data/withoutExpno/acqu

42

lib/index.js

@@ -21,2 +21,3 @@ 'use strict';

*/
function groupByExperiments(fileCollection, options = {}) {

@@ -42,9 +43,13 @@ let {

if (file.relativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
currentProcessingNo = Number(parts[parts.length - 2]);
currentExperimentNo = Number(parts[parts.length - 4]);
name = parts[parts.length - 5];
const pdataIndex = parts.indexOf('pdata');
currentProcessingNo = Number(parts[pdataIndex + 1]);
const expno = parseInt(parts[pdataIndex - 1], 10);
currentExperimentNo = isNaN(expno) ? 0 : expno;
name = parts[pdataIndex - 2] || parts[pdataIndex - 1];
id = parts.slice(0, -3).join('/');
} else if (file.relativePath.match(/[0-9]+\/.*$/)) {
currentExperimentNo = Number(parts[parts.length - 2]);
name = parts[parts.length - 3] || parts[parts.length - 2];
} else if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) {
const firstLevel = parts.indexOf(file.name);
const expno = parseInt(parts[firstLevel - 1], 10);
currentExperimentNo = isNaN(expno) ? 0 : expno;
name = parts[firstLevel - 2] || parts[firstLevel - 1];
id = parts.slice(0, -1).join('/');

@@ -78,3 +83,3 @@ } else {

const processedData = experiment.processedData[currentProcessingNo];
processedData.fileCollectionItems.push(file);
processedData.fileCollectionItems.push(file); // check if it can be moved into the conditional block
if (file.name.match(/^(1r|1i|2rr|procs|proc2s)$/)) {

@@ -92,3 +97,3 @@ processedData[file.name] = file;

} else {
experiment.fileCollectionItems.push(file);
experiment.fileCollectionItems.push(file); // check if it can be moved into the conditional block
if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) {

@@ -137,5 +142,3 @@ experiment[file.name] = file;

for (let key in experiments) {
const experiment = { ...experiments[key] };
const processed = experiment.processedData;
delete experiment.processedData;
const { processedData: processed, ...experiment } = { ...experiments[key] };
if (experiment.ser || experiment.fid) {

@@ -145,7 +148,7 @@ if (Object.keys(processed).length > 0) {

if (firstProcessed.procs) {
experiment.fileCollectionItems.push(firstProcessed.procs);
experiment.fileCollectionItems.push(firstProcessed.procs); //seems useless
experiment.procs = firstProcessed.procs;
}
if (firstProcessed.proc2s) {
experiment.fileCollectionItems.push(firstProcessed.proc2s);
// experiment.fileCollectionItems.push(firstProcessed.proc2s); //seems useless
experiment.proc2s = firstProcessed.proc2s;

@@ -240,5 +243,6 @@ }

const SW_H = Number(spectra.meta.SW_h[0]);
const SW_H = parseFloat(spectra.meta.SW_h[0]);
const SF = Number(spectra.meta.SFO1[0]);
const SF = parseFloat(spectra.meta.SFO1[0]);
const dtypa = parseInt(spectra.meta.DTYPA, 10);

@@ -291,11 +295,11 @@ spectra.meta.DATATYPE = 'NMR FID';

// const dtypa = spectra.meta.DTYPA;// we should use it for float or double FID data;
const method = dtypa === 2 ? 'readFloat64' : 'readInt32';
if (aqMode === QSEQ) {
for (let i = 0; i < nbPoints; i++) {
spectra.spectra[j].data.re[i] = ioBuffer.readInt32();
spectra.spectra[j].data.re[i] = ioBuffer[method]();
}
} else {
for (let i = 0; i < nbPoints; i++) {
spectra.spectra[j].data.re[i] = ioBuffer.readInt32();
spectra.spectra[j].data.im[i] = ioBuffer.readInt32();
spectra.spectra[j].data.re[i] = ioBuffer[method]();
spectra.spectra[j].data.im[i] = ioBuffer[method]();
}

@@ -302,0 +306,0 @@ }

{
"name": "brukerconverter",
"version": "6.0.5",
"version": "6.0.6-pre.1675950152",
"description": "Parse and convert Bruker raw data",

@@ -53,2 +53,2 @@ "main": "lib/index.js",

}
}
}
import { getCoffee } from 'bruker-data-test';
import { fileCollectionFromPath } from 'filelist-utils';
import { toBeDeepCloseTo, toMatchCloseTo } from 'jest-matcher-deep-close-to';
import { convertFileCollection } from '../convertFileCollection.js';
import { join } from 'path';

@@ -10,2 +12,26 @@ expect.extend({ toBeDeepCloseTo, toMatchCloseTo });

describe('convertFileCollection', () => {
it('convert folder without expno level', async () => {
const fileCollection = await fileCollectionFromPath(
join(__dirname, 'data/withoutExpno'),
);
const results = await convertFileCollection(fileCollection, {
converter: { keepFiles: true },
});
expect(results[0].source).toMatchCloseTo({
name: 'withoutExpno',
expno: 0,
is1D: true,
isFID: true,
});
expect(results[1].source).toMatchCloseTo({
name: 'withoutExpno',
expno: 0,
procno: 1,
is1D: true,
isFT: true,
});
expect(results[1].spectra[0].data.re).toHaveLength(65536 / 2);
expect(results[0].spectra[0].data.re).toHaveLength(65536 / 2);
});
it('advanced example', async () => {

@@ -12,0 +38,0 @@ const fileCollection = await getCoffee();

import { getCoffee } from 'bruker-data-test';
import { fileCollectionFromPath } from 'filelist-utils';
import { join } from 'path';
import { groupByExperiments } from '../groupByExperiments.js';
describe('groupByExperiment without expno', () => {
it('processed data and raw 1D data', async () => {
const fileCollection = await fileCollectionFromPath(
join(__dirname, 'data/withoutExpno'),
);
const results = groupByExperiments(fileCollection);
expect(results).toHaveLength(2);
expect(results[0].expno).toBe(0);
expect(results[0].name).toBe('withoutExpno');
expect(results[1].expno).toBe(0);
expect(results[1].name).toBe('withoutExpno');
});
});
describe('groupByExperiments', () => {

@@ -6,0 +21,0 @@ it('no options', async () => {

@@ -13,2 +13,3 @@ /**

*/
export function groupByExperiments(fileCollection, options = {}) {

@@ -34,9 +35,13 @@ let {

if (file.relativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
currentProcessingNo = Number(parts[parts.length - 2]);
currentExperimentNo = Number(parts[parts.length - 4]);
name = parts[parts.length - 5];
const pdataIndex = parts.indexOf('pdata');
currentProcessingNo = Number(parts[pdataIndex + 1]);
const expno = parseInt(parts[pdataIndex - 1], 10);
currentExperimentNo = isNaN(expno) ? 0 : expno;
name = parts[pdataIndex - 2] || parts[pdataIndex - 1];
id = parts.slice(0, -3).join('/');
} else if (file.relativePath.match(/[0-9]+\/.*$/)) {
currentExperimentNo = Number(parts[parts.length - 2]);
name = parts[parts.length - 3] || parts[parts.length - 2];
} else if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) {
const firstLevel = parts.indexOf(file.name);
const expno = parseInt(parts[firstLevel - 1], 10);
currentExperimentNo = isNaN(expno) ? 0 : expno;
name = parts[firstLevel - 2] || parts[firstLevel - 1];
id = parts.slice(0, -1).join('/');

@@ -70,3 +75,3 @@ } else {

const processedData = experiment.processedData[currentProcessingNo];
processedData.fileCollectionItems.push(file);
processedData.fileCollectionItems.push(file); // check if it can be moved into the conditional block
if (file.name.match(/^(1r|1i|2rr|procs|proc2s)$/)) {

@@ -84,3 +89,3 @@ processedData[file.name] = file;

} else {
experiment.fileCollectionItems.push(file);
experiment.fileCollectionItems.push(file); // check if it can be moved into the conditional block
if (file.name.match(/^(ser|fid|acqus|acqu2s)$/)) {

@@ -129,5 +134,3 @@ experiment[file.name] = file;

for (let key in experiments) {
const experiment = { ...experiments[key] };
const processed = experiment.processedData;
delete experiment.processedData;
const { processedData: processed, ...experiment } = { ...experiments[key] };
if (experiment.ser || experiment.fid) {

@@ -137,7 +140,7 @@ if (Object.keys(processed).length > 0) {

if (firstProcessed.procs) {
experiment.fileCollectionItems.push(firstProcessed.procs);
experiment.fileCollectionItems.push(firstProcessed.procs); //seems useless
experiment.procs = firstProcessed.procs;
}
if (firstProcessed.proc2s) {
experiment.fileCollectionItems.push(firstProcessed.proc2s);
// experiment.fileCollectionItems.push(firstProcessed.proc2s); //seems useless
experiment.proc2s = firstProcessed.proc2s;

@@ -144,0 +147,0 @@ }

@@ -16,5 +16,6 @@ import { IOBuffer } from 'iobuffer';

const SW_H = Number(spectra.meta.SW_h[0]);
const SW_H = parseFloat(spectra.meta.SW_h[0]);
const SF = Number(spectra.meta.SFO1[0]);
const SF = parseFloat(spectra.meta.SFO1[0]);
const dtypa = parseInt(spectra.meta.DTYPA, 10);

@@ -67,11 +68,11 @@ spectra.meta.DATATYPE = 'NMR FID';

// const dtypa = spectra.meta.DTYPA;// we should use it for float or double FID data;
const method = dtypa === 2 ? 'readFloat64' : 'readInt32';
if (aqMode === aqModeDirect.QSEQ) {
for (let i = 0; i < nbPoints; i++) {
spectra.spectra[j].data.re[i] = ioBuffer.readInt32();
spectra.spectra[j].data.re[i] = ioBuffer[method]();
}
} else {
for (let i = 0; i < nbPoints; i++) {
spectra.spectra[j].data.re[i] = ioBuffer.readInt32();
spectra.spectra[j].data.im[i] = ioBuffer.readInt32();
spectra.spectra[j].data.re[i] = ioBuffer[method]();
spectra.spectra[j].data.im[i] = ioBuffer[method]();
}

@@ -78,0 +79,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc