public override IEnumerable <string> Process(string filename) { string resultFile = filename + ".SILACsummary"; FileInfo resultFI = new FileInfo(resultFile); DirectoryInfo detailDir = new DirectoryInfo(resultFI.DirectoryName + "\\" + resultFI.Name + ".details"); if (!detailDir.Exists) { detailDir.Create(); } builder.Progress = this.Progress; var spectra = resultFormat.ReadFromFile(filename); builder.Quantify(spectra, detailDir.FullName); SilacQuantificationSummaryOption summaryOption = new SilacQuantificationSummaryOption() { MinimumPeptideRSquare = this.MinPeptideRegressionCorrelation }; spectra.ForEach(m => { summaryOption.SetPeptideRatioValid(m, summaryOption.HasPeptideRatio(m) && !summaryOption.IsPeptideOutlier(m)); }); resultFormat.Initialize(spectra); resultFormat.WriteToFile(resultFile, spectra); return(new[] { resultFile }); }
public override IEnumerable <string> Process(string filename) { string resultFile = filename + ".SILACsummary"; FileInfo resultFI = new FileInfo(resultFile); DirectoryInfo detailDir = new DirectoryInfo(resultFI.DirectoryName + "\\" + resultFI.Name + ".details"); if (!detailDir.Exists) { detailDir.Create(); } builder.Progress = this.Progress; IIdentifiedResult sr = resultFormat.ReadFromFile(filename); var spectra = sr.GetSpectra(); builder.Quantify(spectra, detailDir.FullName); SilacQuantificationSummaryOption summaryOption = new SilacQuantificationSummaryOption() { MinimumPeptideRSquare = this.MinPeptideRegressionCorrelation }; spectra.ForEach(m => { summaryOption.SetPeptideRatioValid(m, summaryOption.HasPeptideRatio(m) && !summaryOption.IsPeptideOutlier(m)); }); foreach (IIdentifiedProteinGroup mpg in sr) { calc.Calculate(mpg, m => true); } if (option.KeepPeptideWithMostScan) { foreach (var pgroup in sr) { var gspec = pgroup.GetPeptides().GroupBy(l => l.Query.FileScan.Experimental + "_" + l.Sequence + "_" + l.Query.Charge).ToList(); HashSet <IIdentifiedSpectrum> kept = new HashSet <IIdentifiedSpectrum>(); foreach (var spec in gspec) { if (spec.Count() == 1) { kept.Add(spec.First()); } else { var maxScan = spec.Max(l => (l.Annotations["S_RATIO"] as QuantificationItem).ScanCount); var maxSpecs = spec.Where(l => (l.Annotations["S_RATIO"] as QuantificationItem).ScanCount == maxScan).ToList(); foreach (var maxSpec in maxSpecs) { kept.Add(maxSpec); } } } foreach (var p in pgroup) { p.Peptides.RemoveAll(l => !kept.Contains(l.Spectrum)); } } } resultFormat.InitializeByResult(sr); resultFormat.WriteToFile(resultFile, sr); return(new[] { resultFile }); }
public override IEnumerable <string> Process(string filename) { string resultFile = filename + ".SILACsummary"; FileInfo resultFI = new FileInfo(resultFile); DirectoryInfo detailDir = new DirectoryInfo(resultFI.DirectoryName + "\\" + resultFI.Name + ".details"); if (!detailDir.Exists) { detailDir.Create(); } builder.Progress = this.Progress; IIdentifiedResult sr = resultFormat.ReadFromFile(filename); var spectra = sr.GetSpectra(); builder.Quantify(spectra, detailDir.FullName); SilacQuantificationSummaryOption option = new SilacQuantificationSummaryOption() { MinimumPeptideRSquare = this.MinPeptideRegressionCorrelation }; spectra.ForEach(m => { m.SetEnabled(option.IsPeptideRatioValid(m) && !option.IsPeptideOutlier(m)); var dupSpectra = m.GetDuplicatedSpectra(); dupSpectra.ForEach(n => n.SetEnabled(option.IsPeptideRatioValid(n) && !option.IsPeptideOutlier(n))); }); var calc = new ExtendSilacProteinRatioCalculator(); Dictionary <string, string> datasetMap = new Dictionary <string, string>(); foreach (var ds in datasets) { var lst = ds.Value; lst.ForEach(m => datasetMap[m] = ds.Key); } foreach (IIdentifiedProteinGroup mpg in sr) { var realSpectra = new List <IIdentifiedSpectrum>(mpg.GetPeptides()); foreach (var spectrum in realSpectra) { var dupSpectra = spectrum.GetDuplicatedSpectra(); mpg.AddIdentifiedSpectra(dupSpectra); } ProteinQuantificationResult pr = new ProteinQuantificationResult(); foreach (var ds in datasets) { var lst = ds.Value; pr.Items[ds.Key] = calc.Calculate(mpg, m => lst.Contains(m.Query.FileScan.Experimental)); } bool valid = pr.Items.Values.FirstOrDefault(m => m.Enabled) != null; foreach (IIdentifiedProtein protein in mpg) { protein.SetEnabled(valid); protein.Annotations[SilacQuantificationConstants.SILAC_KEY] = pr; } } var finalSpectra = sr.GetSpectra(); finalSpectra.ForEach(m => m.SetDataset(datasetMap[m.Query.FileScan.Experimental])); resultFormat.InitializeByResult(sr); resultFormat.WriteToFile(resultFile, sr); return(new[] { resultFile }); }