From e61857d4a7c4823bdbd0e3e2318d4f34c0c930d2 Mon Sep 17 00:00:00 2001 From: Miguel Angel Asencio Hurtado Date: Thu, 6 Jul 2017 11:17:48 +0200 Subject: [PATCH] feat(massInPeaks): expose slot variable --- src/massInPeaks.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/massInPeaks.js b/src/massInPeaks.js index cb99698..844d4e4 100644 --- a/src/massInPeaks.js +++ b/src/massInPeaks.js @@ -9,20 +9,28 @@ import {integrate2D} from './util/integrate2D'; * @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.slot = 1] - When to merge two mass values intensities * @return {Array} - List of GSD objects with an extra 'ms' field with the integrated MS spectra */ export function massInPeaks(peakList, sampleMS, options = {}) { + const { + thresholdFactor = 0, + maxNumberPeaks = Number.MAX_VALUE, + groupWidth = 0, + slot = 1 + } = options; + // integrate MS for (let i = 0; i < peakList.length; ++i) { var serie = {dimension: 2, data: sampleMS}; - var integral = integrate2D(serie, peakList[i].left.index, peakList[i].right.index, 1); + var integral = integrate2D(serie, peakList[i].left.index, peakList[i].right.index, slot); var msSum = { x: integral[0], y: integral[1] }; - if (options.maxNumberPeaks || options.thresholdFactor || options.groupWidth) { - msSum = massFilter(msSum, options); + if (maxNumberPeaks || thresholdFactor || groupWidth) { + msSum = massFilter(msSum, {maxNumberPeaks, thresholdFactor, groupWidth}); } peakList[i].ms = msSum; }