Пример #1
0
            private static int RtRangeCompare(SwathSpectrumEntry item, SwathQuery query)
            {
                if (item.Rt < query.RtRange.LowValue)
                {
                    return(-1);
                }

                if (item.Rt > query.RtRange.HighValue)
                {
                    return(1);
                }

                return(0);
            }
Пример #2
0
            internal SwathSpectrumEntry SearchClosestRt(SwathQuery query)
            {
                IndexRange result;

                if (BinarySearch.Search(swathSpectra, query, RtRangeCompare, out result))
                {
                    return(IndexRange.EnumRange(swathSpectra, result)
                           .ItemAtMin(x => CalcLockRtDiffAbs(x, query)));
                }
                else
                {
                    return(null);
                }
            }
Пример #3
0
            internal MSSwath SearchClosestTargetMz(SwathQuery query)
            {
                IndexRange result;

                if (BinarySearch.Search(swathes, query.TargetMz, SearchCompare, out result))
                {
                    return(IndexRange.EnumRange(swathes, result)
                           .ItemAtMin(x => CalcTargetMzDiffAbs(x, query)));
                }
                else
                {
                    return(null);
                }
            }
Пример #4
0
        public Peak2D[] GetMS2(
            IMzLiteDataReader dataReader,
            SwathQuery query,
            Func <IEnumerable <Peak1D>, RangeQuery, Peak1D> mzRangeSelector = null)
        {
            if (dataReader == null)
            {
                throw new ArgumentNullException("dataReader");
            }
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            if (mzRangeSelector == null)
            {
                mzRangeSelector = GetClosestMz;
            }

            MSSwath swath = swathList.SearchClosestTargetMz(query);

            if (swath == null)
            {
                return(new Peak2D[0]);
            }

            SwathSpectrumEntry swathSpec = swath.SearchClosestRt(query);

            if (swathSpec == null)
            {
                return(new Peak2D[0]);
            }

            Peak1DArray spectrumPeaks = dataReader.ReadSpectrumPeaks(swathSpec.SpectrumID);

            Peak2D[] ms2Peaks = new Peak2D[query.CountMS2Masses];

            for (int i = 0; i < query.CountMS2Masses; i++)
            {
                RangeQuery           mzRange = query[i];
                IEnumerable <Peak1D> mzPeaks = BinarySearch.Search(spectrumPeaks.Peaks, mzRange, MzRangeCompare);
                Peak1D p = mzRangeSelector(mzPeaks, mzRange);
                ms2Peaks[i] = new Peak2D(p.Intensity, p.Mz, swathSpec.Rt);
            }

            return(ms2Peaks);
        }
Пример #5
0
 private static double CalcLockRtDiffAbs(SwathSpectrumEntry swathSpectrum, SwathQuery query)
 {
     return(Math.Abs(swathSpectrum.Rt - query.RtRange.LockValue));
 }
Пример #6
0
 internal IEnumerable <SwathSpectrumEntry> SearchAllRt(SwathQuery query)
 {
     return(BinarySearch.Search(swathSpectra, query, RtRangeCompare));
 }
Пример #7
0
 private static double CalcTargetMzDiffAbs(MSSwath swath, SwathQuery query)
 {
     return(Math.Abs(swath.SwathWindow.TargetMz - query.TargetMz));
 }