private void AddDoubleISOFileForListView(RawFileInfo fileInfo) { if (fileInfo == null) { return; } if (dISOFileInfos.FirstOrDefault(f => f.ToString() == fileInfo.ToString()) == null) { dISOFileInfos.Add(fileInfo); } }
public static void TestFlashLFQ() { // get the raw file paths RawFileInfo raw = new RawFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw")); RawFileInfo mzml = new RawFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml")); // create some PSMs Identification id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> { "MyProtein" }); Identification id2 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> { "MyProtein" }); Identification id3 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> { "MyProtein" }); Identification id4 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> { "MyProtein" }); // create the FlashLFQ engine FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> { id1, id2, id3, id4 }); // run the engine var results = engine.Run(); // check raw results Assert.That(results.peaks[raw].Count == 1); Assert.That(results.peaks[raw].First().intensity > 0); Assert.That(!results.peaks[raw].First().isMbrFeature); Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[raw] > 0); Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[raw] > 0); Assert.That(results.proteinGroups["MyProtein"].intensities[raw] > 0); // check mzml results Assert.That(results.peaks[mzml].Count == 1); Assert.That(results.peaks[mzml].First().intensity > 0); Assert.That(!results.peaks[mzml].First().isMbrFeature); Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[mzml] > 0); Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[mzml] > 0); Assert.That(results.proteinGroups["MyProtein"].intensities[mzml] > 0); // test peak output List <string> output = new List <string>() { FlashLFQ.ChromatographicPeak.TabSeparatedHeader }; foreach (var peak in results.peaks.SelectMany(p => p.Value)) { output.Add(peak.ToString()); } Assert.That(output.Count == 3); // test peptide base sequence output output = new List <string>() { Peptide.TabSeparatedHeader }; foreach (var pep in results.peptideBaseSequences) { output.Add(pep.Value.ToString()); } Assert.That(output.Count == 2); // test peptide mod sequence output output = new List <string>() { Peptide.TabSeparatedHeader }; foreach (var pep in results.peptideModifiedSequences) { output.Add(pep.Value.ToString()); } Assert.That(output.Count == 2); // test protein output output = new List <string>() { ProteinGroup.TabSeparatedHeader }; foreach (var protein in results.proteinGroups) { output.Add(protein.Value.ToString()); } Assert.That(output.Count == 2); }
static int Run(Dictionary <string, object> opts) { if ((bool)opts["ExampleCommands"] == true) { Examples.CommandLineUsage(); Environment.Exit(0); } if ((bool)opts["ExampleModifications"] == true) { Examples.ExampleMods(); Environment.Exit(0); } List <string> files = new List <string>(); QcDataCollection qcDataCollection = new QcDataCollection(); WorkflowParameters parameters = new WorkflowParameters(opts); if (parameters.InputFiles != null) // did the user give us a list of files? { List <string> problems = new List <string>(); files = parameters.InputFiles.ToList(); // check if the list provided contains only .raw files foreach (string file in files) { if (!file.EndsWith(".raw", StringComparison.OrdinalIgnoreCase)) { problems.Add(file); } } if (problems.Count() == 1) { Console.WriteLine("\nERROR: {0} does not appear to be a .raw file. Invoke '>RawTools --help' if you need help.", problems.ElementAt(0)); Log.Error("Invalid file provided: {0}", problems.ElementAt(0)); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(1); } if (problems.Count() > 1) { Console.WriteLine("\nERROR: The following {0} files do not appear to be .raw files. Invoke '>RawTools --help' if you need help." + "\n\n{1}", problems.Count(), String.Join("\n", problems)); Log.Error("Invalid files provided: {0}", String.Join(" ", problems)); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(1); } files = RawFileInfo.RemoveInAcquistionFiles(files); // if the file location(s) are relative, we need to get the absolute path to them files.EnsureAbsolutePaths(); Log.Information("Files to be processed, provided as list: {0}", String.Join(" ", files)); } else if (!String.IsNullOrEmpty(parameters.RawFileDirectory)) // did the user give us a directory? { // if QC is being done, use the QC method snf get the qc data collection at the same time if (parameters.QcParams.QcDirectory != null) { (files, qcDataCollection) = QcWorkflow.GetFileListAndQcFile(parameters, parameters.IncludeSubdirectories); } // if not, the parse method else if (Directory.Exists(parameters.RawFileDirectory)) { files = Directory.GetFiles(parameters.RawFileDirectory, "*.*", SearchOption.TopDirectoryOnly) .Where(s => s.EndsWith(".raw", StringComparison.OrdinalIgnoreCase)).ToList(); } else { Console.WriteLine("ERROR: The provided directory does not appear to be valid."); Log.Error("Invalid directory provided: {0}", parameters.RawFileDirectory); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(1); } files = RawFileInfo.RemoveInAcquistionFiles(files); // if the file location(s) are relative, we need to get the absolute path to them files.EnsureAbsolutePaths(); Log.Information("Files to be processed, provided as directory: {0}", String.Join(" ", files)); } else { Console.WriteLine("ERROR: At least one of the following arguments is required: -f, -d"); Log.Error("No raw files or directory specified."); return(1); } if (parameters.ParseParams.Quant) { List <string> possible = new List <string>() { "TMT0", "TMT2", "TMT6", "TMT10", "TMT11", "iTRAQ4", "iTRAQ8" }; if (!possible.Contains(parameters.ParseParams.LabelingReagents)) { Console.WriteLine("ERROR: For quantification, the labeling reagent must be one of {TMT0, TMT2, TMT6, TMT10, TMT11, iTRAQ4, iTRAQ8}"); Log.Error("Invalid labeling reagent provided: {0}", parameters.ParseParams.LabelingReagents); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(1); } } if (parameters.ParseParams.Chromatogram != null) { List <string> possible = new List <string>() { "1", "2", "3", "T", "B" }; foreach (var x in parameters.ParseParams.Chromatogram) { if (!possible.Contains(x.ToString())) { Console.WriteLine("ERROR: Incorrect format for -chro. See help."); Log.Error("Invalid chromatogram argument provided: {Chro}", parameters.ParseParams.Chromatogram); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(1); } } } System.Diagnostics.Stopwatch singleFileTime = new System.Diagnostics.Stopwatch(); System.Diagnostics.Stopwatch totalTime = new System.Diagnostics.Stopwatch(); totalTime.Start(); foreach (string file in files) { singleFileTime.Start(); Console.WriteLine("\nProcessing: {0}\n", file); //using (IRawDataPlus rawFile = RawFileReaderFactory.ReadFile(fileName:file)) using (IRawFileThreadManager rawFile = RawFileReaderFactory.CreateThreadManager(file)) { if (parameters.ParseParams.OutputDirectory == null) { parameters.ParseParams.OutputDirectory = Path.GetDirectoryName(file); } WorkFlowsDDA.UniversalDDA(rawFile, parameters, qcDataCollection); } singleFileTime.Stop(); Console.WriteLine("\nElapsed time: {0} s", Math.Round(Convert.ToDouble(singleFileTime.ElapsedMilliseconds) / 1000.0, 2)); singleFileTime.Reset(); } if (parameters.LogDump) { Write.LogDump.WriteToDisk(parameters); } totalTime.Stop(); Console.WriteLine("\nTime to process all {0} files: {1}", files.Count(), totalTime.Elapsed); //Console.Write("Press any key to exit..."); //Console.ReadKey(); return(0); }
public RawFileInfoViewModel(RawFileInfo rawFileInfo) { _rawFileInfo = rawFileInfo; }
public static void CalcRatioSignificanceProteinGroups(SilacType type, ICombinedData combinedData, RawFileInfo fileInfo) { if (type == SilacType.Doublets) { { List <double> lNormRatio = new List <double>(); List <double> lRatio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio10(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lNormRatio.Add(Math.Log(normalizedRatio)); lRatio.Add(Math.Log(ratio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lNormRatio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lNormRatio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.RatioSignificanceA10 = ratioSignificanceA[i]; group.RatioSignificanceB10 = ratioSignificanceB[i]; } } if (fileInfo.HasExperiment) { string[] exps = fileInfo.GetAllExperimentValues(); foreach (string exp in exps) { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio10(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, fileInfo.GetRawFileIndicesFromExperiment(exp), out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.AddRatioSignificanceA10(exp, ratioSignificanceA[i]); group.AddRatioSignificanceB10(exp, ratioSignificanceB[i]); } } } } if (type == SilacType.Triplets) { { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio10(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.RatioSignificanceA10 = ratioSignificanceA[i]; group.RatioSignificanceB10 = ratioSignificanceB[i]; } } if (fileInfo.HasExperiment) { string[] exps = fileInfo.GetAllExperimentValues(); foreach (string exp in exps) { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio10(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, fileInfo.GetRawFileIndicesFromExperiment(exp), out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.AddRatioSignificanceA10(exp, ratioSignificanceA[i]); group.AddRatioSignificanceB10(exp, ratioSignificanceB[i]); } } } { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio20(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.RatioSignificanceA20 = ratioSignificanceA[i]; group.RatioSignificanceB20 = ratioSignificanceB[i]; } } if (fileInfo.HasExperiment) { string[] exps = fileInfo.GetAllExperimentValues(); foreach (string exp in exps) { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio20(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, fileInfo.GetRawFileIndicesFromExperiment(exp), out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.AddRatioSignificanceA20(exp, ratioSignificanceA[i]); group.AddRatioSignificanceB20(exp, ratioSignificanceB[i]); } } } { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio21(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.RatioSignificanceA21 = ratioSignificanceA[i]; group.RatioSignificanceB21 = ratioSignificanceB[i]; } } if (fileInfo.HasExperiment) { string[] exps = fileInfo.GetAllExperimentValues(); foreach (string exp in exps) { List <double> lratio = new List <double>(); List <double> lIntensity = new List <double>(); List <int> indices = new List <int>(); for (int i = 0; i < combinedData.GetProteinGroupCount(); i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(i); double ratio; double normalizedRatio; int count; double dev; int nOutliers; double pval; group.GetRatio21(combinedData, out ratio, out normalizedRatio, out count, out dev, out nOutliers, fileInfo.GetRawFileIndicesFromExperiment(exp), out pval); double intensity = group.GetIntensity0(combinedData) + group.GetIntensity1(combinedData) + group.GetIntensity2(combinedData); if (normalizedRatio > 0 && !double.IsInfinity(normalizedRatio) && !double.IsNaN(normalizedRatio) && intensity > 0) { lratio.Add(Math.Log(normalizedRatio)); lIntensity.Add(Math.Log(intensity)); indices.Add(i); } } double[] ratioSignificanceA = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), 1); double[] ratioSignificanceB = NumUtil.MovingBoxPlot(lratio.ToArray(), lIntensity.ToArray(), -1); for (int i = 0; i < indices.Count; i++) { IIdentifiedProteinGroup group = combinedData.GetIProteinGroupAt(indices[i]); group.AddRatioSignificanceA21(exp, ratioSignificanceA[i]); group.AddRatioSignificanceB21(exp, ratioSignificanceB[i]); } } } } }
public static void DoQc(WorkflowParameters parameters) { //QcDataCollectionDDA qcDataCollection; dynamic qcDataCollection; string dataDirectory = parameters.RawFileDirectory; string qcDirectory = parameters.QcParams.QcDirectory; string qcSearchDataDirecotry = parameters.QcParams.QcSearchDataDirectory; List <string> fileList = new List <string>(); string qcFile = Path.Combine(qcDirectory, "QC.xml"); (fileList, qcDataCollection) = GetFileListAndQcFile(parameters); foreach (string fileName in fileList) { Console.WriteLine("\nProcessing {0}", fileName); if (!RawFileInfo.CheckIfValid(fileName)) { continue; } // okay, it is probably a real raw file, let's do the QC // check if the raw file already exists in the QC data with a different name if (CheckIfFilePresentInQcCollection(fileName, qcDataCollection)) { Log.Information("A file with the same creation date and time as {File} already exists in the QC data", fileName); Console.WriteLine("A file with the same creation date and time as {File} already exists in the QC data. Skipping to next file.", fileName); continue; } IRawFileThreadManager rawFileThreadManager = RawFileReaderFactory.CreateThreadManager(fileName); if (parameters.ExpType == ExperimentType.DDA) { WorkFlowsDDA.QcDDA(rawFileThreadManager, parameters); } //else if (parameters.ExpType == ExperimentType.DIA) //{ // WorkFlowsDIA.QcDIA(rawFileThreadManager, parameters); //} /* * using (IRawDataPlus rawFile = RawFileReaderFactory.ReadFile(fileName)) * { * rawFile.SelectInstrument(Device.MS, 1); * * if (parameters.ExpType == ExperimentType.DDA) * { * WorkFlowsDDA.QcDDA(rawFile, parameters); * } * else if (parameters.ExpType == ExperimentType.DIA) * { * WorkFlowsDIA.QcDIA(rawFile, parameters); * } * }*/ Log.Information("QC finished: {File}", fileName); } Log.Information("QC of all files completed"); Console.WriteLine("QC of all files completed!"); }