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

netcdf-gcms

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netcdf-gcms - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

src/agilentGCMS.js

14

package.json
{
"name": "netcdf-gcms",
"version": "1.1.0",
"version": "1.2.0",
"description": "Parser from NetCDF files to JSON usable for GCMS",

@@ -34,11 +34,13 @@ "main": "./src/index.js",

"devDependencies": {
"cheminfo-tools": "^1.5.0",
"eslint": "^4.10.0",
"eslint-config-cheminfo": "^1.2.0",
"eslint-plugin-no-only-tests": "^2.0.0",
"cheminfo-tools": "^1.21.1",
"eslint": "^4.19.1",
"eslint-config-cheminfo": "^1.18.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.27.1",
"eslint-plugin-no-only-tests": "^2.0.1",
"jest": "^21.2.1"
},
"dependencies": {
"netcdfjs": "^0.3.0"
"netcdfjs": "^0.6.0"
}
}
'use strict';
function aiaTemplate(reader) {
var time = [];
const tic = reader.getDataVariable('ordinate_values');
var time = [];
const tic = reader.getDataVariable('ordinate_values');
// variables to get the time
const delayTime = Number(reader.getDataVariable('actual_delay_time'));
const interval = Number(reader.getDataVariable('actual_sampling_interval'));
// variables to get the time
const delayTime = Number(reader.getDataVariable('actual_delay_time'));
const interval = Number(reader.getDataVariable('actual_sampling_interval'));
var currentTime = delayTime;
for (var i = 0; i < tic.length; i++) {
time.push(currentTime);
currentTime += interval;
}
var currentTime = delayTime;
for (var i = 0; i < tic.length; i++) {
time.push(currentTime);
currentTime += interval;
}
return {
times: time,
series: [{
name: 'tic',
dimension: 1,
data: tic
}]
};
return {
times: time,
series: [
{
name: 'tic',
dimension: 1,
data: tic
}
]
};
}
module.exports = aiaTemplate;
'use strict';
const NetCDFReader = require('netcdfjs');
const agilent = require('./agilent');
const finnigan = require('./finnigan');
const agilentGCMS = require('./agilentGCMS');
const agilentHPLC = require('./agilentHPLC');
const finniganGCMS = require('./finniganGCMS');
const aiaTemplate = require('./aiaTemplate');

@@ -11,29 +13,66 @@

* @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data
* @param {object} [options={}]
* @param {boolean} [options.meta] - add meta information
* @param {boolean} [options.variables] -add variables information
* @return {{times, series}} - JSON with the time, TIC and mass spectra values
*/
function netcdfGcms(data) {
let reader = new NetCDFReader(data);
const globalAttributes = reader.globalAttributes;
function netcdfGcms(data, options) {
let reader = new NetCDFReader(data);
if (globalAttributes.find(val => val.name === 'dataset_origin')) {
return agilent(reader);
} else if (globalAttributes.find(val => val.name === 'source_file_format')) {
return finnigan(reader);
} else if (globalAttributes.find(val => val.name === 'aia_template_revision')) {
return aiaTemplate(reader);
} else {
throw new TypeError('Unknown file format');
}
let instrument_mfr = reader.getDataVariableAsString('instrument_mfr');
let dataset_origin = reader.attributeExists('dataset_origin');
let mass_values = reader.dataVariableExists('mass_values');
let detector_name = reader.getAttribute('detector_name');
let aia_template_revision = reader.attributeExists('aia_template_revision');
const globalAttributes = reader.globalAttributes;
let ans;
if (mass_values && dataset_origin) {
ans = agilentGCMS(reader);
} else if (
mass_values &&
instrument_mfr &&
instrument_mfr.match(/finnigan/i)
) {
ans = finniganGCMS(reader);
} else if (detector_name && detector_name.match(/dad/i)) {
// diode array agilent HPLC
ans = agilentHPLC(reader);
} else if (aia_template_revision) {
ans = aiaTemplate(reader);
} else {
throw new TypeError('Unknown file format');
}
if (options && options.meta) {
ans.meta = addMeta(globalAttributes);
}
if (options && options.variables) {
ans.variables = addVariables(reader);
}
return ans;
}
/**
* Reads a NetCDF file with Agilent format and returns a formatted JSON with the data from it
* Reads a NetCDF file with Agilent GCMS format and returns a formatted JSON with the data from it
* @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data
* @return {{times, series}} - JSON with the time, TIC and mass spectra values
*/
function fromAgilent(data) {
return agilent(new NetCDFReader(data));
function fromAgilentGCMS(data) {
return agilentGCMS(new NetCDFReader(data));
}
/**
* Reads a NetCDF file with Agilent HPLC format and returns a formatted JSON with the data from it
* @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data
* @return {{times, series}} - JSON with the time, TIC and mass spectra values
*/
function fromAgilentHPLC(data) {
return agilentHPLC(new NetCDFReader(data));
}
/**
* Reads a NetCDF file with Finnigan format and returns a formatted JSON with the data from it

@@ -43,13 +82,29 @@ * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data

*/
function fromFinnigan(data) {
return finnigan(new NetCDFReader(data));
function fromFinniganGCMS(data) {
return finniganGCMS(new NetCDFReader(data));
}
function fromAiaTemplate(data) {
return aiaTemplate(new NetCDFReader(data));
return aiaTemplate(new NetCDFReader(data));
}
function addMeta(globalAttributes) {
var ans = {};
for (const item of globalAttributes) {
ans[item.name] = item.value;
}
return ans;
}
function addVariables(reader) {
for (let variable of reader.variables) {
variable.value = reader.getDataVariable(variable);
}
return reader.variables;
}
module.exports = netcdfGcms;
module.exports.fromAgilent = fromAgilent;
module.exports.fromFinnigan = fromFinnigan;
module.exports.fromAgilentGCMS = fromAgilentGCMS;
module.exports.fromAgilentHPLC = fromAgilentHPLC;
module.exports.fromFinniganGCMS = fromFinniganGCMS;
module.exports.fromAiaTemplate = fromAiaTemplate;
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