public override IEnumerable <string> Process(string targetDir) { foreach (var raw in rawFiles) { List <SimplePeakChro> waitingPeaks = new List <SimplePeakChro>(); foreach (var peak in targetPeaks) { string file = GetTargetFile(targetDir, raw, peak); if (force || !File.Exists(file)) { waitingPeaks.Add(peak); } else { var p = new SimplePeakChroXmlFormat().ReadFromFile(file); peak.MaxRetentionTime = p.MaxRetentionTime; peak.Peaks = p.Peaks; } } if (waitingPeaks.Count == 0) { continue; } rawReader.Open(raw); try { int firstScan = rawReader.GetFirstSpectrumNumber(); int lastScan = rawReader.GetLastSpectrumNumber(); var lastRt = rawReader.ScanToRetentionTime(lastScan); waitingPeaks.ForEach(m => { m.Peaks.Clear(); m.MaxRetentionTime = lastRt; }); Progress.SetMessage("Processing chromotograph extracting..."); Progress.SetRange(firstScan, lastScan); for (int scan = firstScan; scan <= lastScan; scan++) { if (rawReader.GetMsLevel(scan) != 1) { continue; } Progress.SetPosition(scan); if (Progress.IsCancellationPending()) { throw new UserTerminatedException(); } PeakList <Peak> pkl = rawReader.GetPeakList(scan); double rt = rawReader.ScanToRetentionTime(scan); foreach (var peak in waitingPeaks) { var env = pkl.FindPeak(peak.Mz, peak.MzTolerance); Peak findPeak = new Peak(peak.Mz, 0.0, 0); if (env.Count > 0) { if (env.Count == 1) { findPeak = env[0]; } else { var charge = env.FindCharge(peak.Charge); if (charge.Count > 0) { if (charge.Count == 1) { findPeak = charge[0]; } else { findPeak = charge.FindMaxIntensityPeak(); } } else { findPeak = env.FindMaxIntensityPeak(); } } } peak.Peaks.Add(new ScanPeak() { Mz = findPeak.Mz, Intensity = findPeak.Intensity, Scan = scan, RetentionTime = rt, Charge = findPeak.Charge, PPMDistance = PrecursorUtils.mz2ppm(peak.Mz, findPeak.Mz - peak.Mz) }); } } waitingPeaks.ForEach(m => m.TrimPeaks(minRetentionTime)); } finally { rawReader.Close(); } Progress.SetMessage("Saving ... "); foreach (var peak in waitingPeaks) { string file = GetTargetFile(targetDir, raw, peak); new SimplePeakChroXmlFormat().WriteToFile(file, peak); } Progress.SetMessage("Finished."); Progress.End(); } return(new string[] { targetDir }); }
private void lvPeptides_SelectedIndexChanged(object sender, EventArgs e) { if (lvPeptides.SelectedItems.Count > 0) { var spectrum = lvPeptides.SelectedItems[0].Tag as IIdentifiedSpectrum; var file = ProteinChromatographProcessor.GetTargetFile(GetOriginFile(), rawFile.FullName, SpectrumToChro(spectrum)); var chro = new SimplePeakChroXmlFormat().ReadFromFile(file); try { zgcScans.ClearData(false); var mainPane = ZedGraphicExtension.InitMasterPanel(zgcScans, CreateGraphics(), 2, "Chromotograph"); if (chro.Peaks.Count > 0) { var pplSample = new PointPairList(); var pplppm = new PointPairList(); var bFirst = true; foreach (ScanPeak p in chro.Peaks) { pplSample.Add(p.RetentionTime, p.Intensity); pplppm.Add(p.RetentionTime, p.PPMDistance); //if (p.Intensity > 0) //{ // pplSample.Add(p.RetentionTime, p.Intensity); // pplppm.Add(p.RetentionTime, p.PPMDistance); //} //else if (pplSample.Count > 0) //{ // if (bFirst) // { // mainPane.PaneList[0].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplSample, Color.Red, SymbolType.None); // mainPane.PaneList[1].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplppm, Color.Red, SymbolType.None); // } // else // { // mainPane.PaneList[0].AddCurve("a", pplSample, Color.Red, SymbolType.None); // mainPane.PaneList[1].AddCurve("a", pplppm, Color.Red, SymbolType.None); // } // pplSample.Clear(); // pplppm.Clear(); // bFirst = false; //} } if (pplSample.Count > 0) { if (bFirst) { mainPane.PaneList[0].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplSample, Color.Red, SymbolType.None); mainPane.PaneList[1].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplppm, Color.Red, SymbolType.None); } else { mainPane.PaneList[0].AddCurve("a", pplSample, Color.Red, SymbolType.None); mainPane.PaneList[1].AddCurve("a", pplppm, Color.Red, SymbolType.None); } } } } finally { ZedGraphicExtension.UpdateGraph(zgcScans); } } }