CSMSL.Analysis.Identification.SpectrumFragmentsMatch.MatchFragments C# (CSharp) Method

MatchFragments() public method

public MatchFragments ( IEnumerable fragments, Tolerance tolerance, double percentCutoff ) : IEnumerable
fragments IEnumerable
tolerance Tolerance
percentCutoff double
return IEnumerable
        public IEnumerable<Fragment> MatchFragments(IEnumerable<Fragment> fragments, Tolerance tolerance, double percentCutoff, params int[] chargeStates)
        {
            double basePeakInt = Spectrum.GetBasePeakIntensity();
            double lowThreshold = basePeakInt*percentCutoff;
            double summedIntensity = 0;
            double totalIntensity = Spectrum.GetTotalIonCurrent();
            foreach (Fragment fragment in fragments)
            {
                foreach (int chargeState in chargeStates)
                {
                    double mz = fragment.ToMz(chargeState);
                    var peak = Spectrum.GetClosestPeak(tolerance.GetRange(mz));
                    if (peak != null && peak.Intensity >= lowThreshold)
                    {
                        Add(new FragmentSpectralMatch(Spectrum, fragment, tolerance, chargeState));
                        yield return fragment;
                        summedIntensity += peak.Intensity;
                    }
                }
            }
            PercentTIC = 100.0*summedIntensity/totalIntensity;
        }