Beispiel #1
0
 public void NarrowPeak(ChromDataPeakList peakSet, PeptideChromDataPeak narrowestPeptidePeak, int indexSet)
 {
     var peak = peakSet[0].Peak;
     if (peak != null)
     {
         int len = narrowestPeptidePeak.Length;
         if (narrowestPeptidePeak.IsRightBound)
             peak.ResetBoundaries(peak.EndIndex - len + 1, peak.EndIndex);
         else // if (narrowestPeptidePeak.IsLeftBound)  Need to make sure they are the same length
             peak.ResetBoundaries(peak.StartIndex, peak.StartIndex + len - 1);
     }
 }
Beispiel #2
0
        public ChromDataPeakList SetBestPeak(ChromDataPeakList peakSet, PeptideChromDataPeak bestPeptidePeak, int indexSet)
        {
            ChromDataPeakList peakSetAdd = null;
            int startIndex, endIndex;
            // TODO: Need to do something more reasonable for Deuterium elution time shifts
            bool matchBounds = GetLocalPeakBounds(bestPeptidePeak, out startIndex, out endIndex);

            if (peakSet != null)
            {
                // If the peak ranked by peptide matching is not in its proper position,
                // then move it there
                if (!ReferenceEquals(peakSet, _listPeakSets[indexSet]))
                {
                    _listPeakSets.Remove(peakSet);
                    _listPeakSets.Insert(indexSet, peakSet);
                }
                // If there is a different best peptide peak, and it should have
                // the same retention time charachteristics, then reset the integration
                // boundaries of this peak set
                if (matchBounds)
                {
                    var peak = peakSet[0].Peak;
                    // If this peak and the best peak for this peptide are allowed to be shifted in
                    // relationship to each other, then make that shift be the delta between the apex
                    // times of the two peaks.  They still need to be the same width.
                    if (!IsSameRT(bestPeptidePeak.Data))
                    {
                        int deltaBounds = GetLocalIndex(bestPeptidePeak.TimeIndex) - peak.TimeIndex;
                        startIndex = Math.Max(0, startIndex + deltaBounds);
                        endIndex = Math.Min(Times.Length - 1, endIndex + deltaBounds);
                    }

                    // Reset the range of the best peak, if the chromatograms for this peak group
                    // overlap with the best peptide peak at all.  Resetting the range of the best
                    // peak for this peak group will cause it and all other peaks in the peak group
                    // to be reintegrated to this range
                    if (startIndex < endIndex)
                    {
                        peak.ResetBoundaries(startIndex, endIndex);
                    }
                    // In a peak set with mutiple charge states and light-heavy pairs, it is
                    // possible that a peak may not overlap with the best peak in its
                    // charge group.  If this is the case, and the best peak is completely
                    // outside the bounds of the current chromatogram, then insert an
                    // empty peak.
                    else
                    {
                        var peakAdd = new ChromDataPeak(BestChromatogram, null);
                        peakSetAdd = new ChromDataPeakList(peakAdd, _listChromData) { IsForcedIntegration = true };
                    }
                }
            }
            // If no peak was found at the peptide level for this data set,
            // but there is a best peak for the peptide
            else if (bestPeptidePeak != null && matchBounds)
            {
                // And the chromatograms for this transition group overlap with the best peptide
                // peak, then create a peak with the same extents as the best peak.  This peak will
                // appear as missing, if Integrate All is not selected.
                ChromDataPeak peakAdd;
                if (startIndex < endIndex)
                {
                    // CONSIDER: Not that great for peaks that are expected to be shifted in relationship
                    //           to each other, since this will force them to have the same boundaries,
                    //           but if no evidence of a peak was found, it is hard to understand what
                    //           could be done better.
                    var chromData = BestChromatogram;
                    peakAdd = new ChromDataPeak(chromData, chromData.CalcPeak(startIndex, endIndex));
                }
                // Otherwise, create an empty peak
                else
                {
                    peakAdd = new ChromDataPeak(BestChromatogram, null);
                }

                peakSetAdd = new ChromDataPeakList(peakAdd, _listChromData) {IsForcedIntegration = true};
            }
            else
            {
                // Otherwise, insert an empty peak
                var peakAdd = new ChromDataPeak(BestChromatogram, null);
                peakSetAdd = new ChromDataPeakList(peakAdd, _listChromData) { IsForcedIntegration = true };
            }

            if (peakSetAdd != null)
            {
                if (indexSet < _listPeakSets.Count)
                    _listPeakSets.Insert(indexSet, peakSetAdd);
                else
                    _listPeakSets.Add(peakSetAdd);
                peakSet = peakSetAdd;
            }
            return peakSet;
        }
Beispiel #3
0
 /// <summary>
 /// Returns true if the peak boundaries should be reset to the startIndex and endIndex
 /// values output from this function.
 /// </summary>
 /// <param name="bestPeptidePeak">The best peak for this peptide, which will be in its own scale</param>
 /// <param name="startIndex">The start index this peak should have, if return is true</param>
 /// <param name="endIndex">The end index this peak should have, if return is false</param>
 /// <returns>True if peak bounds should be reset</returns>
 private bool GetLocalPeakBounds(PeptideChromDataPeak bestPeptidePeak, out int startIndex, out int endIndex)
 {
     if (bestPeptidePeak == null)
     {
         startIndex = endIndex = -1;
         return false;
     }
     startIndex = Math.Max(0, GetLocalIndex(bestPeptidePeak.StartIndex));
     endIndex = Math.Min(Times.Length - 1, GetLocalIndex(bestPeptidePeak.EndIndex));
     return IsSameRT(bestPeptidePeak.Data) || IsShiftedRT(bestPeptidePeak.Data);
 }