private void MGFRead(string FileName) { MGFInFileName.Text = FileName; MGFin = new MGFParser.MGFFile(); MGFin.MGFRead(FileName); MGFoutFileName.Text = Path.GetDirectoryName(FileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(FileName) + "-filtered.mgf"; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { //BackgroundWorker worker = sender as BackgroundWorker; int PercentCompleted = 0; if (mp == null) { if (File.Exists(DatFileName.Text)) { mp = new Mascot.MascotParser(); mp.ParseFile(DatFileName.Text); } else { throw new ArgumentException( "Mascot .DAT file must be specified", "n"); } } if (MGFin == null) { if (File.Exists(DatFileName.Text)) { MGFRead(MGFInFileName.Text); } else { throw new ArgumentException( "MGF file must be specified", "n"); } } if (!Settings.Default.MScore) { //сортируем по score MascotSpectrabyScore mss = new MascotSpectrabyScore(); mp.Spectra.Sort(mss); int DirectCount = 0, ReversedCount = 0, i; for (i = 0; i < mp.Spectra.Count; i++) { if (mp.Spectra[i].Peptides.Count == 0) { break; } bool Reversed = true; for (int j = 0; j < mp.Spectra[i].Peptides[0].ProteinNames.Length; j++) { Reversed &= mp.Spectra[i].Peptides[0].ProteinNames[j].ToUpper().Contains("REVERSED"); } if (Reversed) { ReversedCount++; } else { DirectCount++; } double FDRRatio = ((double)ReversedCount / (double)DirectCount) * 100.0; if (FDRRatio > Convert.ToDouble(Settings.Default.FDRThreshold)) { break; } } Settings.Default.Mascot_Threshold = Convert.ToString(mp.Spectra[i].Peptides[0].Score); } Mascot.MascotSpectra ms; MGFParser.MGFSpectrum mgfs; MGFout = new MGFParser.MGFFile(); MGFout.MGFComments.AddRange(MGFin.MGFComments); MGFout.MGFComments.Add(String.Format("Filtered by {0};", Text)); MGFout.MGFComments.Add(String.Format("Mascot Threshold - {0}", Settings.Default.Mascot_Threshold)); if (!Settings.Default.MScore) { MGFout.MGFComments.Add(String.Format("Based on FDR Threshold - {0}%", Settings.Default.FDRThreshold)); } MGFout.MGFComments.Add(String.Format("Mascot Result File - {0}", DatFileName.Text)); for (int i = 0; i < MGFin.Spectra.Count; i++) { mgfs = MGFin.Spectra[i]; //Link to Mascot search results - не работает - мы только что пересортировалми спектры //ms = mp.AccessByFSN(mgfs.ScanNumber); ms = null; for (int j = 0; j < mp.Spectra.Count; j++) { if (mp.Spectra[j].ScanNumber == mgfs.ScanNumber) { ms = mp.Spectra[j]; break; } } if (ms == null) { throw new ArgumentException( "Probably .dat file does not correspond to .mgf file", "n"); } if (ms.Peptides.Count == 0 || ms.Peptides[0].Score < Convert.ToDouble(Settings.Default.Mascot_Threshold)) { continue; } bool Reversed = true; for (int j = 0; j < ms.Peptides[0].ProteinNames.Length; j++) { Reversed &= ms.Peptides[0].ProteinNames[j].ToUpper().Contains("REVERSED"); } if (Reversed) { continue; } if (mgfs.Data.Count == 0) { continue; } MGFout.Spectra.Add(mgfs); if (Convert.ToInt32(((i * 100) / MGFin.Spectra.Count)) > PercentCompleted) { PercentCompleted = Convert.ToInt32(((i * 100) / MGFin.Spectra.Count)); backgroundWorker1.ReportProgress(PercentCompleted); } } backgroundWorker1.ReportProgress(100); MGFout.MGFWrite(Settings.Default.MGF_Out); backgroundWorker1.ReportProgress(0); }