public Peak(LCTrace Trace, int ApexIndex, int LeftIndex, int RightIndex) { this.Trace = Trace; this.Apex = ApexIndex; this.LeftIndex = Math.Min(LeftIndex, RightIndex); this.RightIndex = Math.Max(LeftIndex, RightIndex); Left = Trace.Group.Points[LeftIndex].RT; Right = Trace.Group.Points[RightIndex].RT; Apex = Trace.Group.Points[ApexIndex].RT; ApexMass = Trace.Group.Points[ApexIndex].Mass; ApexIntensity = Trace.Group.Points[ApexIndex].Intensity; }
public void ApplyPeak(Peak P, LCTrace Trace) { MZData thisPoint = null; MZData TracePoint = null; double MSum = 0.0; double ISum = 0.0; double aSum = 0.0; double bSum = 0.0; for (int i = Trace.Group.Points[P.LeftIndex].Scan; i <= Trace.Group.Points[P.RightIndex].Scan; i++) { thisPoint = PointForScan(i); TracePoint = Trace.PointForScan(i); MSum += thisPoint == null ? 0.0 : thisPoint.Mass * thisPoint.Intensity * thisPoint.TimeCoeff; ISum += thisPoint == null ? 0.0 : thisPoint.Intensity; aSum += (thisPoint != null && TracePoint != null)?thisPoint.Intensity:0.0; bSum += (thisPoint != null && TracePoint != null)?TracePoint.Intensity:0.0; } PeakTotal = ISum; PeakMeanMass = ISum != 0.0 ? MSum / ISum : 0.0; PeakRatio = bSum != 0.0 ? aSum / bSum : 0.0; }
/** * Wavelet-based peak detection. * Returns a list of peaks in this chromatogram satisfying the given criteria * Here min and max peak width are given in the units of scan time. * (Note that this assumes scans are even in time.) */ public TracePeaks(LCTrace Trace) { this.Trace = Trace; }
static Feature FeatureForTarget(Target T, MZData P) { Feature F = new Feature(); T.Feature = F; F.Target = T; //Monoisotopic trace MZData Apex = null; Apex = P; if (Apex == null) { return(null); } F.MainTrace = LCTrace.CreateTrace(RawFileService.GroupFromPoint(Apex), Apex);//main for untargeted analysis //? gapped for main trace if (F.MainTrace == null) { return(null); } F.MainTrace.Attribution = "C0N0"; double RTStart = F.MainTrace.Group.Points[0].RT; double RTEnd = F.MainTrace.Group.Points[F.MainTrace.Group.Points.Count - 1].RT; //Check if Apex outside of RT Window if (F.MainTrace.Apex.RT < T.RTMin || F.MainTrace.Apex.RT > T.RTMax) { F.MainApexOutsideRtWindow = true; } F.TPeaks = new TracePeaks(F.MainTrace); F.TPeaks.waveletPeakDetection(PeakMinWidth, PeakMaxWidth, PeakMinIntensity, PeakbaselineRatio); F.TPeaks.SelectClosestAsTarget(F.Target); //End of monotrace F.HasPrevIsotope = false; //End of preisotopes //Checks for isotopic peaks F.Isotopes = new LCTrace[T.C13toCheck + 1]; F.Isotopes[0] = F.MainTrace; //Pure isotopes for (int C13 = 1; C13 <= T.C13toCheck; C13++) { double TargetMass = Apex.Mass + (C13Shift * (double)(C13)) / T.Charge; MZData D = RawFileService.RawFile.RawSpectra[Apex.Scan].FindNearestPeak(TargetMass, MassError); if (D.Mass > 0.0) { F.Isotopes[C13] = LCTrace.CreateTrace(RawFileService.GroupFromPoint(D), D); } else { F.Isotopes[C13] = null; } //Gapped trace (it was only actual if low signals is turned on - may provide some non-obvious errors) if (F.Isotopes[C13] == null || (F.Isotopes[C13].Group.Points[0].RT > T.RTMin && F.Isotopes[C13].Group.Points[F.Isotopes[C13].Group.Points.Count - 1].RT < T.RTMax)) { F.Isotopes[C13] = LCTrace.CreateTrace(RawFileService.GroupFromArea(T.RTMin, T.RTMax, TargetMass), D.Mass == 0.0?null:D); } if (F.Isotopes[C13] != null) { F.Isotopes[C13].Attribution = String.Format("C{0}N{1}", C13, 0); } } //Apply peaks if (F.TPeaks.TargetPeak != null) { F.ApplyPeak(F.TPeaks.TargetPeak); } return(F); }