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.1.5-pre.1691494258 to 6.2.0

src/util/parseIntegrals.js

68

lib/index.js

@@ -214,43 +214,2 @@ 'use strict';

async function addIntegrals(result, files) {
const integralFile = files.integrals;
let text = await integralFile.text();
text = text.split(/\n/);
const info = text[1]
.replace(/^\s*/, '')
.replace(/(?<=\w)[\t]+/g, ';')
.replace(/(?<==)[\t\s]*/g, '')
.match(
/(?<name>(?<=[NAME] =)[\w\d]*);EXPNO =(?<expno>[\d]*);PROCNO =(?<procno>[\d]*)/,
);
const { expno, procno, name } = info?.groups || {};
const directory = text[2].replace(/\s*DU\s*=\t*([\w/.\d]+)/, '$1');
const integrals = [];
const integralData = text.slice(3).filter((t) => t);
for (let i = 1; i < integralData.length; i++) {
const data = integralData[i]
.replace(/^\s*/, '')
.replace(/[\s\t]+/g, ';')
.match(/\d+;(?<from>[0-9.]+);(?<to>[0-9.]+);(?<integration>[0-9.]+)/);
if (data) {
const { from, to, integration } = data.groups;
integrals.push({
from: parseFloat(from),
to: parseFloat(to),
integration: parseFloat(integration),
});
}
}
result.integrals = {
directory,
name,
expno: Number(expno),
procno: Number(procno),
integrals,
};
}
function joinInfoMeta(target, toAppend) {

@@ -294,2 +253,27 @@ for (let key in toAppend.meta) {

async function parseIntegrals(files) {
const integralData = (await files.integrals.text())
.split(/\r?\n/)
.slice(3)
.filter((t) => t);
const integrals = [];
for (let i = 1; i < integralData.length; i++) {
const data = integralData[i]
.replace(/^\s*/, '')
.replace(/[\s\t]+/g, ';')
.match(/\d+;(?<from>[0-9.]+);(?<to>[0-9.]+);(?<integration>[0-9.]+)/);
if (data) {
const { from, to, integration } = data.groups;
integrals.push({
from: parseFloat(from),
to: parseFloat(to),
integration: parseFloat(integration),
});
}
}
return integrals;
}
const QSEQ = 2;

@@ -445,3 +429,3 @@

if (files.quantFactorSample) addEreticFactor(result, files);
if (files.integrals) await addIntegrals(result, files);
if (files.integrals) result.integrals = await parseIntegrals(files);

@@ -448,0 +432,0 @@ if (files['1r'] || files['1i']) {

{
"name": "brukerconverter",
"version": "6.1.5-pre.1691494258",
"version": "6.2.0",
"description": "Parse and convert Bruker raw data",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -136,16 +136,10 @@ import { join } from 'path';

expect(pdata.integrals).toEqual(
expect.objectContaining({
directory: '/opt/topspin4.3.0/examdata',
name: 'exam_CMCse_1',
procno: 1,
expno: 10,
integrals: expect.arrayContaining([
{
from: 6.633,
to: 6.56,
integration: 1,
},
]),
}),
expect.arrayContaining([
{
from: 6.633,
to: 6.56,
integration: 1,
},
]),
);
});

@@ -1,4 +0,4 @@

import { addIntegrals } from './addIntegrals.js';
import { joinInfoMeta } from './joinMetaInfo.js';
import { parseData } from './parseData';
import { parseIntegrals } from './parseIntegrals.js';
import { setFIDSpectrumData } from './setFIDSpectrumData';

@@ -13,3 +13,3 @@ import { setProcessedSpectrumData } from './setProcessedSpectrumData';

if (files.quantFactorSample) addEreticFactor(result, files);
if (files.integrals) await addIntegrals(result, files);
if (files.integrals) result.integrals = await parseIntegrals(files);

@@ -16,0 +16,0 @@ if (files['1r'] || files['1i']) {

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