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

chromatography

Package Overview
Dependencies
Maintainers
5
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromatography - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

src/fromJcamp.js

7

package.json
{
"name": "chromatography",
"version": "1.2.0",
"version": "2.0.0",
"description": "Tools for storing, search and analize GC/MS spectra",

@@ -54,9 +54,10 @@ "main": "src/index.js",

"eslint-plugin-no-only-tests": "^1.1.0",
"jcampconverter": "^2.3.0",
"nyc": "^8.3.0"
},
"dependencies": {
"ml-gsd": "mljs/global-spectral-deconvolution#peak-high",
"binary-search": "^1.3.2",
"jcampconverter": "^2.3.0",
"ml-gsd": "^2.0.1",
"ml-regression": "^4.1.1"
}
}

@@ -9,3 +9,3 @@ # chromatography

> Tools for storing, search and analize GC/MS spectra
> Tools for storing, search and analyze GC/MS spectra

@@ -16,13 +16,28 @@ https://docs.google.com/document/d/1Jg2l6wKjFCYBSqdVWBSujSkqMhsEV6ZMyxeI9RSLhn0/edit#heading=h.8gjgl6jygt0s

```bash
npm install chromatography
```
`npm install chromatography`
## [API Documentation](https://cheminfo-js.github.io/chromatography/)
## Test
## Example
```bash
npm install
npm test
```js
const GCMS = require('chromatography');
let gcms = GCMS.fromJcamp(jcampReferenceMixture);
let kovatsConversionTable = GCMS.getKovatsTable(gcms); // [{time, value}, ]
let conversionFunction = GCMS.kovatsConversionFunction(kovatsConversionTable, {});
let diesel = GCMS.fromJcamp(jcampOfDiesel);
let times = GCMS.rescaleTime(diesel.getTimes(), conversionFunction);
diesel.setTimes(times);
// diesel.rescaleTime(conversionFunction);
let peaks = GCMS.getPeaks(diesel, options);
let dieselJSON = diesel.toJSON(options); // [ {time:12, height:12, width: 3, mass: [{mass, intensity}]} ]
let gcms2 = GCMS.fromJSON(anotherDieselJSON);
let similarity = GCMS.similarity(gcms, gcms2, options)
// get a spectrum in another reference model
let revertConversionFunction = GCMS.kovatsConversionFunction(kovatsConversionTable, {revert: true});
let mySpectrumInAnotherReference = mySpectrum
```

@@ -29,0 +44,0 @@

'use strict';
const rescaleTime = require('./rescaleTime');
/**

@@ -7,3 +9,3 @@ * Class allowing to store time / ms (ms) series

* @class Chromatogram
* @param {Object|Array<Number>} data - A GC/MS data format object or a time serie
* @param {object|Array<number>} data - A GC/MS data format object or a time serie
*/

@@ -35,4 +37,4 @@ class Chromatogram {

* Find the serie giving the name
* @param {String} name - name of the serie
* @return {Object} - Object with an array of data, dimensions of the elements in the array and name of the serie
* @param {string} name - name of the serie
* @return {object} - Object with an array of data, dimensions of the elements in the array and name of the serie
*/

@@ -45,3 +47,3 @@ findSerieByName(name) {

* Add a new serie
* @param {Object} serie - Object with an array of data, dimensions of the elements in the array and name of the serie
* @param {object} serie - Object with an array of data, dimensions of the elements in the array and name of the serie
*/

@@ -66,3 +68,3 @@ addSerie(serie) {

* Returns the first time value
* @return {Number} - First time value
* @return {number} - First time value
*/

@@ -75,3 +77,3 @@ getFirstTime() {

* Returns the last time value
* @return {Number} - Last time value
* @return {number} - Last time value
*/

@@ -84,3 +86,3 @@ getLastTime() {

* Returns the time values
* @return {Array<Number>} - Time values
* @return {Array<number>} - Time values
*/

@@ -90,4 +92,52 @@ getTimes() {

}
/**
* Assign the time values
* @param {Array<number>} times - New time values
*/
setTimes(times) {
this.times = times;
}
/**
* Modifies the time applying the conversion function
* @param {function(number)} conversionFunction
*/
rescaleTime(conversionFunction) {
this.times = rescaleTime(this.times, conversionFunction);
}
/**
* Parse the content to an JSON Array
* @return {Array<object>} - Returns a list with the following fields:
* * `time`: Number for the retention time
* * `tic`: Number for the total ion chromatogram
* * `mass`: List of mass values and their respective intensities
*/
toJSON() {
var ans = new Array(this.times.length);
const tic = this.findSerieByName('tic').data;
const mass = this.findSerieByName('ms').data.map((ms) => {
var ansMS = new Array(ms[0].length);
for (var i = 0; i < ansMS.length; i++) {
ansMS[i] = {
mass: ms[0][i],
intensity: ms[1][i]
};
}
return ansMS;
});
for (var i = 0; i < ans.length; i++) {
ans[i] = {
time: this.times[i],
tic: tic[i],
mass: mass[i]
};
}
return ans;
}
}
module.exports = Chromatogram;

@@ -5,7 +5,7 @@ 'use strict';

* Cosine similarity between two MS spectra
* @param {Array<Number>} ms1x - Array of mass values for the first spectra
* @param {Array<Number>} ms1y - Array of weighted abundance values for the first spectra
* @param {Array<Number>} ms2x - Array of mass values for the second spectra
* @param {Array<Number>} ms2y - Array of weighted abundance values for the second spectra
* @return {Number} - Similarity between two MS spectra
* @param {Array<number>} ms1x - Array of mass values for the first spectra
* @param {Array<number>} ms1y - Array of weighted abundance values for the first spectra
* @param {Array<number>} ms2x - Array of mass values for the second spectra
* @param {Array<number>} ms2y - Array of weighted abundance values for the second spectra
* @return {number} - Similarity between two MS spectra
*/

@@ -12,0 +12,0 @@ function cosine(ms1x, ms1y, ms2x, ms2y) {

@@ -6,3 +6,3 @@ 'use strict';

// Chromatography utils
exports.peakPicking = require('./peakPicking');
exports.getPeaks = require('./getPeaks');
exports.massInPeaks = require('./massInPeaks');

@@ -15,1 +15,6 @@ exports.vectorify = require('./vectorify');

exports.kovats = require('./kovats');
exports.getKovatsTable = require('./getKovatsTable');
exports.kovatsConversionFunction = require('./kovatsConversionFunction');
exports.rescaleTime = require('./rescaleTime');
exports.fromJcamp = require('./fromJcamp');
exports.fromJSON = require('./fromJSON');

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

* Calculates the Kovats retention index for a mass spectra of a n-alkane
* @param {Object} ms - An mass spectra object
* @param {Array<Number>} ms.x - Array of masses
* @param {Array<Number>} ms.y - Array of intensities
* @return {Number} - Kovats retention index
* @param {object} ms - An mass spectra object
* @param {Array<number>} ms.x - Array of masses
* @param {Array<number>} ms.y - Array of intensities
* @return {number} - Kovats retention index
*/

@@ -11,0 +11,0 @@ function kovats(ms) {

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

* @ignore
* @param {Array<Object>} list - Sorted list of XY-objects to be filtered
* @param {Number} maxNumberPeaks - Maximum number of peaks for each mass spectra
* @param {Number} groupWidth - When find a max can't be another max in a radius of this size
* @return {Array<Object>} - List of XY-objects filtered
* @param {Array<object>} list - Sorted list of XY-objects to be filtered
* @param {number} maxNumberPeaks - Maximum number of peaks for each mass spectra
* @param {number} groupWidth - When find a max can't be another max in a radius of this size
* @return {Array<object>} - List of XY-objects filtered
*/

@@ -35,10 +35,10 @@ function moreDistinct(list, maxNumberPeaks, groupWidth) {

* Filters a mass object
* @param {Object} massXYObject - Object with x and y data
* @param {Array<Number>} massXYObject.x - Array of mass values
* @param {Array<Number>} massXYObject.y - Array of abundance values
* @param {Object} options - Options for the integral filtering
* @param {Number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {Number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {Number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {Object} - Object with filtered x and y data
* @param {object} massXYObject - Object with x and y data
* @param {Array<number>} massXYObject.x - Array of mass values
* @param {Array<number>} massXYObject.y - Array of abundance values
* @param {object} options - Options for the integral filtering
* @param {number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {object} - Object with filtered x and y data
*/

@@ -45,0 +45,0 @@ function massFilter(massXYObject, options = {}) {

@@ -7,9 +7,9 @@ 'use strict';

* Integrate MS spectra of a peak list
* @param {Array<Object>} peakList - List of GSD objects
* @param {Array<Object>} sampleMS - MS array of GC spectra
* @param {Object} options - Options for the integral filtering
* @param {Number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {Number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {Number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {Array<Object>} - List of GSD objects with an extra 'ms' field with the integrated MS spectra
* @param {Array<object>} peakList - List of GSD objects
* @param {Array<object>} sampleMS - MS array of GC spectra
* @param {object} options - Options for the integral filtering
* @param {number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {Array<object>} - List of GSD objects with an extra 'ms' field with the integrated MS spectra
*/

@@ -16,0 +16,0 @@ function massInPeaks(peakList, sampleMS, options = {}) {

@@ -7,16 +7,15 @@ 'use strict';

* Aligns the time of the sample based on the regression with his reference value
* @param {Array<Object>} reference - Array of peaks, integrated mass spectra and weighted mass spectra for the reference chromatogram
* @param {Array<Object>} sample - Array of peaks, integrated mass spectra and weighted mass spectra for the sample chromatogram
* @param {Object} [options] - Options object
* @param {Boolean} [options.computeQuality = false] - Calculate the quality of the regression
* @param {Number} [options.stringFormula = 0] - Precision of the string formula (0 if don't need the value)
* @param {Number} [options.polynomialDegree = 3] - Degree of the polynomial regression
* @return {Object} - The scaled spectra:
* * `reference`: The reference array
* * `sample`: The scaled sample array
* @param {Array<object>} reference - Array of peaks, integrated mass spectra and weighted mass spectra for the reference chromatogram
* @param {Array<object>} sample - Array of peaks, integrated mass spectra and weighted mass spectra for the sample chromatogram
* @param {object} [options] - Options object
* @param {boolean} [options.computeQuality = false] - Calculate the quality of the regression
* @param {number} [options.polynomialDegree = 3] - Degree of the polynomial regression
* @return {object} - The scaled spectra:
* * `scaleRegression`: The regression function to make the regression
* * `stringFormula`: Regression equation
* * `r2`: R2 quality number
* * `error`: Vector of the difference between the spected value and the actual shift value
*/
function scaleAlignment(reference, sample, options = {}) {
const {computeQuality = false, stringFormula = 0, polynomialDegree = 3} = options;
const {computeQuality = false, polynomialDegree = 3} = options;
let referenceTime = reference.map((val) => val.x);

@@ -27,18 +26,14 @@ let sampleTime = sample.map((val) => val.x);

const maxTime = Math.max(...referenceTime);
let scaledSample = sample.map((peak) => {
peak.x = regression.predict(peak.x);
return peak;
}).filter((peak) => peak.x <= maxTime);
let error = new Array(sample.length);
for (var i = 0; i < sample.length; i++) {
error[i] = reference[i].x - regression.predict(sample[i].x);
}
let ans = {
reference: reference,
sample: scaledSample
scaleRegression: regression
};
if (stringFormula !== 0) {
ans.stringFormula = regression.toString(stringFormula);
}
if (computeQuality) {
ans.r2 = regression.quality.r2;
ans.error = error;
}

@@ -45,0 +40,0 @@ return ans;

'use strict';
const peakPicking = require('./peakPicking');
const getPeaks = require('./getPeaks');
const massInPeaks = require('./massInPeaks');

@@ -12,8 +12,8 @@ const vectorify = require('./vectorify');

* @param {Chromatogram} chromatography - Chromatogram to process
* @param {Object} [options] - Options object (same as spectraComparison)
* @return {{peaks: Array<Object>, integratedMs: Array<Object>, vector: Array<Object>}} - Array of peaks, integrated mass spectra and weighted mass spectra
* @param {object} [options] - Options object (same as spectraComparison)
* @return {{peaks: Array<object>, integratedMs: Array<object>, vector: Array<object>}} - Array of peaks, integrated mass spectra and weighted mass spectra
*/
function preprocessing(chromatography, options) {
// peak picking
let peaks = peakPicking(chromatography, options);
let peaks = getPeaks(chromatography, options);
peaks = peaks.sort((a, b) => a.index - b.index);

@@ -47,14 +47,14 @@

* @param {Chromatogram} chrom2 - Second chromatogram
* @param {Object} [options] - Options object
* @param {Number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {Number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {Number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @param {Number} [options.heightFilter = 2] - Filter all objects that are bellow `heightFilter` times the median of the height
* @param {Number} [options.massPower = 3] - Power applied to the mass values
* @param {Number} [options.intPower = 0.6] - Power applied to the abundance values
* @param {Number} [options.similarityThreshold = 0.7] - Minimum similarity value to consider them similar
* @return {Object} - Most similar peaks and their similarities:
* @param {object} [options] - Options object
* @param {number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @param {number} [options.heightFilter = 2] - Filter all objects that are bellow `heightFilter` times the median of the height
* @param {number} [options.massPower = 3] - Power applied to the mass values
* @param {number} [options.intPower = 0.6] - Power applied to the abundance values
* @param {number} [options.similarityThreshold = 0.7] - Minimum similarity value to consider them similar
* @return {object} - Most similar peaks and their similarities:
* * `peaksFirst`: Array of peaks, integrated mass spectra and weighted mass spectra for the first chromatogram
* * `peaksSecond`: Array of peaks, integrated mass spectra and weighted mass spectra for the second chromatogram
* * `peaksSimilarity`: Array of similarities (Number)
* * `peaksSimilarity`: Array of similarities (number)
*/

@@ -106,3 +106,3 @@ function spectraComparison(chrom1, chrom2, options) {

for (let i = 0; i < similarLen; ++i) {
if (duplicates.hasOwnProperty(similarityPeaks.chrom1[i].x)) {
if ({}.hasOwnProperty.call(duplicates, similarityPeaks.chrom1[i].x)) {
duplicates[similarityPeaks.chrom1[i].x].push(i);

@@ -109,0 +109,0 @@ } else {

@@ -7,10 +7,10 @@ 'use strict';

* Given a list of GSD objects returns the weighted mass times abundance
* @param {Array<Object>} peakList - List of GSD objects
* @param {Object} options - Options for the integral filtering
* @param {Number} [options.massPower = 3] - Power applied to the mass values
* @param {Number} [options.intPower = 0.6] - Power applied to the abundance values
* @param {Number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {Number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {Number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {Array<Object>} - List of mass and weighted mass times abundance objects
* @param {Array<object>} peakList - List of GSD objects
* @param {object} options - Options for the integral filtering
* @param {number} [options.massPower = 3] - Power applied to the mass values
* @param {number} [options.intPower = 0.6] - Power applied to the abundance values
* @param {number} [options.thresholdFactor = 0] - Every peak that it's bellow the main peak times this factor fill be removed (when is 0 there's no filter)
* @param {number} [options.maxNumberPeaks = Number.MAX_VALUE] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)
* @param {number} [options.groupWidth = 0] - When find a max can't be another max in a radius of this size
* @return {Array<object>} - List of mass and weighted mass times abundance objects
*/

@@ -17,0 +17,0 @@ function vectorify(peakList, options = {}) {

@@ -6,3 +6,3 @@ import test from 'ava';

import {join} from 'path';
import {Chromatogram, massInPeaks, peakPicking, vectorify, cosine} from '..';
import {Chromatogram, massInPeaks, getPeaks, vectorify, cosine} from '..';

@@ -23,3 +23,3 @@ const readFileAsync = Promise.promisify(fs.readFile);

let peakList = peakPicking(chrom);
let peakList = getPeaks(chrom);
t.is(peakList.length, 312);

@@ -63,3 +63,3 @@

let peakList = peakPicking(chrom);
let peakList = getPeaks(chrom);
t.is(peakList.length, 1);

@@ -66,0 +66,0 @@

import test from 'ava';
import {convert} from 'jcampconverter';
import fs from 'fs';
import Promise from 'bluebird';
import {join} from 'path';
import {Chromatogram} from '..';
import {fromJcamp} from '..';

@@ -13,5 +12,4 @@ const readFileAsync = Promise.promisify(fs.readFile);

const jcamp = await readFileAsync(path, 'utf8');
const data = convert(jcamp, {newGCMS: true}).gcms;
const chrom = new Chromatogram(data);
const chrom = fromJcamp(jcamp);
t.is(chrom.length, 6993);
});

@@ -46,5 +46,5 @@ import test from 'ava';

let mass = [
[ [1, 2], [1, 1] ],
[ [1, 2, 5], [1, 1, 1] ],
[ [2, 4], [1, 1] ]
[[1, 2], [1, 1]],
[[1, 2, 5], [1, 1, 1]],
[[2, 4], [1, 1]]
];

@@ -65,3 +65,3 @@

let peaks = [
{ ms: {
{ms: {
x: [1, 2, 3],

@@ -68,0 +68,0 @@ y: [1, 1, 1]

@@ -6,3 +6,3 @@ import test from 'ava';

import {join} from 'path';
import {Chromatogram, massInPeaks, peakPicking} from '..';
import {Chromatogram, massInPeaks, getPeaks} from '..';

@@ -23,3 +23,3 @@ const readFileAsync = Promise.promisify(fs.readFile);

let peakList = peakPicking(chrom);
let peakList = getPeaks(chrom);
t.is(peakList.length, 312);

@@ -56,3 +56,3 @@

let peaks = peakPicking(chrom);
let peaks = getPeaks(chrom);
t.is(peaks.length, 1);

@@ -73,5 +73,5 @@

t.deepEqual(massInPeaks(peaks, [
[ [1, 2], [1, 1] ],
[ [1, 2, 5], [1, 1, 1] ],
[ [3, 4], [1, 1] ]
[[1, 2], [1, 1]],
[[1, 2, 5], [1, 1, 1]],
[[3, 4], [1, 1]]
]), [{

@@ -93,5 +93,5 @@ left: {index: 0},

let mass = [
[ [1, 2], [1, 1] ],
[ [1, 2, 5], [1, 1, 1] ],
[ [2, 4], [1, 1] ]
[[1, 2], [1, 1]],
[[1, 2, 5], [1, 1, 1]],
[[2, 4], [1, 1]]
];

@@ -115,5 +115,5 @@

let mass = [
[ [1, 2], [1, 1] ],
[ [1, 2, 5], [1, 1, 1] ],
[ [2, 4], [1, 2] ]
[[1, 2], [1, 1]],
[[1, 2, 5], [1, 1, 1]],
[[2, 4], [1, 2]]
];

@@ -120,0 +120,0 @@

@@ -54,9 +54,8 @@ import test from 'ava';

let compared = spectraComparison(chrom1, chrom2, options);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [30, 40, 50, 60]);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [10, 20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [20, 30, 40, 50, 60]);
let aligned = scaleAlignment(compared.peaksFirst, compared.peaksSecond);
t.deepEqual(aligned.reference.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(aligned.sample.map((val) => val.x), [20, 30, 40, 50]);
t.is(Math.abs(aligned.scaleRegression.predict(30) - 20) < 1e-4, true);
});

@@ -109,11 +108,10 @@

let compared = spectraComparison(chrom1, chrom2, options);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [30, 40, 50, 60]);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [10, 20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [20, 30, 40, 50, 60]);
let aligned = scaleAlignment(compared.peaksFirst, compared.peaksSecond, {computeQuality: true, stringFormula: 3});
t.deepEqual(aligned.reference.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(aligned.sample.map((val) => val.x), [20, 30, 40, 50]);
t.is(aligned.stringFormula, 'y = 1.00*x-10.0');
t.is(aligned.r2, 1);
t.is(Math.abs(aligned.scaleRegression.predict(30) - 20) < 1e-4, true);
t.is(aligned.scaleRegression.toString(3), 'f(x) = 9.95e-17 * x^3 - 1.22e-14 * x^2 + 1.00 * x - 10.0');
t.is(Math.abs(aligned.r2 - 1) < 1e-4, true);
});

@@ -54,5 +54,5 @@ import test from 'ava';

let compared = spectraComparison(chrom1, chrom2, options);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [30, 40, 50, 60]);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [10, 20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [20, 30, 40, 50, 60]);
});

@@ -105,5 +105,5 @@

let compared = spectraComparison(chrom1, chrom2, options);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [30, 40, 50]);
t.deepEqual(compared.peaksSimilarity, [1, 1, 1, 1]);
t.deepEqual(compared.peaksFirst.map((val) => val.x), [20, 30, 40, 50]);
t.deepEqual(compared.peaksSecond.map((val) => val.x), [20, 30, 40, 50]);
});

@@ -126,3 +126,3 @@

if (i < 45) {
ms2[i] = [[ 28, 29, 30, 31, 32, 56, 58, 60, 62, 64, 84, 87, 90, 93, 96 ], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
ms2[i] = [[28, 29, 30, 31, 32, 56, 58, 60, 62, 64, 84, 87, 90, 93, 96], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
} else {

@@ -129,0 +129,0 @@ ms2[i] = [[i, 2 * i, 3 * i], [1, 1, 1]];

@@ -6,3 +6,3 @@ import test from 'ava';

import {join} from 'path';
import {Chromatogram, massInPeaks, peakPicking, vectorify} from '..';
import {Chromatogram, massInPeaks, getPeaks, vectorify} from '..';

@@ -23,3 +23,3 @@ const readFileAsync = Promise.promisify(fs.readFile);

let peakList = peakPicking(chrom);
let peakList = getPeaks(chrom);
t.is(peakList.length, 312);

@@ -59,3 +59,3 @@

let peakList = peakPicking(chrom);
let peakList = getPeaks(chrom);
t.is(peakList.length, 1);

@@ -74,3 +74,3 @@

let peaks = [
{ ms: {
{ms: {
x: [1, 2, 3],

@@ -77,0 +77,0 @@ y: [1, 1, 1]

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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