Example #1
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);
        }
Example #2
0
 internal IEnumerable <SwathSpectrumEntry> SearchAllRt(SwathQuery query)
 {
     return(BinarySearch.Search(swathSpectra, query, RtRangeCompare));
 }
Example #3
0
 internal IEnumerable <MSSwath> SearchAllTargetMz(double targetMz)
 {
     return(BinarySearch.Search(swathes, targetMz, SearchCompare));
 }