public static CalculatedPeaks Calculate(PeptideFileAnalysis peptideFileAnalysis, IEnumerable <CalculatedPeaks> otherPeaks) { var tracerFormulae = peptideFileAnalysis.TurnoverCalculator.ListTracerFormulas(); var result = new CalculatedPeaks(peptideFileAnalysis); if (!peptideFileAnalysis.AutoFindPeak) { var previous = peptideFileAnalysis.PeakData; if (previous.Peaks.Count == tracerFormulae.Count) { for (int i = 0; i < previous.Peaks.Count; i++) { var peak = previous.Peaks[i]; if (result._peaks.Count == 0) { result.MakeBasePeak(tracerFormulae[i], peak.StartTime, peak.EndTime); } else { result.MakeSecondaryPeak(tracerFormulae[i], peak.StartTime, peak.EndTime); } } var maxArea = result._peaks.Values.Max(peak => peak.Area); result = result.ChangeBasePeak(result._peaks.First(kvp => kvp.Value.Area.Equals(maxArea)).Key); result.IntegrationNote = IntegrationNote.Manual; } } if (result._peaks.Count == 0) { result.LookForBestPeak(otherPeaks); } result.FinishCalculation(); return(result); }
public void SetCalculatedPeaks(CalculatedPeaks calculatedPeaks) { if (calculatedPeaks.AutoFindPeak) { throw new InvalidOperationException(); } Data = Data.SetPeaks(false, calculatedPeaks.ToPeakSetData()); PeptideAnalysis.InvalidatePeaks(); }
public void Save(ISession session) { var dbPeptideFileAnalysis = session.Get <DbPeptideFileAnalysis>(Id); dbPeptideFileAnalysis.AutoFindPeak = AutoFindPeak; dbPeptideFileAnalysis.Note = Data.Note; dbPeptideFileAnalysis.ValidationStatus = Data.ValidationStatus; session.Update(dbPeptideFileAnalysis); if (null != CalculatedPeaks) { CalculatedPeaks.Save(session); } }
public CalculatedPeaks AutoSizePeak(TracerFormula tracerFormula, AdjustPeaksMode adjustPeaksMode) { if (tracerFormula.Equals(BasePeakKey)) { return(this); } var result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; var oldBasePeak = _peaks[BasePeakKey]; result.MakeBasePeak(BasePeakKey, oldBasePeak.StartTime, oldBasePeak.EndTime); foreach (var entry in _peaks) { if (entry.Key.Equals(BasePeakKey)) { continue; } Peak?newPeak = null; if (entry.Key.Equals(tracerFormula)) { double width = oldBasePeak.EndTime - oldBasePeak.StartTime; if (adjustPeaksMode == AdjustPeaksMode.Full) { newPeak = result.FindMatchingPeak(tracerFormula); } else if (adjustPeaksMode == AdjustPeaksMode.Overlapping) { newPeak = result.FindMatchingPeak(tracerFormula, entry.Value.StartTime - width, entry.Value.EndTime + width); } else if (adjustPeaksMode == AdjustPeaksMode.Narrow) { newPeak = result.FindMatchingPeak(tracerFormula, Math.Min(entry.Value.StartTime, entry.Value.EndTime - width), Math.Max(entry.Value.EndTime, entry.Value.StartTime + width)); } } if (newPeak == null) { result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } } result.FinishCalculation(); return(result); }
public CalculatedPeaks ChangeBasePeak(TracerFormula baseTracerFormula) { CalculatedPeaks result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; var basePeak = _peaks[baseTracerFormula]; result.MakeBasePeak(baseTracerFormula, basePeak.StartTime, basePeak.EndTime); foreach (var entry in _peaks) { if (entry.Key.Equals(baseTracerFormula)) { continue; } result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } result.FinishCalculation(); return(result); }
public CalculatedPeaks ChangeTime(TracerFormula tracerFormula, double newStartTime, double newEndTime) { CalculatedPeaks result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; Peak oldBasePeak = _peaks[BasePeakKey]; bool isBasePeak; if (tracerFormula.Equals(BasePeakKey)) { result.MakeBasePeak(BasePeakKey, newStartTime, newEndTime); isBasePeak = true; } else { result.MakeBasePeak(BasePeakKey, oldBasePeak.StartTime, oldBasePeak.EndTime); isBasePeak = false; } foreach (var entry in _peaks) { if (entry.Key.Equals(tracerFormula)) { if (isBasePeak) { continue; } result.MakeSecondaryPeak(tracerFormula, newStartTime, newEndTime); } else { result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } } result.FinishCalculation(); return(result); }
public void EnsurePeaksCalculated() { if (0 == GetChromatogramRefCount()) { throw new InvalidOperationException("No chromatograms"); } if (null != _calculatedPeaks) { return; } var peaksList = new List <CalculatedPeaks>(); var peptideFileAnalyses = FileAnalyses.ToArray(); Array.Sort(peptideFileAnalyses, (f1, f2) => (null == f1.PsmTimes).CompareTo(null == f2.PsmTimes) ); bool changed = false; foreach (var peptideFileAnalysis in peptideFileAnalyses) { if (peptideFileAnalysis.ChromatogramSet == null || !peptideFileAnalysis.IsMzKeySetComplete(peptideFileAnalysis.ChromatogramSet.Chromatograms.Keys)) { continue; } var peaks = peptideFileAnalysis.CalculatedPeaks; if (peaks == null || changed) { peaks = CalculatedPeaks.Calculate(peptideFileAnalysis, peaksList); changed = changed || peaks != null; } peaksList.Add(peaks); } SetCalculatedPeaks(peaksList); }
public CalculatedPeaks ChangeTime(TracerFormula tracerFormula, double newStartTime, double newEndTime) { CalculatedPeaks result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; Peak oldBasePeak = _peaks[BasePeakKey]; bool isBasePeak; if (tracerFormula.Equals(BasePeakKey)) { result.MakeBasePeak(BasePeakKey, newStartTime, newEndTime); isBasePeak = true; } else { result.MakeBasePeak(BasePeakKey, oldBasePeak.StartTime, oldBasePeak.EndTime); isBasePeak = false; } foreach (var entry in _peaks) { if (entry.Key.Equals(tracerFormula)) { if (isBasePeak) { continue; } result.MakeSecondaryPeak(tracerFormula, newStartTime, newEndTime); } else { result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } } result.FinishCalculation(); return result; }
public CalculatedPeaks ChangeBasePeak(TracerFormula baseTracerFormula) { CalculatedPeaks result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; var basePeak = _peaks[baseTracerFormula]; result.MakeBasePeak(baseTracerFormula, basePeak.StartTime, basePeak.EndTime); foreach (var entry in _peaks) { if (entry.Key.Equals(baseTracerFormula)) { continue; } result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } result.FinishCalculation(); return result; }
public CalculatedPeaks AutoSizePeak(TracerFormula tracerFormula, AdjustPeaksMode adjustPeaksMode) { if (tracerFormula.Equals(BasePeakKey)) { return this; } var result = new CalculatedPeaks(PeptideFileAnalysis) { AutoFindPeak = false, }; var oldBasePeak = _peaks[BasePeakKey]; result.MakeBasePeak(BasePeakKey, oldBasePeak.StartTime, oldBasePeak.EndTime); foreach (var entry in _peaks) { if (entry.Key.Equals(BasePeakKey)) { continue; } Peak? newPeak = null; if (entry.Key.Equals(tracerFormula)) { double width = oldBasePeak.EndTime - oldBasePeak.StartTime; if (adjustPeaksMode == AdjustPeaksMode.Full) { newPeak = result.FindMatchingPeak(tracerFormula); } else if (adjustPeaksMode == AdjustPeaksMode.Overlapping) { newPeak = result.FindMatchingPeak(tracerFormula, entry.Value.StartTime - width, entry.Value.EndTime + width); } else if (adjustPeaksMode == AdjustPeaksMode.Narrow) { newPeak = result.FindMatchingPeak(tracerFormula, Math.Min(entry.Value.StartTime, entry.Value.EndTime - width), Math.Max(entry.Value.EndTime, entry.Value.StartTime + width)); } } if (newPeak == null) { result.MakeSecondaryPeak(entry.Key, entry.Value.StartTime, entry.Value.EndTime); } } result.FinishCalculation(); return result; }
public static CalculatedPeaks Calculate(PeptideFileAnalysis peptideFileAnalysis, IEnumerable<CalculatedPeaks> otherPeaks) { var tracerFormulae = peptideFileAnalysis.TurnoverCalculator.ListTracerFormulas(); var result = new CalculatedPeaks(peptideFileAnalysis); if (!peptideFileAnalysis.AutoFindPeak) { var previous = peptideFileAnalysis.PeakData; if (previous.Peaks.Count == tracerFormulae.Count) { for (int i = 0; i < previous.Peaks.Count; i++) { var peak = previous.Peaks[i]; if (result._peaks.Count == 0) { result.MakeBasePeak(tracerFormulae[i], peak.StartTime, peak.EndTime); } else { result.MakeSecondaryPeak(tracerFormulae[i], peak.StartTime, peak.EndTime); } } var maxArea = result._peaks.Values.Max(peak => peak.Area); result = result.ChangeBasePeak(result._peaks.First(kvp => kvp.Value.Area.Equals(maxArea)).Key); result.IntegrationNote = IntegrationNote.Manual; } } if (result._peaks.Count == 0 ) { result.LookForBestPeak(otherPeaks); } result.FinishCalculation(); return result; }