Exemplo n.º 1
0
        private void RunFlashLfq()
        {
            // read IDs
            var ids = new List <Identification>();

            foreach (var identFile in identFilesForDataGrid)
            {
                ids = ids.Concat(PsmReader.ReadPsms(identFile.FilePath, false, spectraFileInfo)).ToList();
            }

            // run FlashLFQ engine
            try
            {
                flashLfqEngine = new FlashLFQEngine(
                    allIdentifications: ids,
                    normalize: flashLfqEngine.Normalize,
                    ppmTolerance: flashLfqEngine.PpmTolerance,
                    isotopeTolerancePpm: flashLfqEngine.IsotopePpmTolerance,
                    matchBetweenRuns: flashLfqEngine.MatchBetweenRuns,
                    matchBetweenRunsPpmTolerance: flashLfqEngine.MbrPpmTolerance,
                    integrate: flashLfqEngine.Integrate,
                    numIsotopesRequired: flashLfqEngine.NumIsotopesRequired,
                    idSpecificChargeState: flashLfqEngine.IdSpecificChargeState,
                    requireMonoisotopicMass: flashLfqEngine.RequireMonoisotopicMass,
                    silent: false,
                    optionalPeriodicTablePath: null,
                    maxMbrWindow: flashLfqEngine.MbrRtWindow,
                    advancedProteinQuant: flashLfqEngine.AdvancedProteinQuant);

                results = flashLfqEngine.Run();
            }
            catch (Exception ex)
            {
                MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
            }

            // write output
            try
            {
                OutputWriter.WriteOutput(Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName, results, outputFolderPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not write FlashLFQ output: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
            }
        }
Exemplo n.º 2
0
        public static void TestPercolatorErrorHandling()
        {
            string search      = "Percolator";
            string psmFilename = "BadPercolatorSmallCalibratableYeast.txt";

            string          myDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "SampleFiles");
            string          pathOfIdentificationFile = Path.Combine(myDirectory, search, psmFilename);
            string          pathOfMzml = Path.Combine(myDirectory, "SmallCalibratible_Yeast.mzML");
            SpectraFileInfo sfi        = new SpectraFileInfo(pathOfMzml, "A", 1, 1, 1);

            List <Identification> ids = PsmReader.ReadPsms(pathOfIdentificationFile, false, new List <SpectraFileInfo> {
                sfi
            });

            //would like better assertion with message but can't get it to return exception message...
            Assert.IsEmpty(ids);
        }
Exemplo n.º 3
0
        public void TestPercolatorReadPsmsGetsRTsFromFileHeader()
        {
            string search      = "Percolator";
            string psmFilename = "percolatorTestData.txt";

            var myDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "SampleFiles", search);
            var pathOfIdentificationFile = Path.Combine(myDirectory, psmFilename);
            var pathOfMzml = Path.Combine(myDirectory, "percolatorMzml.mzML");

            Assert.That(File.Exists(pathOfIdentificationFile));
            Assert.That(File.Exists(pathOfMzml));



            SpectraFileInfo sfi = new SpectraFileInfo(pathOfMzml, "A", 1, 1, 1);

            List <double> expectedRetentionTimes = new List <double> {
                7.54, 7.54, 7.56, 7.58, 7.61, 7.63
            };

            List <Identification> ids = PsmReader.ReadPsms(pathOfIdentificationFile, true, new List <SpectraFileInfo> {
                sfi
            });

            Assert.AreEqual(6, ids.Count);
            List <double> actualRetentionTimes = ids.Select(t => Math.Round(t.Ms2RetentionTimeInMinutes, 2)).ToList();

            foreach (double rt in actualRetentionTimes)
            {
                Assert.IsTrue(Double.IsFinite(rt));
            }
            CollectionAssert.AreEquivalent(expectedRetentionTimes, actualRetentionTimes);

            List <int> proteinGroupCounts = new List <int> {
                11, 6, 3, 2, 15, 3
            };

            CollectionAssert.AreEquivalent(proteinGroupCounts, ids.Select(i => i.ProteinGroups.Count).ToList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Runs the FlashLFQ engine with the user's defined spectra files, ID files, and FlashLFQ
        /// settings.
        /// </summary>
        private void RunFlashLfq()
        {
            // read IDs
            var ids = new List <Identification>();

            try
            {
                foreach (var identFile in idFiles)
                {
                    ids = ids.Concat(PsmReader.ReadPsms(identFile.FilePath, false, spectraFiles.Select(p => p.SpectraFileInfo).ToList())).ToList();
                }
            }
            catch (Exception e)
            {
                string errorReportPath = Directory.GetParent(spectraFiles.First().FilePath).FullName;
                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(e, Directory.GetParent(spectraFiles.First().FilePath).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + e.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ could not read the PSM file: " + e.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            if (!ids.Any())
            {
                MessageBox.Show("No peptide IDs for the specified spectra files were found! " +
                                "Check to make sure the spectra file names match between the ID file and the spectra files",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            // run FlashLFQ engine
            try
            {
                flashLfqEngine = FlashLfqSettings.CreateEngineWithSettings(settings, ids);

                results = flashLfqEngine.Run();
            }
            catch (Exception ex)
            {
                string errorReportPath = Directory.GetParent(spectraFiles.First().FilePath).FullName;

                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(ex, Directory.GetParent(spectraFiles.First().FilePath).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            // write output
            if (results != null)
            {
                try
                {
                    OutputWriter.WriteOutput(Directory.GetParent(spectraFiles.First().FilePath).FullName, results, flashLfqEngine.Silent,
                                             outputFolderPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not write FlashLFQ output: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }
            }
        }
Exemplo n.º 5
0
        private void RunFlashLfq()
        {
            // read IDs
            var ids = new List <Identification>();

            try
            {
                foreach (var identFile in identFilesForDataGrid)
                {
                    ids = ids.Concat(PsmReader.ReadPsms(identFile.FilePath, false, spectraFileInfo)).ToList();
                }
            }
            catch (Exception e)
            {
                string errorReportPath = Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName;
                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(e, Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + e.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ could not read the PSM file: " + e.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            if (!ids.Any())
            {
                MessageBox.Show("No peptide IDs for the specified spectra files were found! " +
                                "Check to make sure the spectra file names match between the ID file and the spectra files",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            // run FlashLFQ engine
            try
            {
                flashLfqEngine = new FlashLfqEngine(
                    allIdentifications: ids,
                    normalize: flashLfqEngine.Normalize,
                    ppmTolerance: flashLfqEngine.PpmTolerance,
                    isotopeTolerancePpm: flashLfqEngine.IsotopePpmTolerance,
                    matchBetweenRuns: flashLfqEngine.MatchBetweenRuns,
                    matchBetweenRunsPpmTolerance: flashLfqEngine.MbrPpmTolerance,
                    integrate: flashLfqEngine.Integrate,
                    numIsotopesRequired: flashLfqEngine.NumIsotopesRequired,
                    idSpecificChargeState: flashLfqEngine.IdSpecificChargeState,
                    requireMonoisotopicMass: flashLfqEngine.RequireMonoisotopicMass,
                    silent: false,
                    optionalPeriodicTablePath: null,
                    maxMbrWindow: flashLfqEngine.MbrRtWindow,
                    advancedProteinQuant: flashLfqEngine.AdvancedProteinQuant);

                results = flashLfqEngine.Run();
            }
            catch (Exception ex)
            {
                string errorReportPath = Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName;
                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(ex, Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            // write output
            if (results != null)
            {
                try
                {
                    OutputWriter.WriteOutput(Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName, results,
                                             outputFolderPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not write FlashLFQ output: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Runs the FlashLFQ engine with the user's defined spectra files, ID files, and FlashLFQ
        /// settings.
        /// </summary>
        private void RunFlashLfq()
        {
            // read IDs
            var ids = new List <Identification>();

            try
            {
                foreach (var identFile in idFiles)
                {
                    ids = ids.Concat(PsmReader.ReadPsms(identFile.FilePath, false, spectraFiles.Select(p => p.SpectraFileInfo).ToList())).ToList();
                }
            }
            catch (Exception e)
            {
                string errorReportPath = Directory.GetParent(spectraFiles.First().FilePath).FullName;
                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(e, Directory.GetParent(spectraFiles.First().FilePath).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + e.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ could not read the PSM file: " + e.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            if (!ids.Any())
            {
                MessageBox.Show("No peptide IDs for the specified spectra files were found! " +
                                "Check to make sure the spectra file names match between the ID file and the spectra files",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            if (ids.Any(p => p.Ms2RetentionTimeInMinutes > 500))
            {
                var res = MessageBox.Show("It seems that some of the retention times in the PSM file(s) are in seconds and not minutes; FlashLFQ requires the RT to be in minutes. " +
                                          "Continue with the FlashLFQ run? (only click yes if the RTs are actually in minutes)",
                                          "Error", MessageBoxButton.YesNo, MessageBoxImage.Hand);

                if (res == MessageBoxResult.No)
                {
                    return;
                }
            }

            // run FlashLFQ engine
            try
            {
                flashLfqEngine = FlashLfqSettings.CreateEngineWithSettings(settings, ids);

                results = flashLfqEngine.Run();
            }
            catch (Exception ex)
            {
                string errorReportPath = Directory.GetParent(spectraFiles.First().FilePath).FullName;

                if (outputFolderPath != null)
                {
                    errorReportPath = outputFolderPath;
                }

                try
                {
                    OutputWriter.WriteErrorReport(ex, Directory.GetParent(spectraFiles.First().FilePath).FullName,
                                                  outputFolderPath);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                    ".\nThe error report could not be written: " + ex2.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }

                MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message +
                                ".\nError report written to " + errorReportPath, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                return;
            }

            // write output
            if (results != null)
            {
                try
                {
                    OutputWriter.WriteOutput(Directory.GetParent(spectraFiles.First().FilePath).FullName, results, flashLfqEngine.Silent,
                                             outputFolderPath);

                    MessageBox.Show("Run complete");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not write FlashLFQ output: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);

                    return;
                }
            }
        }