New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

brukerconverter

Package Overview
Dependencies
Maintainers
6
Versions
92
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

to
4.1.7-pre.1664466065

src/helpers/convertZip.js

33

brukerconverter.d.ts
import { DoubleArray } from 'cheminfo-types';
import type { PartialFile, PartialFileList } from 'filelist-utils';
import type { FileCollectionItem, FileCollection } from 'filelist-utils';
import { DoubleMatrix } from 'ml-spectra-processing';

@@ -16,3 +16,5 @@

type FirstLevelPartialFile = Partial<Record<FirstLevelKeys, PartialFile>>;
type FirstLevelPartialFile = Partial<
Record<FirstLevelKeys, FileCollectionItem>
>;

@@ -59,3 +61,3 @@ export interface GroupByExperimentsOptions {

name: string;
fileList: PartialFileList;
fileList: FileCollection;
expno: number;

@@ -72,3 +74,3 @@ is2D?: boolean;

expno: number;
fileList: PartialFileList;
fileList: FileCollection;
processedData?: ProcessedData;

@@ -80,3 +82,6 @@ is2D?: boolean;

export function groupByExperiments(fileList: PartialFileList, options?: GroupByExperimentsOptions): Experiment[];
export function groupByExperiments(
fileList: FileCollection,
options?: GroupByExperimentsOptions,
): Experiment[];

@@ -89,4 +94,4 @@ export interface ConverterOptions {

export interface ConvertFileListOptions {
filter?: GroupByExperimentsOptions,
converter?: ConverterOptions,
filter?: GroupByExperimentsOptions;
converter?: ConverterOptions;
}

@@ -109,3 +114,3 @@

yUnit: string;
isXYdata: boolean,
isXYdata: boolean;
observeFrequency: number;

@@ -117,3 +122,3 @@ deltaX: number;

export interface Spectrum2D extends Spectrum1D {
pageValue: number
pageValue: number;
}

@@ -134,3 +139,3 @@

isFID: boolean;
}
};
}

@@ -161,8 +166,10 @@

isFID: boolean;
}
};
}
type SpectraData = SpectraData1D | SpectraData2D;
export async function convertFileList(fileList: PartialFileList, options?: ConvertFileListOptions): Promise<SpectraData[]>
export function convertFileList(
fileList: FileCollection,
options?: ConvertFileListOptions,
): Promise<SpectraData[]>;

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

var filelistUtils = require('filelist-utils');
var jcampconverter = require('jcampconverter');

@@ -47,4 +48,4 @@ var iobuffer = require('iobuffer');

let id;
const parts = file.webkitRelativePath.split('/');
if (file.webkitRelativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
const parts = file.relativePath.split('/');
if (file.relativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
currentProcessingNo = Number(parts[parts.length - 2]);

@@ -54,3 +55,3 @@ currentExperimentNo = Number(parts[parts.length - 4]);

id = parts.slice(0, -3).join('/');
} else if (file.webkitRelativePath.match(/[0-9]+\/.*$/)) {
} else if (file.relativePath.match(/[0-9]+\/.*$/)) {
currentExperimentNo = Number(parts[parts.length - 2]);

@@ -137,3 +138,2 @@ name = parts[parts.length - 3] || parts[parts.length - 2];

}
// console.log('experiments', experiments)
// We convert the object to an array

@@ -191,3 +191,3 @@ // and before filtering we will move all the processedData

}
// console.log(experimentsArray)
return experimentsArray;

@@ -609,3 +609,9 @@ }

function convertZip(zip, options) {
const fileList = filelistUtils.fileCollectionFromZip(zip);
return convertFileList(fileList, options);
}
exports.convertFileList = convertFileList;
exports.convertZip = convertZip;
exports.groupByExperiments = groupByExperiments;
{
"name": "brukerconverter",
"version": "4.1.6",
"version": "4.1.7-pre.1664466065",
"description": "Parse and convert Bruker raw data",

@@ -36,3 +36,3 @@ "main": "lib/index.js",

"@types/jest": "^28.1.6",
"bruker-data-test": "0.2.1",
"bruker-data-test": "0.3.0-pre.1664462893",
"cheminfo-build": "^1.1.11",

@@ -48,3 +48,3 @@ "eslint": "^8.20.0",

"cheminfo-types": "^1.4.0",
"filelist-utils": "^0.5.0",
"filelist-utils": "^0.11.0",
"iobuffer": "^5.1.0",

@@ -55,2 +55,2 @@ "is-any-array": "^2.0.0",

}
}
}

@@ -11,3 +11,3 @@ import { getCoffee } from 'bruker-data-test';

it('advanced example', async () => {
const fileList = getCoffee();
const fileList = await getCoffee();
const results = await convertFileList(fileList);

@@ -14,0 +14,0 @@ expect(results).toHaveLength(18);

@@ -1,3 +0,3 @@

import { getZipped } from 'bruker-data-test';
import { fileListFromZip } from 'filelist-utils';
import { getData } from 'bruker-data-test';
import { fileCollectionFromZip } from 'filelist-utils';

@@ -8,6 +8,4 @@ import { convertFileList } from '../convertFileList.js';

it('cyclospirin proton spectrum', async () => {
const zip = await getZipped()
.filter((file) => file.name === 'cyclosporin_1h.zip')[0]
.arrayBuffer();
const fileList = await fileListFromZip(zip);
const zip = await getData('cyclosporin_1h.zip');
const fileList = await fileCollectionFromZip(zip);
let result = await convertFileList(fileList, {

@@ -24,6 +22,4 @@ xy: true,

it('cyclosporin hmbc', async () => {
const zip = await getZipped()
.filter((file) => file.name === 'cyclosporin_hmbc.zip')[0]
.arrayBuffer();
const fileList = await fileListFromZip(zip);
const zip = await getData('cyclosporin_hmbc.zip');
const fileList = await fileCollectionFromZip(zip);
let result = await convertFileList(fileList, {

@@ -30,0 +26,0 @@ converter: {

@@ -6,9 +6,10 @@ import { getCoffee } from 'bruker-data-test';

describe('groupByExperiments', () => {
const fileList = getCoffee();
it('no options', async () => {
const results = groupByExperiments(fileList);
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection);
expect(results).toHaveLength(18);
});
it('ignore fid and 2d', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
ignore2D: true,

@@ -28,3 +29,4 @@ ignoreFID: true,

it('ignore ft and 2d', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
ignore2D: true,

@@ -44,3 +46,4 @@ ignoreFT: true,

it('ignore fid and 1d', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
ignore1D: true,

@@ -52,3 +55,4 @@ ignoreFID: true,

it('ignore ft and 1d', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
ignore1D: true,

@@ -60,3 +64,4 @@ ignoreFT: true,

it('get only procNo equal 1', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
processingNumber: 1,

@@ -67,3 +72,4 @@ });

it('get only the first procno ignoring raw data', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
onlyFirstProcessedData: false,

@@ -75,3 +81,4 @@ ignoreFID: true,

it('get only the second procno ignoring raw data', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
processingNumber: 2,

@@ -83,3 +90,4 @@ ignoreFID: true,

it('get only procNo equal 1 ignoring raw data', async () => {
const results = groupByExperiments(fileList, {
const fileCollection = await getCoffee();
const results = groupByExperiments(fileCollection, {
processingNumber: 1,

@@ -86,0 +94,0 @@ ignoreFID: true,

@@ -37,4 +37,4 @@ /**

let id;
const parts = file.webkitRelativePath.split('/');
if (file.webkitRelativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
const parts = file.relativePath.split('/');
if (file.relativePath.match(/\/pdata\/[0-9]+\/.*$/)) {
currentProcessingNo = Number(parts[parts.length - 2]);

@@ -44,3 +44,3 @@ currentExperimentNo = Number(parts[parts.length - 4]);

id = parts.slice(0, -3).join('/');
} else if (file.webkitRelativePath.match(/[0-9]+\/.*$/)) {
} else if (file.relativePath.match(/[0-9]+\/.*$/)) {
currentExperimentNo = Number(parts[parts.length - 2]);

@@ -127,3 +127,2 @@ name = parts[parts.length - 3] || parts[parts.length - 2];

}
// console.log('experiments', experiments)
// We convert the object to an array

@@ -181,4 +180,4 @@ // and before filtering we will move all the processedData

}
// console.log(experimentsArray)
return experimentsArray;
}

@@ -0,2 +1,3 @@

export { convertZip } from './helpers/convertZip';
export { convertFileList } from './convertFileList';
export { groupByExperiments } from './groupByExperiments';