コード例 #1
0
        //TODO: paired samples

        public FlashLfqSettings()
        {
            FlashLfqEngine f = new FlashLfqEngine(new List <Identification>());
            var            bayesianSettings = new ProteinQuantificationEngine(new FlashLfqResults(new List <SpectraFileInfo>(), new List <Identification>()), 1, "temp");

            Normalize             = f.Normalize;
            PpmTolerance          = f.PpmTolerance;
            IsotopePpmTolerance   = f.IsotopePpmTolerance;
            Integrate             = f.Integrate;
            NumIsotopesRequired   = f.NumIsotopesRequired;
            IdSpecificChargeState = f.IdSpecificChargeState;
            MaxThreads            = f.MaxThreads;

            MatchBetweenRuns         = f.MatchBetweenRuns;
            MbrRtWindow              = f.MbrRtWindow;
            RequireMsmsIdInCondition = f.RequireMsmsIdInCondition;

            BayesianProteinQuant         = f.BayesianProteinQuant;
            ProteinQuantBaseCondition    = f.ProteinQuantBaseCondition;
            ProteinQuantFoldChangeCutoff = 0.1;
            McmcSteps       = f.McmcSteps;
            McmcBurninSteps = f.McmcBurninSteps;
            UseSharedPeptidesForProteinQuant = f.UseSharedPeptidesForProteinQuant;

            RandomSeed = bayesianSettings.RandomSeed;
        }
コード例 #2
0
        private void changeSettingsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new SettingsWindow();

            dialog.PopulateSettings(flashLfqEngine);

            if (dialog.ShowDialog() == true)
            {
                flashLfqEngine = dialog.TempFlashLfqEngine;
            }
        }
コード例 #3
0
        public void PopulateSettings(FlashLfqEngine engine)
        {
            normalize.IsChecked            = engine.Normalize;
            ppmTolerance.Text              = engine.PpmTolerance.ToString(CultureInfo.InvariantCulture);
            mbr.IsChecked                  = engine.MatchBetweenRuns;
            advancedProteinQuant.IsChecked = engine.AdvancedProteinQuant;

            integrate.IsChecked               = engine.Integrate;
            precursorChargeOnly.IsChecked     = engine.IdSpecificChargeState;
            requireMonoisotopicPeak.IsChecked = engine.RequireMonoisotopicMass;
            isotopeTolerance.Text             = engine.IsotopePpmTolerance.ToString(CultureInfo.InvariantCulture);
            numIsotopePeak.Text               = engine.NumIsotopesRequired.ToString();
            maxMbrWindow.Text = engine.MbrRtWindow.ToString(CultureInfo.InvariantCulture);
        }
コード例 #4
0
        public MainWindow()
        {
            InitializeComponent();

            spectraFilesForDataGrid = new ObservableCollection <SpectraFileForDataGrid>();
            identFilesForDataGrid   = new ObservableCollection <IdentificationFileForDataGrid>();
            worker         = new BackgroundWorker();
            worker.DoWork += new DoWorkEventHandler(RunProgram);

            flashLfqEngine  = new FlashLfqEngine(new List <Identification>());
            spectraFileInfo = new List <SpectraFileInfo>();

            identFilesDataGrid.DataContext   = identFilesForDataGrid;
            dataGridSpectraFiles.DataContext = spectraFilesForDataGrid;

            var _writer = new TextBoxWriter(notificationsTextBox);

            Console.SetOut(_writer);
        }
コード例 #5
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckForValidEntries())
            {
                return;
            }

            TempFlashLfqEngine = new FlashLfqEngine(new List <Identification>(),
                                                    advancedProteinQuant: advancedProteinQuant.IsChecked.Value,
                                                    normalize: normalize.IsChecked.Value,
                                                    ppmTolerance: double.Parse(ppmTolerance.Text),
                                                    matchBetweenRuns: mbr.IsChecked.Value,
                                                    integrate: integrate.IsChecked.Value,
                                                    idSpecificChargeState: precursorChargeOnly.IsChecked.Value,
                                                    requireMonoisotopicMass: requireMonoisotopicPeak.IsChecked.Value,
                                                    isotopeTolerancePpm: double.Parse(isotopeTolerance.Text),
                                                    numIsotopesRequired: int.Parse(numIsotopePeak.Text),
                                                    maxMbrWindow: double.Parse(maxMbrWindow.Text));

            DialogResult = true;
        }
コード例 #6
0
        public MainWindow()
        {
            InitializeComponent();
            PopulateSettings();

            spectraFiles = new ObservableCollection <SpectraFileForDataGrid>();

            conditions = new ObservableCollection <string>();
            ControlConditionComboBox.ItemsSource = conditions;

            // sort the spectra files by condition, then sample, then fraction, then replicate
            var collectionView = CollectionViewSource.GetDefaultView(spectraFiles);

            collectionView.SortDescriptions.Add(new SortDescription(nameof(SpectraFileForDataGrid.Condition), ListSortDirection.Ascending));
            collectionView.SortDescriptions.Add(new SortDescription(nameof(SpectraFileForDataGrid.Sample), ListSortDirection.Ascending));
            collectionView.SortDescriptions.Add(new SortDescription(nameof(SpectraFileForDataGrid.Fraction), ListSortDirection.Ascending));
            collectionView.SortDescriptions.Add(new SortDescription(nameof(SpectraFileForDataGrid.Replicate), ListSortDirection.Ascending));

            // file names are readonly
            spectraFilesDataGrid.Columns[0].IsReadOnly = true;
            identFilesDataGrid.Columns[0].IsReadOnly   = true;

            idFiles                    = new ObservableCollection <IdentificationFileForDataGrid>();
            worker                     = new BackgroundWorker();
            worker.DoWork             += new DoWorkEventHandler(RunProgram);
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;

            flashLfqEngine = new FlashLfqEngine(new List <Identification>());

            identFilesDataGrid.ItemsSource   = idFiles;
            spectraFilesDataGrid.DataContext = spectraFiles;

            BayesianSettings1.Visibility = Visibility.Hidden;
            BayesianSettings2.Visibility = Visibility.Hidden;

            var _writer = new TextBoxWriter(notificationsTextBox);

            Console.SetOut(_writer);
        }
コード例 #7
0
        private static void Run(FlashLfqSettings settings)
        {
            try
            {
                settings.ValidateCommandLineSettings();
            }
            catch (Exception e)
            {
                if (!settings.Silent)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
                return;
            }

            // check to see if experimental design file exists
            string assumedPathToExpDesign = Path.Combine(settings.SpectraFileRepository, "ExperimentalDesign.tsv");

            if ((settings.Normalize || settings.BayesianProteinQuant) && !File.Exists(assumedPathToExpDesign))
            {
                if (!settings.Silent)
                {
                    Console.WriteLine("Could not find experimental design file " +
                                      "(required for normalization and Bayesian statistical analysis): " + assumedPathToExpDesign);
                }
                return;
            }

            // set up spectra file info
            List <SpectraFileInfo> spectraFileInfos = new List <SpectraFileInfo>();
            List <string>          filePaths        = Directory.GetFiles(settings.SpectraFileRepository)
                                                      .Where(f => acceptedSpectrumFileFormats.Contains(Path.GetExtension(f).ToLowerInvariant())).ToList();

            // check for duplicate file names (agnostic of file extension)
            foreach (var fileName in filePaths.GroupBy(p => Path.GetFileNameWithoutExtension(p)))
            {
                if (fileName.Count() > 1)
                {
                    var types = fileName.Select(p => Path.GetFileNameWithoutExtension(p)).Distinct();

                    if (!settings.Silent)
                    {
                        Console.WriteLine("Multiple spectra files with the same name were detected (maybe " + string.Join(" and ", types) + "?). " +
                                          "Please remove or rename duplicate files from the spectra file directory.");
                    }
                    return;
                }
            }

            if (settings.PrintThermoLicenceViaCommandLine)
            {
                Console.WriteLine(ThermoRawFileReaderLicence.ThermoLicenceText);
                return;
            }

            // check thermo licence agreement
            if (filePaths.Select(v => Path.GetExtension(v).ToLowerInvariant()).Any(f => f == ".raw"))
            {
                var licenceAgreement = LicenceAgreementSettings.ReadLicenceSettings();

                if (!licenceAgreement.HasAcceptedThermoLicence)
                {
                    if (settings.AcceptThermoLicenceViaCommandLine)
                    {
                        if (!settings.ReadOnlyFileSystem)
                        {
                            licenceAgreement.AcceptLicenceAndWrite();
                        }
                    }
                    else
                    {
                        // decided to write this even if it's on silent mode...
                        Console.WriteLine(ThermoRawFileReaderLicence.ThermoLicenceText);
                        Console.WriteLine("\nIn order to search Thermo .raw files, you must agree to the above terms. Do you agree to the above terms? y/n\n");

                        string res = Console.ReadLine();

                        if (res.ToLowerInvariant() == "y")
                        {
                            try
                            {
                                if (!settings.ReadOnlyFileSystem)
                                {
                                    licenceAgreement.AcceptLicenceAndWrite();
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Thermo licence has been declined. Exiting FlashLFQ. You can still search .mzML and .mgf files without agreeing to the Thermo licence.");
                            return;
                        }
                    }
                }
            }

            if (File.Exists(assumedPathToExpDesign))
            {
                var experimentalDesign = File.ReadAllLines(assumedPathToExpDesign)
                                         .ToDictionary(v => v.Split('\t')[0], v => v);

                foreach (var file in filePaths)
                {
                    string filename = Path.GetFileNameWithoutExtension(file);

                    var expDesignForThisFile = experimentalDesign[filename];
                    var split = expDesignForThisFile.Split('\t');

                    string condition = split[1];
                    int    biorep    = int.Parse(split[2]);
                    int    fraction  = int.Parse(split[3]);
                    int    techrep   = int.Parse(split[4]);

                    // experimental design info passed in here for each spectra file
                    spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                             condition: condition,
                                                             biorep: biorep - 1,
                                                             fraction: fraction - 1,
                                                             techrep: techrep - 1));
                }
            }
            else
            {
                for (int i = 0; i < filePaths.Count; i++)
                {
                    var file = filePaths[i];
                    spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                             condition: "Default",
                                                             biorep: i,
                                                             fraction: 0,
                                                             techrep: 0));
                }
            }

            // check the validity of the settings and experimental design
            try
            {
                settings.ValidateSettings(spectraFileInfos);
            }
            catch (Exception e)
            {
                if (!settings.Silent)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
                return;
            }

            // set up IDs
            List <Identification> ids;

            try
            {
                ids = PsmReader.ReadPsms(settings.PsmIdentificationPath, settings.Silent, spectraFileInfos);
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem reading PSMs: " + e.Message);
                return;
            }

            if (ids.Any())
            {
                if (!settings.Silent)
                {
                    Console.WriteLine("Setup is OK; read in " + ids.Count + " identifications; starting FlashLFQ engine");
                }

                // write FlashLFQ settings to a file
                if (!Directory.Exists(settings.OutputPath))
                {
                    Directory.CreateDirectory(settings.OutputPath);
                }
                Nett.Toml.WriteFile(settings, Path.Combine(settings.OutputPath, "FlashLfqSettings.toml"));

                // make engine with desired settings
                FlashLfqEngine  engine  = null;
                FlashLfqResults results = null;
                try
                {
                    engine = FlashLfqSettings.CreateEngineWithSettings(settings, ids);

                    // run
                    results = engine.Run();
                }
                catch (Exception ex)
                {
                    string errorReportPath = Directory.GetParent(filePaths.First()).FullName;
                    if (settings.OutputPath != null)
                    {
                        errorReportPath = settings.OutputPath;
                    }

                    if (!settings.Silent)
                    {
                        Console.WriteLine("FlashLFQ has crashed with the following error: " + ex.Message +
                                          ".\nError report written to " + errorReportPath);
                    }

                    OutputWriter.WriteErrorReport(ex, Directory.GetParent(filePaths.First()).FullName, settings.OutputPath);
                }

                // output
                if (results != null)
                {
                    try
                    {
                        OutputWriter.WriteOutput(settings.PsmIdentificationPath, results, settings.Silent, settings.OutputPath);
                    }
                    catch (Exception ex)
                    {
                        if (!settings.Silent)
                        {
                            Console.WriteLine("Could not write FlashLFQ output: " + ex.Message);
                        }
                    }
                }
            }
            else
            {
                if (!settings.Silent)
                {
                    Console.WriteLine("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");
                }
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            // parameters
            List <string> acceptedSpectrumFileFormats = new List <string> {
                ".RAW", ".MZML"
            };

            // setup parameters
            var p = new FluentCommandLineParser <ApplicationArguments>();

            p.SetupHelp("?", "help")
            .Callback(text => Console.WriteLine(
                          "Valid arguments:\n" +
                          "--idt [string|identification file path (TSV format)]\n" +
                          "--rep [string|directory containing spectrum data files]\n" +
                          "--out [string|output directory]\n" +
                          "--ppm [double|ppm tolerance]\n" +
                          "--iso [double|isotopic distribution tolerance in ppm]\n" +
                          "--sil [bool|silent mode]\n" +
                          "--int [bool|integrate features]\n" +
                          "--mbr [bool|match between runs]\n" +
                          "--mrt [double|maximum MBR window in minutes]\n" +
                          "--chg [bool|use only precursor charge state]\n" +
                          "--rmm [bool|require observed monoisotopic mass peak]\n" +
                          "--nis [int|number of isotopes required to be observed]\n" +
                          "--nor [bool|normalize intensity results]\n" +
                          "--pro [bool|advanced protein quantification]\n"
                          ));

            p.Setup(arg => arg.PsmInputPath) // PSMs file
            .As("idt").
            Required();

            p.Setup(arg => arg.RawFilesPath) // spectrum files
            .As("rep").
            Required();

            p.Setup(arg => arg.OutputPath) // output path
            .As("out");

            p.Setup(arg => arg.PpmTolerance) // ppm tolerance
            .As("ppm");

            p.Setup(arg => arg.IsotopePpmTolerance) // isotope ppm tolerance
            .As("iso");

            p.Setup(arg => arg.Silent) // do not display output messages
            .As("sil");

            p.Setup(arg => arg.Integrate) // integrate
            .As("int");

            p.Setup(arg => arg.MatchBetweenRuns) // match between runs
            .As("mbr");

            p.Setup(arg => arg.MbrRtWindow) // maximum match-between-runs window in minutes
            .As("mrt");

            p.Setup(arg => arg.IdSpecificChargeState) // only use PSM-identified charge states
            .As("chg");

            p.Setup(arg => arg.RequireMonoisotopicMass) // require observation of monoisotopic peak
            .As("rmm");

            p.Setup(arg => arg.NumIsotopesRequired) // num of isotopes required
            .As("nis");

            p.Setup(arg => arg.Normalize) // normalize
            .As("nor");

            p.Setup(arg => arg.AdvancedProteinQuant) // advanced protein quant
            .As("pro");

            // args are OK - run FlashLFQ
            if (!p.Parse(args).HasErrors&& p.Object.PsmInputPath != null)
            {
                if (!File.Exists(p.Object.PsmInputPath))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not locate identification file " + p.Object.PsmInputPath);
                    }
                    return;
                }

                if (!Directory.Exists(p.Object.RawFilesPath))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not locate folder " + p.Object.RawFilesPath);
                    }
                    return;
                }

                string assumedPathToExpDesign = Path.Combine(p.Object.RawFilesPath, "ExperimentalDesign.tsv");
                if (p.Object.Normalize && !File.Exists(assumedPathToExpDesign))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not find experimental design file (required for normalization): " + assumedPathToExpDesign);
                    }
                    return;
                }

                // set up spectra file info
                // get experimental design info for normalization
                List <SpectraFileInfo> spectraFileInfos = new List <SpectraFileInfo>();
                IEnumerable <string>   files            = Directory.GetFiles(p.Object.RawFilesPath)
                                                          .Where(f => acceptedSpectrumFileFormats.Contains(Path.GetExtension(f).ToUpperInvariant()));

                if (p.Object.Normalize)
                {
                    var experimentalDesign = File.ReadAllLines(assumedPathToExpDesign)
                                             .ToDictionary(v => v.Split('\t')[0], v => v);

                    foreach (var file in files)
                    {
                        string filename = Path.GetFileNameWithoutExtension(file);

                        var expDesignForThisFile = experimentalDesign[filename];
                        var split = expDesignForThisFile.Split('\t');

                        string condition = split[1];
                        int    biorep    = int.Parse(split[2]);
                        int    fraction  = int.Parse(split[3]);
                        int    techrep   = int.Parse(split[4]);

                        // experimental design info passed in here for each spectra file
                        spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                                 condition: condition,
                                                                 biorep: biorep - 1,
                                                                 fraction: fraction - 1,
                                                                 techrep: techrep - 1));
                    }
                }
                else
                {
                    foreach (var file in files)
                    {
                        spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                                 condition: "",
                                                                 biorep: 0,
                                                                 fraction: 0,
                                                                 techrep: 0));
                    }
                }

                // set up IDs
                List <Identification> ids;
                try
                {
                    ids = PsmReader.ReadPsms(p.Object.PsmInputPath, p.Object.Silent, spectraFileInfos);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Problem reading PSMs: " + e.Message);
                    return;
                }

                if (ids.Any())
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Setup is OK; read in " + ids.Count + " identifications; starting FlashLFQ engine");
                    }

                    // make engine with desired settings
                    FlashLfqEngine  engine  = null;
                    FlashLfqResults results = null;
                    try
                    {
                        engine = new FlashLfqEngine(
                            allIdentifications: ids,
                            normalize: p.Object.Normalize,
                            ppmTolerance: p.Object.PpmTolerance,
                            isotopeTolerancePpm: p.Object.IsotopePpmTolerance,
                            matchBetweenRuns: p.Object.MatchBetweenRuns,
                            matchBetweenRunsPpmTolerance: p.Object.MbrPpmTolerance,
                            integrate: p.Object.Integrate,
                            numIsotopesRequired: p.Object.NumIsotopesRequired,
                            idSpecificChargeState: p.Object.IdSpecificChargeState,
                            requireMonoisotopicMass: p.Object.RequireMonoisotopicMass,
                            silent: p.Object.Silent,
                            optionalPeriodicTablePath: null,
                            maxMbrWindow: p.Object.MbrRtWindow,
                            advancedProteinQuant: p.Object.AdvancedProteinQuant);

                        // run
                        results = engine.Run();
                    }
                    catch (Exception ex)
                    {
                        string errorReportPath = Directory.GetParent(files.First()).FullName;
                        if (p.Object.OutputPath != null)
                        {
                            errorReportPath = p.Object.OutputPath;
                        }

                        if (!p.Object.Silent)
                        {
                            Console.WriteLine("FlashLFQ has crashed with the following error: " + ex.Message +
                                              ".\nError report written to " + errorReportPath);
                        }

                        OutputWriter.WriteErrorReport(ex, Directory.GetParent(files.First()).FullName, p.Object.OutputPath);
                    }

                    // output
                    if (results != null)
                    {
                        try
                        {
                            OutputWriter.WriteOutput(p.Object.PsmInputPath, results, p.Object.OutputPath);
                        }
                        catch (Exception ex)
                        {
                            if (!p.Object.Silent)
                            {
                                Console.WriteLine("Could not write FlashLFQ output: " + ex.Message);
                            }
                        }
                    }
                }
                else
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("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");
                    }
                }
            }
            else if (p.Parse(args).HasErrors == false && p.Object.PsmInputPath == null)
            {
                // no errors - just requesting help?
            }
            else
            {
                Console.WriteLine("Invalid arguments - type \"--help\" for valid arguments");
            }
        }
コード例 #9
0
ファイル: Test.cs プロジェクト: trishorts/FlashLFQ
        ///
        /// The purpose of this unit test is to ensure that the settings passed by the user through the command-line or the GUI
        /// are passed propertly into the FlashLFQ engine.
        ///
        public static void TestSettingsPassing()
        {
            // make settings
            FlashLfqSettings settings = new FlashLfqSettings();

            // set the settings to non-default values
            var properties = settings.GetType().GetProperties();

            foreach (var property in properties)
            {
                Type type = property.PropertyType;

                if (type == typeof(string))
                {
                    property.SetValue(settings, "TEST_VALUE");
                }
                else if (type == typeof(bool) || type == typeof(bool?))
                {
                    if (property.GetValue(settings) == null || (bool)property.GetValue(settings) == false)
                    {
                        property.SetValue(settings, true);
                    }
                    else
                    {
                        property.SetValue(settings, false);
                    }
                }
                else if (type == typeof(double) || type == typeof(double?))
                {
                    property.SetValue(settings, double.MinValue);
                }
                else if (type == typeof(int) || type == typeof(int?))
                {
                    property.SetValue(settings, int.MinValue);
                }
                else
                {
                    Assert.IsTrue(false);
                }
            }

            settings.MaxThreads = 1;

            FlashLfqEngine e = FlashLfqSettings.CreateEngineWithSettings(settings, new List <Identification>());

            var engineProperties = e.GetType().GetFields();

            // check to make sure the settings got passed properly into the engine (the settings should have identical values)
            foreach (var property in properties)
            {
                string name = property.Name;

                // skip settings that don't exist in the FlashLFQ engine
                // these are usually just command-line options for i/o stuff, etc.
                if (name == "PsmIdentificationPath" ||
                    name == "SpectraFileRepository" ||
                    name == "OutputPath" ||
                    name == "ReadOnlyFileSystem" ||
                    name == "PrintThermoLicenceViaCommandLine" ||
                    name == "AcceptThermoLicenceViaCommandLine")
                {
                    continue;
                }

                var engineProperty = engineProperties.First(p => p.Name == name);

                var settingsValue = property.GetValue(settings);
                var engineValue   = engineProperty.GetValue(e);

                Assert.AreEqual(settingsValue, engineValue);
            }
        }
コード例 #10
0
ファイル: Benchmarks.cs プロジェクト: lonelu/HPCmzLib
        private static void Main(string[] args)
        {
            Console.WriteLine("Welcome to MetaMorpheus");


            // EDGAR: Createing the FlashLfqEngine is unforunately required,
            // otherwise the code just crashes when executed.

            SpectraFileInfo mzml = new SpectraFileInfo("sliced-mzml.mzml", "a", 0, 1, 0);
            var             pg   = new FlashLFQ.ProteinGroup("MyProtein", "gene", "org");
            Identification  id3  = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR",
                                                      1350.65681, 94.12193, 2, new List <FlashLFQ.ProteinGroup> {
                pg
            });
            Identification id4 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR",
                                                    1350.65681, 94.05811, 2, new List <FlashLFQ.ProteinGroup> {
                pg
            });
            FlashLfqEngine engine = new FlashLfqEngine(new List <Identification> {
                id3, id4
            }, normalize: true);

            // EDGAR: End of part required to avoid crash


            //generate toml
            Console.WriteLine("generating toml with {0} key-value pairs", args[1]);
            var tomlData = Toml.Create();

            for (int i = 0; i < int.Parse(args[1]); i++)
            {
                tomlData.Add(i.ToString(), i);
            }

            //write toml
            Console.WriteLine("writing toml file {0}", args[0]);
            Stopwatch stopwatch = Stopwatch.StartNew();

            Toml.WriteFile(tomlData, args[0]);
            stopwatch.Stop();
            Console.WriteLine("Time elapsed for toml write: {0}\n", stopwatch.ElapsedMilliseconds);


            //read file
            Console.WriteLine("reading toml file {0}", args[0]);
            stopwatch = Stopwatch.StartNew();
            var tomlRead = Toml.ReadFile(args[0]);

            stopwatch.Stop();
            Console.WriteLine("Time elapsed for toml read: {0}\n", stopwatch.ElapsedMilliseconds);


            //read mzml file
            Console.WriteLine("reading mzml file {0}", args[2]);
            stopwatch = Stopwatch.StartNew();
            var msData = Mzml.LoadAllStaticData(args[2]);

            stopwatch.Stop();
            Console.WriteLine("Time elapsed for mzML read: {0}\n", stopwatch.ElapsedMilliseconds);


            //write mzml file
            Console.WriteLine("writing mzml file {0}", args[3]);
            stopwatch = Stopwatch.StartNew();
            MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(msData, args[3], false);
            stopwatch.Stop();
            Console.WriteLine("Time elapsed for mzML write: {0}", stopwatch.ElapsedMilliseconds);
        }
コード例 #11
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;
                }
            }
        }
コード例 #12
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;
                }
            }
        }
コード例 #13
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;
                }
            }
        }