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

mzdata

Package Overview
Dependencies
Maintainers
7
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mzdata - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

src/__tests__/mzXML.test.js

4

History.md

@@ -0,1 +1,5 @@

# [2.1.0](https://github.com/cheminfo-js/mzData/compare/v2.0.1...v2.1.0) (2020-04-20)
## [2.0.1](https://github.com/cheminfo-js/mzData/compare/v1.1.0...v2.0.1) (2020-02-28)

@@ -2,0 +6,0 @@

@@ -205,2 +205,103 @@ 'use strict';

function parseCvParam$2(cvParam) {
let result = {};
if (!cvParam) return result;
let cvParams;
if (Array.isArray(cvParam)) {
cvParams = cvParam;
} else {
cvParams = [cvParam];
}
for (let param of cvParams) {
if (param.precision) {
result = {
precision: param.precision,
byteOrder: param.byteOrder,
contentType: param.contentType,
pairOrder: param.pairOrder,
};
}
}
return result;
}
function parseBinaryDataArray$1(node) {
let data = node.peaks;
let attr = node._attr;
let cvParam = parseCvParam$2(data._attr);
if (!data || !attr) return [];
let buffer = decoder$1(data._data, cvParam);
let kind = '';
if (cvParam.contentType) {
kind = cvParam.contentType;
} else if (cvParam.pairOrder) {
kind = cvParam.pairOrder;
} else {
throw new Error('unknown binary data type');
}
// console.log(buffer)
if (cvParam.precision === 64) {
let result = {};
result.data = new Float64Array(buffer.buffer);
result.kind = kind;
return result;
} else if (cvParam.precision === 32) {
let result = {};
result.data = new Float32Array(buffer);
result.kind = kind;
return result;
}
throw new Error(`unknown precision in decoder: ${attr.precision}`);
}
function decoder$1(base64Encoded, cvParams = {}) {
if (cvParams.compressionType === 'zlib') {
return pako.inflate(base64Js.toByteArray(base64Encoded));
} else {
return base64Js.toByteArray(base64Encoded);
}
}
function processSpectrumList$2(parsed, msData) {
if (!parsed.msRun.scan) return;
let scanList = parsed.msRun.scan;
if (Array.isArray(scanList) === false) scanList = [scanList];
if (scanList[0]._attr) {
msData.info = [];
}
for (let scan of scanList) {
if (typeof scan !== 'object') continue;
if (Array.isArray(scan)) {
throw new Error('processSpectrumList: scan may not be an array');
}
let dataArray = parseBinaryDataArray$1(scan);
let first = new Float64Array(dataArray.data.length / 2);
let second = new Float64Array(dataArray.data.length / 2);
for (let i = 0; i < dataArray.data.length / 2; i++) {
first[i] = dataArray.data[i * 2];
second[i] = dataArray.data[i * 2 + 1];
}
msData.data.push([first, second]);
msData.info.push(scan._attr);
}
}
function processMZXML(topLevel, result) {
processSpectrumList$2(topLevel, result.series.ms);
let offset = topLevel.index.offset;
for (let i = 0; i < offset.length; i++) {
let index = offset[i]._attr.id;
let data = offset[i]._data;
result.times[index - 1] = data;
}
result.metadata = {
msManufacturer: topLevel.msRun.msInstrument.msManufacturer._attr,
msModel: topLevel.msRun.msInstrument.msModel._attr,
msIonisation: topLevel.msRun.msInstrument.msIonisation._attr,
msMassAnalyzer: topLevel.msRun.msInstrument.msMassAnalyzer._attr,
msDetector: topLevel.msRun.msInstrument.msDetector._attr,
software: topLevel.msRun.msInstrument.software._attr,
};
}
function ensureText(data, options = {}) {

@@ -271,2 +372,3 @@ const { encoding = 'utf8' } = options;

case 'mzxml':
processMZXML(topLevel.mzxml, result);
break;

@@ -273,0 +375,0 @@ default:

2

package.json
{
"name": "mzdata",
"version": "2.0.1",
"version": "2.1.0",
"description": "Read and explore mzData v1.05 files",

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

@@ -5,2 +5,3 @@ import { parse } from 'fast-xml-parser';

import { processMZML } from './mzml/process';
import { processMZXML } from './mzxml/process';
import { ensureText } from './util/ensureText';

@@ -50,2 +51,3 @@ import { searchObjectKey } from './util/searchObjectKey';

case 'mzxml':
processMZXML(topLevel.mzxml, result);
break;

@@ -52,0 +54,0 @@ default:

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