示例#1
0
        public static void MakeChromatogramInfo(SignedMz precursorMz, LibraryChromGroup chromGroup, LibraryChromGroup.ChromData chromData, out ChromatogramInfo chromatogramInfo, out TransitionChromInfo transitionChromInfo)
        {
            var crawPeakFinder = Crawdads.NewCrawdadPeakFinder();

            crawPeakFinder.SetChromatogram(chromGroup.Times, chromData.Intensities);
            var crawdadPeak =
                crawPeakFinder.GetPeak(
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.StartTime),
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.EndTime));
            var chromPeak = new ChromPeak(crawPeakFinder, crawdadPeak, 0, chromGroup.Times, chromData.Intensities, null);

            transitionChromInfo = new TransitionChromInfo(null, 0, chromPeak, new float?[0], Annotations.EMPTY,
                                                          UserSet.FALSE);
            var peaks  = new[] { chromPeak };
            var header = new ChromGroupHeaderInfo(precursorMz,
                                                  0,                       // file index
                                                  1,                       // numTransitions
                                                  0,                       // startTransitionIndex
                                                  peaks.Length,            // numPeaks
                                                  0,                       // startPeakIndex
                                                  0,                       // startscoreindex
                                                  0,                       // maxPeakIndex
                                                  chromGroup.Times.Length, // numPoints
                                                  0,                       // compressedSize
                                                  0,                       // uncompressedsize
                                                  0,                       //location
                                                  0, -1, -1, null, null);

            chromatogramInfo = new ChromatogramInfo(header,
                                                    new Dictionary <Type, int>(), 0,
                                                    new ChromCachedFile[0],
                                                    new[] { new ChromTransition(chromData.Mz, 0, 0, 0, ChromSource.unknown), },
                                                    peaks, null,
                                                    chromGroup.Times, new[] { chromData.Intensities }, null, null);
        }
示例#2
0
        private IEnumerable <IFoundPeak> FindIntervalPeaks(float intervalStart, float intervalEnd, IList <int> identifiedIndices)
        {
            int startIndex = Times.BinarySearch(intervalStart);

            if (startIndex < 0)
            {
                startIndex = Math.Max(0, ~startIndex - 1);
            }

            int endIndex = Times.BinarySearch(intervalEnd);

            if (endIndex < 0)
            {
                endIndex = Math.Min(Times.Count - 1, ~endIndex);
            }

            if (endIndex <= startIndex)
            {
                yield break;
            }

            var times                = Times.Skip(startIndex).Take(endIndex - startIndex + 1).ToArray();
            var intensities          = Intensities.Skip(startIndex).Take(endIndex - startIndex + 1).ToArray();
            var subIdentifiedIndices = identifiedIndices.Select(index => index - startIndex).ToArray();
            var subFinder            = Crawdads.NewCrawdadPeakFinder();

            subFinder.SetChromatogram(times, intensities);
            foreach (var peak in subFinder.CalcPeaks(MAX_PEAKS, subIdentifiedIndices))
            {
                yield return(Finder.GetPeak(peak.StartIndex + startIndex, peak.EndIndex + startIndex));
            }
        }
示例#3
0
        public void FindPeaks(double[] retentionTimes, TimeIntervals timeIntervals, ExplicitRetentionTimeInfo explicitRT)
        {
            Finder = Crawdads.NewCrawdadPeakFinder();
            Finder.SetChromatogram(Times, Intensities);
            if (timeIntervals == null)
            {
                RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes));
            }
            else
            {
                var identifiedIndices = TimesToIndices(retentionTimes);
                var allPeaks          = timeIntervals.Intervals.SelectMany(interval =>
                                                                           FindIntervalPeaks(interval.Key, interval.Value, identifiedIndices));
                RawPeaks = allPeaks.OrderByDescending(peak => Tuple.Create(peak.Identified, peak.Area))
                           .Take(MAX_PEAKS).ToArray();
            }
            // Calculate smoothing for later use in extending the Crawdad peaks
            IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray());

            // Accept only peaks within the user-provided RT window, if any
            if (explicitRT != null)
            {
                var winLow  = (float)(explicitRT.RetentionTime - 0.5 * (explicitRT.RetentionTimeWindow ?? 0));
                var winHigh = winLow + (float)(explicitRT.RetentionTimeWindow ?? 0);
                RawPeaks = RawPeaks.Where(rp =>
                {
                    var t = Times[rp.TimeIndex];
                    return(winLow <= t && t <= winHigh);
                });
            }
        }
示例#4
0
 public void FindPeaks(double[] retentionTimes)
 {
     Finder = Crawdads.NewCrawdadPeakFinder();
     Finder.SetChromatogram(Times, Intensities);
     RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes));
     // Calculate smoothing for later use in extending the Crawdad peaks
     IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray());
 }
示例#5
0
 public void SetExplicitPeakBounds(ExplicitPeakBounds peakBounds)
 {
     Finder = Crawdads.NewCrawdadPeakFinder();
     Finder.SetChromatogram(Times, Intensities);
     if (peakBounds.IsEmpty)
     {
         RawPeaks = new IFoundPeak[0];
     }
     else
     {
         RawPeaks = new[] { Finder.GetPeak(TimeToIndex(peakBounds.StartTime), TimeToIndex(peakBounds.EndTime)) };
     }
 }
示例#6
0
 public void FindPeaks(double[] retentionTimes, bool requireDocNode)
 {
     Finder = Crawdads.NewCrawdadPeakFinder();
     Finder.SetChromatogram(Times, Intensities);
     if (requireDocNode && DocNode == null)
     {
         RawPeaks = new IFoundPeak[0];
     }
     else
     {
         RawPeaks = Finder.CalcPeaks(MAX_PEAKS, TimesToIndices(retentionTimes));
         // Calculate smoothing for later use in extending the Crawdad peaks
         IntensitiesSmooth = ChromatogramInfo.SavitzkyGolaySmooth(Intensities.ToArray());
     }
 }
示例#7
0
        public static void MakeChromatogramInfo(SignedMz precursorMz, LibraryChromGroup chromGroup, LibraryChromGroup.ChromData chromData, out ChromatogramInfo chromatogramInfo, out TransitionChromInfo transitionChromInfo)
        {
            var timeIntensities = new TimeIntensities(chromGroup.Times, chromData.Intensities, null, null);
            var crawPeakFinder  = Crawdads.NewCrawdadPeakFinder();

            crawPeakFinder.SetChromatogram(chromGroup.Times, chromData.Intensities);
            var crawdadPeak =
                crawPeakFinder.GetPeak(
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.StartTime),
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.EndTime));
            var chromPeak = new ChromPeak(crawPeakFinder, crawdadPeak, 0, timeIntensities, null);

            transitionChromInfo = new TransitionChromInfo(null, 0, chromPeak,
                                                          IonMobilityFilter.EMPTY, // CONSIDER(bspratt) IMS in chromatogram libraries?
                                                          new float?[0], Annotations.EMPTY,
                                                          UserSet.FALSE);
            var peaks  = new[] { chromPeak };
            var header = new ChromGroupHeaderInfo(precursorMz,
                                                  0,                                                    // file index
                                                  1,                                                    // numTransitions
                                                  0,                                                    // startTransitionIndex
                                                  peaks.Length,                                         // numPeaks
                                                  0,                                                    // startPeakIndex
                                                  0,                                                    // startscoreindex
                                                  0,                                                    // maxPeakIndex
                                                  chromGroup.Times.Length,                              // numPoints
                                                  0,                                                    // compressedSize
                                                  0,                                                    // uncompressedsize
                                                  0,                                                    //location
                                                  0, -1, -1, null, null, null, eIonMobilityUnits.none); // CONSIDER(bspratt) IMS in chromatogram libraries?
            var driftTimeFilter = IonMobilityFilter.EMPTY;                                              // CONSIDER(bspratt) IMS in chromatogram libraries?
            var groupInfo       = new ChromatogramGroupInfo(header,
                                                            new Dictionary <Type, int>(),
                                                            new byte[0],
                                                            new ChromCachedFile[0],
                                                            new[] { new ChromTransition(chromData.Mz, 0, (float)(driftTimeFilter.IonMobility.Mobility ?? 0), (float)(driftTimeFilter.IonMobilityExtractionWindowWidth ?? 0), ChromSource.unknown), },
                                                            peaks,
                                                            null)
            {
                TimeIntensitiesGroup = TimeIntensitiesGroup.Singleton(timeIntensities)
            };

            chromatogramInfo = new ChromatogramInfo(groupInfo, 0);
        }
示例#8
0
 public void SetExplicitPeakBounds(PeakBounds peakBounds)
 {
     Finder = Crawdads.NewCrawdadPeakFinder();
     Finder.SetChromatogram(Times, Intensities);
     RawPeaks = new [] { Finder.GetPeak(TimeToIndex(peakBounds.StartTime), TimeToIndex(peakBounds.EndTime)) };
 }
示例#9
0
 public void SkipFindingPeaks(double[] retentionTimes)
 {
     Finder = Crawdads.NewCrawdadPeakFinder();
     Finder.SetChromatogram(Times, Intensities);
     RawPeaks = new IFoundPeak[0];
 }