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

jcampconverter

Package Overview
Dependencies
Maintainers
6
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jcampconverter - npm Package Compare versions

Comparing version 2.10.2 to 2.11.0

19

package.json
{
"name": "jcampconverter",
"version": "2.10.2",
"version": "2.11.0",
"description": "Parse and convert JCAMP data",

@@ -12,5 +12,5 @@ "main": "./src/index.js",

"eslint-fix": "npm run eslint -- --fix",
"test": "run-s testonly eslint",
"test-travis": "eslint src && jest --coverage && codecov",
"testonly": "jest",
"test": "run-s test-only eslint",
"test-travis": "eslint src && jest --coverage",
"test-only": "jest",
"build": "cheminfo build --root JcampConverter --no-source-map",

@@ -41,11 +41,10 @@ "benchmark": "node benchmark/benchmark.js",

"cheminfo-tools": "^1.22.4",
"codecov": "^2.3.1",
"eslint": "^4.19.1",
"eslint-config-cheminfo": "^1.18.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.21.0",
"eslint": "^5.12.1",
"eslint-config-cheminfo": "^1.20.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jest": "^22.1.3",
"eslint-plugin-no-only-tests": "^2.0.1",
"jest": "^21.2.1",
"jest": "^23.6.0",
"npm-run-all": "^4.1.3"
}
}

@@ -9,6 +9,5 @@ 'use strict';

function convertToFloatArray(stringArray) {
var l = stringArray.length;
var floatArray = new Array(l);
for (var i = 0; i < l; i++) {
floatArray[i] = parseFloat(stringArray[i]);
var floatArray = [];
for (let i = 0; i < stringArray.length; i++) {
floatArray.push(parseFloat(stringArray[i]));
}

@@ -28,3 +27,4 @@ return floatArray;

nbContourLevels: 7,
noiseMultiplier: 5
noiseMultiplier: 5,
profiling: false
};

@@ -41,6 +41,6 @@

var ldr, dataLabel, dataValue, ldrs;
var i, ii, j, position, endLine, infos;
var position, endLine, infos;
var result = {};
result.profiling = [];
result.profiling = options.profiling ? [] : false;
result.logs = [];

@@ -74,3 +74,3 @@ var spectra = [];

for (i = 0, ii = ldrs.length; i < ii; i++) {
for (let i = 0; i < ldrs.length; i++) {
ldr = ldrs[i];

@@ -168,2 +168,3 @@ // This is a new LDR

if (dataValue.match(/.*\+\+.*/)) {
// ex: (X++(Y..Y))
if (!spectrum.deltaX) {

@@ -190,2 +191,13 @@ spectrum.deltaX =

}
if (dataLabel === 'PEAKASSIGNMENTS') {
if (wantXY) {
if (dataValue.match(/.*(XYA).*/)) {
// ex: (XYA)
parseXYA(spectrum, dataValue);
}
spectra.push(spectrum);
spectrum = new Spectrum();
}
continue;
}

@@ -221,2 +233,10 @@ if (dataLabel === 'TITLE') {

spectrum.yFactor = parseFloat(dataValue);
} else if (dataLabel === 'MAXX') {
spectrum.maxX = parseFloat(dataValue);
} else if (dataLabel === 'MINX') {
spectrum.minX = parseFloat(dataValue);
} else if (dataLabel === 'MAXY') {
spectrum.maxY = parseFloat(dataValue);
} else if (dataLabel === 'MINY') {
spectrum.minY = parseFloat(dataValue);
} else if (dataLabel === 'DELTAX') {

@@ -239,4 +259,4 @@ spectrum.deltaX = parseFloat(dataValue);

result.shiftOffsetNum = 0;
if (!result.shiftOffsetVal) {
result.shiftOffsetVal = parseFloat(dataValue);
if (!spectrum.shiftOffsetVal) {
spectrum.shiftOffsetVal = parseFloat(dataValue);
}

@@ -249,3 +269,3 @@ } else if (dataLabel === '$REFERENCEPOINT') {

// result.shiftOffsetNum = parseInt(parts[2].trim());
// result.shiftOffsetVal = parseFloat(parts[3].trim());
// spectrum.shiftOffsetVal = parseFloat(parts[3].trim());
} else if (dataLabel === 'VARNAME') {

@@ -293,2 +313,4 @@ ntuples.varname = dataValue.split(ntuplesSeparator);

spectrum[convertMSFieldToLabel(dataLabel)] = dataValue;
} else if (dataLabel === 'SAMPLEDESCRIPTION') {
spectrum.sampleDescription = dataValue;
}

@@ -310,6 +332,6 @@ if (dataLabel.match(options.keepRecordsRegExp)) {

var keys = Object.keys(ntuples);
for (i = 0; i < keys.length; i++) {
for (let i = 0; i < keys.length; i++) {
var key = keys[i];
var values = ntuples[key];
for (j = 0; j < values.length; j++) {
for (let j = 0; j < values.length; j++) {
if (!newNtuples[j]) newNtuples[j] = {};

@@ -342,6 +364,6 @@ newNtuples[j][key] = values[j];

if (spectra.length > 0) {
for (i = 0; i < spectra.length; i++) {
for (let i = 0; i < spectra.length; i++) {
spectrum = spectra[i];
if (spectrum.data.length > 0) {
for (j = 0; j < spectrum.data.length; j++) {
for (let j = 0; j < spectrum.data.length; j++) {
var data = spectrum.data[j];

@@ -409,5 +431,4 @@ var newData = {

var i;
var existingGCMSFields = [];
for (i = 0; i < GC_MS_FIELDS.length; i++) {
for (let i = 0; i < GC_MS_FIELDS.length; i++) {
var label = convertMSFieldToLabel(GC_MS_FIELDS[i]);

@@ -423,6 +444,6 @@ if (spectra[0][label]) {

for (i = 0; i < length; i++) {
for (let i = 0; i < length; i++) {
var spectrum = spectra[i];
chromatogram.times[i] = spectrum.pageValue;
for (var j = 0; j < existingGCMSFields.length; j++) {
for (let j = 0; j < existingGCMSFields.length; j++) {
chromatogram.series[existingGCMSFields[j]].data[i] = parseFloat(

@@ -467,4 +488,4 @@ spectrum[existingGCMSFields[j]]

}
if (result.shiftOffsetVal) {
var shift = spectrum.firstX - result.shiftOffsetVal;
if (spectrum.shiftOffsetVal) {
var shift = spectrum.firstX - spectrum.shiftOffsetVal;
spectrum.firstX = spectrum.firstX - shift;

@@ -491,6 +512,6 @@ spectrum.lastX = spectrum.lastX - shift;

var z = new Array(ySize);
for (var i = 0; i < ySize; i++) {
for (let i = 0; i < ySize; i++) {
z[i] = new Array(xSize);
var xVector = spectra[i].data[0];
for (var j = 0; j < xSize; j++) {
for (let j = 0; j < xSize; j++) {
var value = xVector[j * 2 + 1];

@@ -711,3 +732,4 @@ z[i][j] = value;

var ascii;
for (var i = 0; i < value.length; i++) {
let i = 0;
for (; i < value.length; i++) {
ascii = value.charCodeAt(i);

@@ -863,2 +885,22 @@ if (ascii === 13 || ascii === 10) {

function parseXYA(spectrum, value) {
var removeSymbolRegExp = /(\(+|\)+|<+|>+|\s+)/g;
spectrum.isXYAdata = true;
var values;
var currentData = [];
spectrum.data = [currentData];
var lines = value.split(/,? *,?[;\r\n]+ */);
for (let i = 1; i < lines.length; i++) {
values = lines[i]
.trim()
.replace(removeSymbolRegExp, '')
.split(',');
currentData.push(parseFloat(values[0]));
currentData.push(parseFloat(values[1]));
}
}
function parsePeakTable(spectrum, value, result) {

@@ -869,3 +911,3 @@ var removeCommentRegExp = /\$\$.*/;

spectrum.isPeaktable = true;
var i, ii, j, jj, values;
var values;
var currentData = [];

@@ -877,3 +919,3 @@ spectrum.data = [currentData];

for (i = 1, ii = lines.length; i < ii; i++) {
for (let i = 1; i < lines.length; i++) {
values = lines[i]

@@ -884,3 +926,3 @@ .trim()

if (values.length % 2 === 0) {
for (j = 0, jj = values.length; j < jj; j = j + 2) {
for (let j = 0; j < values.length; j = j + 2) {
// takes around 40% of the time to add and parse the 2 values nearly exclusively because of parseFloat

@@ -887,0 +929,0 @@ currentData.push(parseFloat(values[j]) * spectrum.xFactor);

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