package com.compomics.pride_asa_pipeline.logic.spectrum.filter.impl;

import com.compomics.pride_asa_pipeline.logic.spectrum.filter.NoiseFilter;
import com.compomics.pride_asa_pipeline.model.Peak;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Florian Reisinger
 *         Date: 10-Sep-2009
 * @since 0.1
 */
public class PeakNoiseFilter implements NoiseFilter {

    @Override
    public List<Peak> filterNoise(List<Peak> peaks, double threshold, double experimentalPrecursorMass) {
        if (peaks == null) {
            return null;
        }
        List<Peak> result = new ArrayList<Peak>();
        for (Peak peak : peaks) {
            //add the peak to the peak list if the peak intensity > threshold
            // and if the MZ ratio is not in 18D range of experimental precursor mass
            if (peak.getIntensity() >= threshold && !(experimentalPrecursorMass - 18 < peak.getMzRatio() && peak.getMzRatio() < experimentalPrecursorMass + 18)) {
                result.add(peak);
            }
        }
        return result;
    }
}

@@ -388,16 +388,85 @@
 ilter %7B%0D
+%0A    %0D%0A    private static final double PRECURSOR_MASS_WINDOW = 18.0;%0D
 %0A%0D%0A    @
@@ -984,18 +984,37 @@
 rMass - 
-18
+PRECURSOR_MASS_WINDOW
  %3C peak.
@@ -1077,18 +1077,37 @@
 rMass + 
-18
+PRECURSOR_MASS_WINDOW
 )) %7B%0D%0A  

add static variable PRECURSOR_MASS_WINDOW