public void results_decoy_dataframe_with_something()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.input_files.Add(ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Identification, "n", "s", "1", "1", "1")); //0
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1");

            e.linked_proteoform_references = new List <Proteoform>(new List <Proteoform> {
                ConstructorsForTesting.make_a_theoretical()
            });
            e.ptm_set = e.linked_proteoform_references.Last().ptm_set;
            ProteoformFamily f = new ProteoformFamily(e);

            f.construct_family();
            Sweet.lollipop.decoy_proteoform_communities.Add("Decoy1", new ProteoformCommunity());
            Sweet.lollipop.decoy_proteoform_communities["Decoy1"].families = new List <ProteoformFamily> {
                f
            };
            var time_stamp = Sweet.time_stamp();
            var directory  = TestContext.CurrentContext.TestDirectory;

            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, time_stamp, Sweet.lollipop.TusherAnalysis1 as IGoAnalysis, Sweet.lollipop.TusherAnalysis1 as TusherAnalysis);
            Assert.IsTrue(File.Exists(Path.Combine(directory, "decoy_experimental_results_" + time_stamp + ".tsv")));
            var lines = File.ReadAllLines(Path.Combine(directory, "decoy_experimental_results_" + time_stamp + ".tsv"));

            Assert.AreEqual(2, lines.Length);
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(SaveState.lollipop.results_folder))
            {
                return;
            }
            string timestamp = SaveState.time_stamp();

            ResultsSummaryGenerator.save_all(SaveState.lollipop.results_folder, timestamp);
            ((ProteoformSweet)MdiParent).save_all_plots(SaveState.lollipop.results_folder, timestamp);
        }
        public void saveall()
        {
            SaveState.lollipop = new Lollipop();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("asdf");

            SaveState.lollipop.qVals.Add(e.quant);
            GoTermNumber g = new GoTermNumber(new GoTerm("id", "desc", Aspect.BiologicalProcess), 0, 0, 0, 0);

            g.by = -1;
            SaveState.lollipop.goTermNumbers.Add(g);
            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, SaveState.time_stamp());
        }
        private void btn_save_Click(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists(Sweet.lollipop.results_folder))
            {
                return;
            }
            string timestamp = Sweet.time_stamp();

            ResultsSummaryGenerator.save_all(Sweet.lollipop.results_folder, timestamp, get_go_analysis(), get_tusher_analysis());
            MDIParent.save_all_plots(Sweet.lollipop.results_folder, timestamp);
            using (StreamWriter file = new StreamWriter(System.IO.Path.Combine(Sweet.lollipop.results_folder, "presets_" + timestamp + ".xml")))
                file.WriteLine(Sweet.save_method());
        }
        public void saveall()
        {
            Sweet.lollipop = new Lollipop();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("asdf");

            Sweet.lollipop.qVals.Add(e.quant);
            GoTermNumber g = new GoTermNumber(new GoTerm("id", "desc", Aspect.BiologicalProcess), 0, 0, 0, 0);

            g.by = -1;
            Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers.Add(g);
            Sweet.lollipop.topdown_proteoforms = new List <TopDownProteoform>()
            {
                ConstructorsForTesting.TopDownProteoform("td1", 1000, 10)
            };
            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, Sweet.time_stamp(), Sweet.lollipop.TusherAnalysis1 as IGoAnalysis, Sweet.lollipop.TusherAnalysis1 as TusherAnalysis);
        }
        public bool full_run()
        {
            clear_lists();
            if (!SaveState.lollipop.theoretical_database.ready_to_make_database(Environment.CurrentDirectory))
            {
                if (SaveState.lollipop.get_files(SaveState.lollipop.input_files, Purpose.ProteinDatabase).Count() <= 0)
                {
                    MessageBox.Show("Please list at least one protein database.", "Full Run");
                    return(false);
                }
                else
                {
                    DialogResult d = MessageBox.Show("No PTM list is listed.\n\nWill now download the default PTM list from UniProt and use it for the Full Run.", "Full Run", MessageBoxButtons.OKCancel);
                    if (d == DialogResult.OK)
                    {
                        SaveState.lollipop.enter_uniprot_ptmlist();
                        if (loadDeconvolutionResults.ReadyToRunTheGamut())
                        {
                            loadDeconvolutionResults.RunTheGamut(); // updates the dgvs
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (SaveState.lollipop.results_folder == "")
            {
                DialogResult d = MessageBox.Show("Choose a results folder for this Full Run?", "Full Run", MessageBoxButtons.YesNoCancel);
                if (d == DialogResult.Yes)
                {
                    FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
                    DialogResult        dr            = folderBrowser.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        string temp_folder_path = folderBrowser.SelectedPath;
                        SaveState.lollipop.results_folder = temp_folder_path;
                        loadDeconvolutionResults.InitializeParameterSet(); // updates the textbox
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                else if (d == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            Cursor = Cursors.WaitCursor;
            foreach (ISweetForm sweet in forms)
            {
                if (sweet.ReadyToRunTheGamut())
                {
                    sweet.RunTheGamut();
                }
            }
            string timestamp = SaveState.time_stamp();

            ResultsSummaryGenerator.save_all(SaveState.lollipop.results_folder, timestamp);
            save_all_plots(SaveState.lollipop.results_folder, timestamp);
            Cursor = Cursors.Default;
            return(true);
        }
        public Stopwatch full_run()
        {
            forms[1].ClearListsTablesFigures(true); // clear forms following load deconvolution results

            MessageBoxResult d3 = MessageBox.Show("Use presets for this Full Run?", "Full Run", MessageBoxButton.YesNoCancel);

            if (d3 == MessageBoxResult.Yes)
            {
                bool?dr = methodFileOpen.ShowDialog();
                if (dr == true)
                {
                    string           filepath = methodFileOpen.FileName;
                    MessageBoxResult d4       = MessageBox.Show("Add files at the listed paths if they still exist?", "Full Run", MessageBoxButton.YesNoCancel);
                    if (d4 == MessageBoxResult.Cancel)
                    {
                        return(null);
                    }

                    if (!open_method(filepath, File.ReadAllLines(filepath), d4 == MessageBoxResult.Yes))
                    {
                        return(null);
                    }
                    ;
                }
                else if (dr == false)
                {
                    return(null);
                }
            }
            else if (d3 == MessageBoxResult.Cancel)
            {
                return(null);
            }

            loadResults.FillTablesAndCharts(); // updates the filelists in form

            //  Check that there are input files
            if (Sweet.lollipop.input_files.Count == 0)
            {
                MessageBox.Show("Please load in deconvolution result files in order to use load and run.", "Full Run");
                return(null);
            }

            // Check that theoretical database(s) are present

            if (Sweet.lollipop.get_files(Sweet.lollipop.input_files, Purpose.ProteinDatabase).Count() <= 0)
            {
                MessageBox.Show("Please list at least one protein database.", "Full Run");
                return(null);
            }


            // Option to choose a result folder
            if (Sweet.lollipop.results_folder == "")
            {
                MessageBoxResult d2 = MessageBox.Show("Choose a results folder for this Full Run?", "Full Run", MessageBoxButton.YesNoCancel);
                if (d2 == MessageBoxResult.Yes)
                {
                    System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
                    System.Windows.Forms.DialogResult        dr            = folderBrowser.ShowDialog();
                    if (dr == System.Windows.Forms.DialogResult.OK)
                    {
                        string temp_folder_path = folderBrowser.SelectedPath;
                        Sweet.lollipop.results_folder = temp_folder_path;
                        loadResults.InitializeParameterSet(); // updates the textbox
                    }
                    else if (dr == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return(null);
                    }
                }
                else if (d2 == MessageBoxResult.Cancel)
                {
                    return(null);
                }
            }
            else
            {
                MessageBoxResult d2 = MessageBox.Show("Would you like to save results of this Full Run to " + Sweet.lollipop.results_folder + "?", "Full Run", MessageBoxButton.YesNoCancel);
                if (d2 == MessageBoxResult.No)
                {
                    Sweet.lollipop.results_folder = "";
                }
                else if (d2 == MessageBoxResult.Cancel)
                {
                    return(null);
                }
            }

            //Run the program
            Mouse.OverrideCursor = Cursors.Wait;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            foreach (ISweetForm sweet in forms)
            {
                if (sweet.ReadyToRunTheGamut())
                {
                    sweet.RunTheGamut(true);
                }
            }

            //  Save the results
            resultsSummary.InitializeParameterSet();
            if (Sweet.lollipop.results_folder != "")
            {
                string timestamp = Sweet.time_stamp();
                ResultsSummaryGenerator.save_all(Sweet.lollipop.results_folder, timestamp, resultsSummary.get_go_analysis(), resultsSummary.get_tusher_analysis());
                save_all_plots(Sweet.lollipop.results_folder, timestamp);
                using (StreamWriter file = new StreamWriter(Path.Combine(Sweet.lollipop.results_folder, "presets_" + timestamp + ".xml")))
                    file.WriteLine(Sweet.save_method());
            }
            List <string> warning_methods = new List <string>()
            {
                "Warning:"
            };

            if (Sweet.lollipop.bottomupReader.bad_ptms.Count > 0)
            {
                warning_methods.Add("The following PTMs in the bottom-up file were not matched with any PTMs in the theoretical database: ");
                warning_methods.Add(string.Join(", ", Sweet.lollipop.bottomupReader.bad_ptms.Distinct()));
            }
            if (Sweet.lollipop.topdownReader.bad_ptms.Count > 0)
            {
                warning_methods.Add("Top-down proteoforms with the following modifications were not matched to a modification in the theoretical PTM list: ");
                warning_methods.Add(string.Join(", ", Sweet.lollipop.topdownReader.bad_ptms.Distinct()));
            }
            if (Sweet.lollipop.topdown_proteoforms_no_theoretical.Count() > 0)
            {
                warning_methods.Add("Top-down proteoforms with the following accessions were not matched to a theoretical proteoform in the theoretical database: ");
                warning_methods.Add(string.Join(", ", Sweet.lollipop.topdown_proteoforms_no_theoretical.Select(t => t.accession.Split('_')[0]).Distinct()));
            }
            if (warning_methods.Count > 1)
            {
                MessageBox.Show(String.Join("\n\n", warning_methods));
            }
            //  Program ran successfully
            stopwatch.Stop();
            Mouse.OverrideCursor = null;
            return(stopwatch);
        }