Skip to content

Commit

Permalink
feat(massInPeaks): expose slot variable
Browse files Browse the repository at this point in the history
  • Loading branch information
maasencioh committed Jul 6, 2017
1 parent 8f77d96 commit e61857d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/massInPeaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<object>} - 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;
}
Expand Down

0 comments on commit e61857d

Please sign in to comment.