From 2147b8e2344f209d1eaa0b8cd6e593d433eb2a5e Mon Sep 17 00:00:00 2001 From: RobbinBouwmeester Date: Thu, 12 Dec 2024 11:32:04 +0100 Subject: [PATCH 1/3] Remove dependency on st_pages --- webinterface/_base.py | 2 - ..._lfq_ion_DDA.py => 2_Quant_LFQ_ion_DDA.py} | 1 + ..._DIA_AIF.py => 3_Quant_LFQ_ion_DIA_AIF.py} | 0 ...SEF.py => 4_Quant_LFQ_ion_DIA_diaPASEF.py} | 0 ..._DDA.py => 5_quant_LFQ_peptidoform_DDA.py} | 8 +- ....py => 6_Quant_LFQ_peptidoform_DIA_AIF.py} | 0 webinterface/pages/TEMPLATE.py | 281 ------------------ webinterface/pages/base_pages/quant.py | 12 +- webinterface/pages/module_pages/__init__.py | 0 .../Quant/lfq/ion/DIA/ion_diaPASEF.py | 4 +- 10 files changed, 14 insertions(+), 294 deletions(-) rename webinterface/pages/{module_pages/quant_lfq_ion_DDA.py => 2_Quant_LFQ_ion_DDA.py} (99%) rename webinterface/pages/{module_pages/quant_lfq_ion_DIA_AIF.py => 3_Quant_LFQ_ion_DIA_AIF.py} (100%) rename webinterface/pages/{module_pages/quant_lfq_ion_DIA_diaPASEF.py => 4_Quant_LFQ_ion_DIA_diaPASEF.py} (100%) rename webinterface/pages/{module_pages/quant_lfq_peptidoform_DDA.py => 5_quant_LFQ_peptidoform_DDA.py} (95%) rename webinterface/pages/{module_pages/quant_lfq_peptidoform_DIA_AIF.py => 6_Quant_LFQ_peptidoform_DIA_AIF.py} (100%) delete mode 100644 webinterface/pages/TEMPLATE.py delete mode 100644 webinterface/pages/module_pages/__init__.py diff --git a/webinterface/_base.py b/webinterface/_base.py index c1930be0..ce11eba3 100644 --- a/webinterface/_base.py +++ b/webinterface/_base.py @@ -4,7 +4,6 @@ import pages.texts.proteobench_builder as pbb import streamlit as st -from st_pages import show_pages_from_config import proteobench @@ -20,7 +19,6 @@ def __init__(self) -> None: self._preface() self._main_page() - show_pages_from_config() def _preface(self): st.markdown( diff --git a/webinterface/pages/module_pages/quant_lfq_ion_DDA.py b/webinterface/pages/2_Quant_LFQ_ion_DDA.py similarity index 99% rename from webinterface/pages/module_pages/quant_lfq_ion_DDA.py rename to webinterface/pages/2_Quant_LFQ_ion_DDA.py index a57c063e..026fcce3 100644 --- a/webinterface/pages/module_pages/quant_lfq_ion_DDA.py +++ b/webinterface/pages/2_Quant_LFQ_ion_DDA.py @@ -13,6 +13,7 @@ class StreamlitUI: def __init__(self): + print("page loaded") self.variables_dda_quant: VariablesDDAQuant = VariablesDDAQuant() self.texts: Type[WebpageTexts] = WebpageTexts self.texts.ShortMessages.title = "DDA Ion quantification" diff --git a/webinterface/pages/module_pages/quant_lfq_ion_DIA_AIF.py b/webinterface/pages/3_Quant_LFQ_ion_DIA_AIF.py similarity index 100% rename from webinterface/pages/module_pages/quant_lfq_ion_DIA_AIF.py rename to webinterface/pages/3_Quant_LFQ_ion_DIA_AIF.py diff --git a/webinterface/pages/module_pages/quant_lfq_ion_DIA_diaPASEF.py b/webinterface/pages/4_Quant_LFQ_ion_DIA_diaPASEF.py similarity index 100% rename from webinterface/pages/module_pages/quant_lfq_ion_DIA_diaPASEF.py rename to webinterface/pages/4_Quant_LFQ_ion_DIA_diaPASEF.py diff --git a/webinterface/pages/module_pages/quant_lfq_peptidoform_DDA.py b/webinterface/pages/5_quant_LFQ_peptidoform_DDA.py similarity index 95% rename from webinterface/pages/module_pages/quant_lfq_peptidoform_DDA.py rename to webinterface/pages/5_quant_LFQ_peptidoform_DDA.py index 1a39fa2d..75426e42 100644 --- a/webinterface/pages/module_pages/quant_lfq_peptidoform_DDA.py +++ b/webinterface/pages/5_quant_LFQ_peptidoform_DDA.py @@ -1,13 +1,13 @@ import logging from typing import Any, Dict, Type -import pages.texts.proteobench_builder as pbb +import pages_dir.texts.proteobench_builder as pbb import streamlit as st -from pages.base_pages.quant import QuantUIObjects -from pages.pages_variables.Quant.lfq.peptidoform.DDA.peptidoform_variables import ( +from pages_dir.base_pages.quant import QuantUIObjects +from pages_dir.pages_variables.Quant.lfq.peptidoform.DDA.peptidoform_variables import ( VariablesDDAQuant, ) -from pages.texts.generic_texts import WebpageTexts +from pages_dir.texts.generic_texts import WebpageTexts from proteobench.io.parsing.parse_settings import ParseSettingsBuilder from proteobench.modules.quant.lfq.peptidoform.DDA.quant_lfq_peptidoform_DDA import ( diff --git a/webinterface/pages/module_pages/quant_lfq_peptidoform_DIA_AIF.py b/webinterface/pages/6_Quant_LFQ_peptidoform_DIA_AIF.py similarity index 100% rename from webinterface/pages/module_pages/quant_lfq_peptidoform_DIA_AIF.py rename to webinterface/pages/6_Quant_LFQ_peptidoform_DIA_AIF.py diff --git a/webinterface/pages/TEMPLATE.py b/webinterface/pages/TEMPLATE.py deleted file mode 100644 index 72b54877..00000000 --- a/webinterface/pages/TEMPLATE.py +++ /dev/null @@ -1,281 +0,0 @@ -"""Streamlit-based web interface for ProteoBench.""" - -import json -import logging -from datetime import datetime - -import pages.texts.proteobench_builder as pbb -import streamlit as st -import streamlit_utils -from streamlit_extras.let_it_rain import rain - -from proteobench.modules.template.module import Module -from proteobench.modules.template.parse_settings import ( - INPUT_FORMATS, - LOCAL_DEVELOPMENT, - TEMPLATE_RESULTS_PATH, -) -from proteobench.modules.template.plot import plot_bench1, plot_bench2 - -logger = logging.getLogger(__name__) - -## Different parts of the web application -# Data for generating the figures -# This is usually -# a) The result of the given datapoint -RESULT_PERF = "result_perf" -# b) All datapoints read from a json file or downloaded from the web -ALL_DATAPOINTS = "all_datapoints" -SUBMIT = "submit" -# Add your figures here -FIG1 = "fig1" -FIG2 = "fig2" - -if "submission_ready" not in st.session_state: - st.session_state["submission_ready"] = False - - -class StreamlitUI: - """Proteobench Streamlit UI.""" - - def __init__(self): - """Proteobench Streamlit UI.""" - self.texts = WebpageTexts - self.user_input = dict() - - pbb.proteobench_page_config() - pbb.proteobench_sidebar() - - if SUBMIT not in st.session_state: - st.session_state[SUBMIT] = False - self._main_page() - - # Here the user can select the input file format. This is defined in the - # modules folder in the io_parse_settings folder - def generate_input_field(self, input_format: str, content: dict): - if content["type"] == "text_input": - return st.text_input(content["label"], content["value"][input_format]) - if content["type"] == "number_input": - return st.number_input( - content["label"], - value=content["value"][input_format], - format=content["format"], - ) - if content["type"] == "selectbox": - return st.selectbox( - content["label"], - content["options"], - content["options"].index(content["value"][input_format]), - ) - if content["type"] == "checkbox": - return st.checkbox(content["label"], content["value"][input_format]) - - def _main_page(self): - """Format main page.""" - st.title("Proteobench") - st.header("Input and configuration") - - with st.form(key="main_form"): - st.subheader("Input files") - self.user_input["input_csv"] = st.file_uploader( - "Search engine result file", help=self.texts.Help.input_file - ) - - self.user_input["input_format"] = st.selectbox( - "Search engine", INPUT_FORMATS, help=self.texts.Help.input_format - ) - - # self.user_input["pull_req"] = st.text_input( - # "Open pull request to make results available to everyone (type \"YES\" to enable)", - # "NO" - # ) - - with st.expander("Additional parameters"): - # Here the user enters metadata about the data analysis - with open("../webinterface/configuration/template.json") as file: - config = json.load(file) - - for key, value in config.items(): - self.user_input[key] = self.generate_input_field(self.user_input["input_format"], value) - submit_button = st.form_submit_button("Parse and bench", help=self.texts.Help.additional_parameters) - - # if st.session_state[SUBMIT]: - if FIG1 in st.session_state: - self._populate_results() - - if submit_button: - self._run_proteobench() - - def _populate_results(self): - self.generate_results("", None, None, False) - - def _run_proteobench(self): - # Run Proteobench - st.header("Running Proteobench") - status_placeholder = st.empty() - status_placeholder.info(":hourglass_flowing_sand: Running Proteobench...") - - if ALL_DATAPOINTS not in st.session_state: - st.session_state[ALL_DATAPOINTS] = None - - try: - result_performance, all_datapoints = Module().benchmarking( - self.user_input["input_csv"], - self.user_input["input_format"], - self.user_input, - st.session_state["all_datapoints"], - ) - st.session_state[ALL_DATAPOINTS] = all_datapoints - except Exception as e: - status_placeholder.error(":x: Proteobench ran into a problem") - st.exception(e) - else: - self.generate_results(status_placeholder, result_performance, all_datapoints, True) - - def generate_results(self, status_placeholder, result_performance, all_datapoints, recalculate): - time_stamp = datetime.now().strftime("%Y%m%d_%H%M%S") - - if recalculate: - status_placeholder.success(":heavy_check_mark: Finished!") - - # Show head of result DataFrame - st.header("Results") - st.subheader("Sample of the processed file") - if not recalculate: - result_performance = st.session_state[RESULT_PERF] - all_datapoints = st.session_state[ALL_DATAPOINTS] - st.dataframe(result_performance.head(100)) - - # Plot results - # set your title - st.subheader("TITLE FOR FIGURE 1") - if recalculate: - # calling the plot functions in modules/template/plot.py - fig = plot_bench1(result_performance) - else: - fig = st.session_state[FIG1] - st.plotly_chart(fig, use_container_width=True) - - # set your title - st.subheader("TITLE FOR FIGURE 2") - # show metadata - # st.text(all_datapoints.head(100)) - - if recalculate: - # calling the plot functions in modules/template/plot.py - fig2 = plot_bench1(all_datapoints) - else: - fig2 = st.session_state[FIG2] - st.plotly_chart(fig2, use_container_width=True) - - # Naming the sample with specifics about input and analysis - sample_name = "%s-%s-%s-%s" % ( - self.user_input["input_format"], - self.user_input["version"], - self.user_input["mbr"], - time_stamp, - ) - - # Download link - st.subheader("Download calculated ratios") - st.download_button( - label="Download", - data=streamlit_utils.save_dataframe(result_performance), - file_name=f"{sample_name}.csv", - mime="text/csv", - ) - st.subheader("Add results to online repository") - st.session_state[FIG1] = fig - st.session_state[FIG2] = fig2 - st.session_state[RESULT_PERF] = result_performance - st.session_state[ALL_DATAPOINTS] = all_datapoints - - checkbox = st.checkbox("I confirm that the metadata is correct") - if checkbox: - st.session_state["submission_ready"] = True - submit_pr = st.button("I really want to upload it") - # TODO: check if parameters are filled - # submit_pr = False - if submit_pr: - st.session_state[SUBMIT] = True - if not LOCAL_DEVELOPMENT: - try: - secret = st.secrets["gh"]["token"] - except: - secret = "" - Module().clone_pr( - st.session_state[ALL_DATAPOINTS], - secret, - username="Proteobot", - remote_git="github.com/Proteobot/Results_Module2_quant_DDA.git", - branch_name="new_branch", - ) - else: - DDA_QUANT_RESULTS_PATH = Module().write_json_local_development(st.session_state[ALL_DATAPOINTS]) - if SUBMIT in st.session_state: - if st.session_state[SUBMIT]: - # status_placeholder.success(":heavy_check_mark: Successfully uploaded data!") - st.subheader("SUCCESS") - st.session_state[SUBMIT] = False - rain(emoji="🎈", font_size=54, falling_speed=5, animation_length=1) - - -## Inline documentation. This is the one for the DDA_Quant module -class WebpageTexts: - class Sidebar: - about = f""" - """ - - class Help: - input_file = """ - Output file of the search engine - """ - - pull_req = """ - It is open to the public indefinitely. - """ - - input_format = """ - Please select the software you used to generate the search engine results. - You can check the toml files at https://github.com/Proteobench/ProteoBench/tree/main/proteobench/modules/dda_quant/io_parse_settings - for more details. - Additionally, you can use the tab-delimited Custom format containing the following columns: - Sequence: peptide sequence - Proteins: Protein accessions according to fasta file - Charge (optional): Charge state of measured peptide - FQ_Orbitrap_DDA_Condition_A_Sample_Alpha_01: Quantitative column sample 1 - LFQ_Orbitrap_DDA_Condition_A_Sample_Alpha_02: Quantitative column sample 2 - LFQ_Orbitrap_DDA_Condition_A_Sample_Alpha_03: Quantitative column sample 3 - LFQ_Orbitrap_DDA_Condition_B_Sample_Alpha_01: Quantitative column sample 4 - LFQ_Orbitrap_DDA_Condition_B_Sample_Alpha_02: Quantitative column sample 5 - LFQ_Orbitrap_DDA_Condition_B_Sample_Alpha_03: Quantitative column sample 6 - """ - - additional_parameters = """ - Please provide all details about the used parameter for the database search. They will facilitate the comparison. - """ - - class Errors: - missing_peptide_csv = """ - Upload a peptide CSV file or select the _Use example data_ checkbox. - """ - missing_calibration_peptide_csv = """ - Upload a calibration peptide CSV file or select another _Calibration - peptides_ option. - """ - missing_calibration_column = """ - Upload a peptide CSV file with a `tr` column or select another _Calibration - peptides_ option. - """ - invalid_peptide_csv = """ - Uploaded peptide CSV file could not be read. Click on _Info about peptide - CSV formatting_ for more info on the correct input format. - """ - invalid_calibration_peptide_csv = """ - Uploaded calibration peptide CSV file could not be read. Click on _Info - about peptide CSV formatting_ for more info on the correct input format. - """ - - -if __name__ == "__main__": - StreamlitUI() diff --git a/webinterface/pages/base_pages/quant.py b/webinterface/pages/base_pages/quant.py index a6d107be..f780f420 100644 --- a/webinterface/pages/base_pages/quant.py +++ b/webinterface/pages/base_pages/quant.py @@ -79,9 +79,9 @@ def initialize_main_slider(self) -> None: if self.variables_quant.slider_id_uuid not in st.session_state.keys(): st.session_state[self.variables_quant.slider_id_uuid] = uuid.uuid4() if st.session_state[self.variables_quant.slider_id_uuid] not in st.session_state.keys(): - st.session_state[ - st.session_state[self.variables_quant.slider_id_uuid] - ] = self.variables_quant.default_val_slider + st.session_state[st.session_state[self.variables_quant.slider_id_uuid]] = ( + self.variables_quant.default_val_slider + ) def generate_main_selectbox(self) -> None: """Creates the selectbox for the Streamlit UI.""" @@ -116,9 +116,9 @@ def initialize_submitted_slider(self) -> None: if self.variables_quant.slider_id_submitted_uuid not in st.session_state.keys(): st.session_state[self.variables_quant.slider_id_submitted_uuid] = uuid.uuid4() if st.session_state[self.variables_quant.slider_id_submitted_uuid] not in st.session_state.keys(): - st.session_state[ - st.session_state[self.variables_quant.slider_id_submitted_uuid] - ] = self.variables_quant.default_val_slider + st.session_state[st.session_state[self.variables_quant.slider_id_submitted_uuid]] = ( + self.variables_quant.default_val_slider + ) def display_submitted_results(self) -> None: """Displays the results section of the page for submitted data.""" diff --git a/webinterface/pages/module_pages/__init__.py b/webinterface/pages/module_pages/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/webinterface/pages/pages_variables/Quant/lfq/ion/DIA/ion_diaPASEF.py b/webinterface/pages/pages_variables/Quant/lfq/ion/DIA/ion_diaPASEF.py index ed757c6e..adc663c2 100644 --- a/webinterface/pages/pages_variables/Quant/lfq/ion/DIA/ion_diaPASEF.py +++ b/webinterface/pages/pages_variables/Quant/lfq/ion/DIA/ion_diaPASEF.py @@ -41,7 +41,9 @@ class VariablesDIAQuantdiaPASEF: download_selector_id_uuid: str = "download_selector_id_dia_quant_diaPASEF" table_id_uuid: str = "table_id_dia_quant_diaPASEF" - additional_params_json: str = "../webinterface/configuration/dia_quant.json" # TODO: make a new file for this, and adapt the configuration file for each module. + additional_params_json: str = ( + "../webinterface/configuration/dia_quant.json" # TODO: make a new file for this, and adapt the configuration file for each module. + ) description_module_md: str = "pages/markdown_files/Quant/lfq/ion/DIA/diaPASEF/introduction.md" description_files_md: str = "pages/markdown_files/Quant/lfq/ion/DIA/diaPASEF/file_description.md" From 3eecaa03ce7a7ca5ac15a151f2beaac554c0cf81 Mon Sep 17 00:00:00 2001 From: RobbinBouwmeester Date: Thu, 19 Dec 2024 10:02:15 +0100 Subject: [PATCH 2/3] Delete 5_quant_LFQ_peptidoform_DDA.py --- .../pages/5_quant_LFQ_peptidoform_DDA.py | 131 ------------------ 1 file changed, 131 deletions(-) delete mode 100644 webinterface/pages/5_quant_LFQ_peptidoform_DDA.py diff --git a/webinterface/pages/5_quant_LFQ_peptidoform_DDA.py b/webinterface/pages/5_quant_LFQ_peptidoform_DDA.py deleted file mode 100644 index 75426e42..00000000 --- a/webinterface/pages/5_quant_LFQ_peptidoform_DDA.py +++ /dev/null @@ -1,131 +0,0 @@ -import logging -from typing import Any, Dict, Type - -import pages_dir.texts.proteobench_builder as pbb -import streamlit as st -from pages_dir.base_pages.quant import QuantUIObjects -from pages_dir.pages_variables.Quant.lfq.peptidoform.DDA.peptidoform_variables import ( - VariablesDDAQuant, -) -from pages_dir.texts.generic_texts import WebpageTexts - -from proteobench.io.parsing.parse_settings import ParseSettingsBuilder -from proteobench.modules.quant.lfq.peptidoform.DDA.quant_lfq_peptidoform_DDA import ( - DDAQuantPeptidoformModule, -) - - -class StreamlitUI: - def __init__(self): - self.variables_dda_quant: VariablesDDAQuant = VariablesDDAQuant() - self.texts: Type[WebpageTexts] = WebpageTexts - self.texts.ShortMessages.title = "DDA peptidoform quantification" - - self.user_input: Dict[str, Any] = dict() - - pbb.proteobench_page_config() - - if self.variables_dda_quant.submit not in st.session_state: - st.session_state[self.variables_dda_quant.submit] = False - try: - token = st.secrets["gh"]["token"] - except KeyError: - token = "" - - self.peptidoform_module: DDAQuantPeptidoformModule = DDAQuantPeptidoformModule(token=token) - self.parsesettingsbuilder = ParseSettingsBuilder( - parse_settings_dir=self.variables_dda_quant.parse_settings_dir, module_id=self.peptidoform_module.module_id - ) - - self.quant_uiobjects = QuantUIObjects( - self.variables_dda_quant, self.peptidoform_module, self.parsesettingsbuilder - ) - - self._main_page() - - def _main_page(self) -> None: - """ - Sets up the main page layout for the Streamlit application. - This includes the title, module descriptions, input forms, and configuration settings. - """ - # Create tabs - ( - tab_results_all, - tab_submission_details, - tab_indepth_plots, - tab_results_new, - tab_public_submission, - ) = st.tabs( - [ - "Public Benchmark Runs", - "Submit New Data", - "Results In-Depth", - "Results New Data", - "Public Submission", - ] - ) - - with tab_results_all: - st.title(self.variables_dda_quant.texts.ShortMessages.title) - st.write( - f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" - ) - if self.variables_dda_quant.beta_warning: - st.warning( - "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." - ) - self.quant_uiobjects.display_all_data_results_main() - - # Tab 2: Submission Details - with tab_submission_details: - st.title(self.variables_dda_quant.texts.ShortMessages.title) - st.write( - f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" - ) - if self.variables_dda_quant.beta_warning: - st.warning( - "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." - ) - self.quant_uiobjects.display_submission_form() - - # Tab 2.5: in-depth plots current data - with tab_indepth_plots: - st.title(self.variables_dda_quant.texts.ShortMessages.title) - st.write( - f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" - ) - if self.variables_dda_quant.beta_warning: - st.warning( - "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." - ) - self.quant_uiobjects.generate_current_data_plots(True) - - # Tab 3: Results (New Submissions) - with tab_results_new: - st.title(self.variables_dda_quant.texts.ShortMessages.title) - st.write( - f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" - ) - if self.variables_dda_quant.beta_warning: - st.warning( - "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." - ) - - self.quant_uiobjects.display_all_data_results_submitted() - - # Tab 4: Public Submission - with tab_public_submission: - st.title(self.variables_dda_quant.texts.ShortMessages.title) - st.write( - f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" - ) - if self.variables_dda_quant.beta_warning: - st.warning( - "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." - ) - self.quant_uiobjects.display_public_submission_ui() - - -if __name__ == "__main__": - logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) - StreamlitUI() # Instantiate and run the extended UI class From 4040fcea8e8bbfe7acf6a35c6fc5fc53a48122de Mon Sep 17 00:00:00 2001 From: RobbinBouwmeester Date: Thu, 19 Dec 2024 10:02:28 +0100 Subject: [PATCH 3/3] Create 5_Quant_LFQ_peptidoform_DDA.py --- .../pages/5_Quant_LFQ_peptidoform_DDA.py | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 webinterface/pages/5_Quant_LFQ_peptidoform_DDA.py diff --git a/webinterface/pages/5_Quant_LFQ_peptidoform_DDA.py b/webinterface/pages/5_Quant_LFQ_peptidoform_DDA.py new file mode 100644 index 00000000..75426e42 --- /dev/null +++ b/webinterface/pages/5_Quant_LFQ_peptidoform_DDA.py @@ -0,0 +1,131 @@ +import logging +from typing import Any, Dict, Type + +import pages_dir.texts.proteobench_builder as pbb +import streamlit as st +from pages_dir.base_pages.quant import QuantUIObjects +from pages_dir.pages_variables.Quant.lfq.peptidoform.DDA.peptidoform_variables import ( + VariablesDDAQuant, +) +from pages_dir.texts.generic_texts import WebpageTexts + +from proteobench.io.parsing.parse_settings import ParseSettingsBuilder +from proteobench.modules.quant.lfq.peptidoform.DDA.quant_lfq_peptidoform_DDA import ( + DDAQuantPeptidoformModule, +) + + +class StreamlitUI: + def __init__(self): + self.variables_dda_quant: VariablesDDAQuant = VariablesDDAQuant() + self.texts: Type[WebpageTexts] = WebpageTexts + self.texts.ShortMessages.title = "DDA peptidoform quantification" + + self.user_input: Dict[str, Any] = dict() + + pbb.proteobench_page_config() + + if self.variables_dda_quant.submit not in st.session_state: + st.session_state[self.variables_dda_quant.submit] = False + try: + token = st.secrets["gh"]["token"] + except KeyError: + token = "" + + self.peptidoform_module: DDAQuantPeptidoformModule = DDAQuantPeptidoformModule(token=token) + self.parsesettingsbuilder = ParseSettingsBuilder( + parse_settings_dir=self.variables_dda_quant.parse_settings_dir, module_id=self.peptidoform_module.module_id + ) + + self.quant_uiobjects = QuantUIObjects( + self.variables_dda_quant, self.peptidoform_module, self.parsesettingsbuilder + ) + + self._main_page() + + def _main_page(self) -> None: + """ + Sets up the main page layout for the Streamlit application. + This includes the title, module descriptions, input forms, and configuration settings. + """ + # Create tabs + ( + tab_results_all, + tab_submission_details, + tab_indepth_plots, + tab_results_new, + tab_public_submission, + ) = st.tabs( + [ + "Public Benchmark Runs", + "Submit New Data", + "Results In-Depth", + "Results New Data", + "Public Submission", + ] + ) + + with tab_results_all: + st.title(self.variables_dda_quant.texts.ShortMessages.title) + st.write( + f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" + ) + if self.variables_dda_quant.beta_warning: + st.warning( + "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." + ) + self.quant_uiobjects.display_all_data_results_main() + + # Tab 2: Submission Details + with tab_submission_details: + st.title(self.variables_dda_quant.texts.ShortMessages.title) + st.write( + f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" + ) + if self.variables_dda_quant.beta_warning: + st.warning( + "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." + ) + self.quant_uiobjects.display_submission_form() + + # Tab 2.5: in-depth plots current data + with tab_indepth_plots: + st.title(self.variables_dda_quant.texts.ShortMessages.title) + st.write( + f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" + ) + if self.variables_dda_quant.beta_warning: + st.warning( + "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." + ) + self.quant_uiobjects.generate_current_data_plots(True) + + # Tab 3: Results (New Submissions) + with tab_results_new: + st.title(self.variables_dda_quant.texts.ShortMessages.title) + st.write( + f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" + ) + if self.variables_dda_quant.beta_warning: + st.warning( + "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." + ) + + self.quant_uiobjects.display_all_data_results_submitted() + + # Tab 4: Public Submission + with tab_public_submission: + st.title(self.variables_dda_quant.texts.ShortMessages.title) + st.write( + f"The full description of the module is available [here]({self.variables_dda_quant.texts.ShortMessages.doc_url})" + ) + if self.variables_dda_quant.beta_warning: + st.warning( + "This module is in BETA phase. The figure presented below and the metrics calculation may change in the near future." + ) + self.quant_uiobjects.display_public_submission_ui() + + +if __name__ == "__main__": + logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) + StreamlitUI() # Instantiate and run the extended UI class