diff --git a/tools/gem_tools/.shed.yml b/tools/gem_tools/.shed.yml deleted file mode 100644 index 0714df47958..00000000000 --- a/tools/gem_tools/.shed.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: gem_tools -owner: AlmaasLab -homepage_url: https://github.com/AlmaasLab/elixir-galaxy-tools-systemsbiology -remote_repository_url: https://github.com/AlmaasLab/elixir-galaxy-tools-systemsbiology -type: unrestricted -description: Tools for analyzing genome-scale metabolic models (GEMs) using COBRApy and related libraries. -long_description: | - This repository contains a collection of Galaxy tools for performing various analyses on genome-scale metabolic models (GEMs). The tools leverage COBRApy and other Python libraries to provide functionalities such as phenotype phase plane analysis, gene knockout analysis, flux variability analysis, and more. -categories: - - Metabolomics - - Systems Biology - - Flux Balance Analysis -license: GNU GENERAL PUBLIC LICENSE \ No newline at end of file diff --git a/tools/gem_tools/gem_check_memote.xml b/tools/gem_tools/gem_check_memote.xml index fa479108a17..e2716b8efab 100644 --- a/tools/gem_tools/gem_check_memote.xml +++ b/tools/gem_tools/gem_check_memote.xml @@ -1,8 +1,8 @@ + Uses the Memote test suite to generate a quality report on a genome-scale metabolic model. See more at https://memote.readthedocs.io/en/latest/index.html gem_macros.xml - Uses the Memote test suite to generate a quality report on a genome-scale metabolic model. See more at https://memote.readthedocs.io/en/latest/index.html memote pytest @@ -42,29 +42,24 @@ The GEM Check Memote tool runs the Memote test suite to generate a detailed report on the quality of a genome-scale metabolic model (GEM). Memote assesses various model characteristics such as stoichiometric consistency and model annotations. Inputs - ------ `Model to check with memote`: The metabolic model in SBML format (.xml or .sbml) to be analyzed by Memote. Ensure the file conforms to SBML standards. Outputs - ------- `Memote report`: An HTML file that contains the full results of the Memote assessment. This report includes overall model quality scores and highlights any issues that need correction. Usage Example - ------------- 1. Upload your SBML model file. 2. Run the tool to generate the Memote report. 3. Review the report to identify any errors or areas for improvement in the model. Troubleshooting - --------------- If the tool fails to run, ensure that your input file is a valid SBML model. Incorrect file formats or non-compliant models may trigger errors. References - ---------- Full documentation and further examples can be found at: https://memote.readthedocs.io/en/latest/index.html ]]> diff --git a/tools/gem_tools/gem_escher_visualization.py b/tools/gem_tools/gem_escher_visualization.py index 061120e06cc..f209a4079e2 100644 --- a/tools/gem_tools/gem_escher_visualization.py +++ b/tools/gem_tools/gem_escher_visualization.py @@ -1,7 +1,8 @@ import argparse + import cobra -from escher import Builder import pandas as pd +from escher import Builder def __main__(): diff --git a/tools/gem_tools/gem_escher_visualization.xml b/tools/gem_tools/gem_escher_visualization.xml index f54df8821be..8e44467b373 100644 --- a/tools/gem_tools/gem_escher_visualization.xml +++ b/tools/gem_tools/gem_escher_visualization.xml @@ -1,14 +1,15 @@ + Visualize the flux distribution of a GEM gem_macros.xml - Visualize the flux distribution of a GEM escher pyparsing + python '$__tool_directory__/gem_escher_visualization.py' '-output' '${output}' @@ -82,7 +83,6 @@ - @@ -94,6 +94,11 @@ + + + + + @@ -101,29 +106,16 @@ Escher Visualization Tool Overview - -------- This tool generates an interactive HTML visualization of metabolic flux distributions in a Genome-scale Metabolic Model (GEM) using Escher. Inputs - ------ - - 1. Model File (Required): - * Upload a COBRA-compatible metabolic model file - * Supported formats include SBML (.xml) and JSON (.json) - - 2. Flux Distribution (Optional): - * Either upload a pre-calculated flux distribution - * Or let the tool calculate optimal flux distribution through FBA - * If calculating, you can optionally provide custom uptake constraints - 3. Map Selection: - * Choose from pre-loaded maps for common metabolic models - * Upload your own Escher map - * Create a new map from scratch + * Model File (Required): COBRA-compatible metabolic model file + * Flux Distribution (Optional): a pre-calculated flux distribution + * Map Selection (Optional): maps for common metabolic models Output - ------ The tool generates an interactive HTML file that: * Displays metabolic pathways with reaction fluxes @@ -132,7 +124,6 @@ * Provides options for customizing the visualization Tips - ---- * Ensure your model is properly formatted and constrained * For large models, consider visualizing specific subsystems diff --git a/tools/gem_tools/gem_extract_exchange.py b/tools/gem_tools/gem_extract_exchange.py index 0f66720e911..7a029bc27a9 100644 --- a/tools/gem_tools/gem_extract_exchange.py +++ b/tools/gem_tools/gem_extract_exchange.py @@ -1,4 +1,5 @@ import argparse + import cobra @@ -11,12 +12,13 @@ def get_exchange_reactions_info(model): exchange_reactions = model.exchanges exchange_reactions_info = [] for reaction in exchange_reactions: - exchange_reactions_info.append([ - reaction.id, - reaction.name, - reaction.reaction, - reaction.lower_bound, - reaction.upper_bound + exchange_reactions_info.append( + [ + reaction.id, + reaction.name, + reaction.reaction, + reaction.lower_bound, + reaction.upper_bound ]) txt_object = ( "reaction_id;reaction_name;reaction_stoichiometry;" diff --git a/tools/gem_tools/gem_extract_exchange.xml b/tools/gem_tools/gem_extract_exchange.xml index dbe9de454a7..c01a641de81 100644 --- a/tools/gem_tools/gem_extract_exchange.xml +++ b/tools/gem_tools/gem_extract_exchange.xml @@ -1,8 +1,8 @@ + Extract the exchange reactions and bounds of a GEM gem_macros.xml - Extract the exchange reactions and bounds of a GEM @@ -35,17 +35,14 @@ python '$__tool_directory__/gem_extract_exchange.py' '--cb_model_location' '${cb GEM Extract Exchange Bounds Overview - -------- This tool extracts the exchange reactions and their associated bounds from a Genome-scale Metabolic (GEM) model in SBML format. The extracted exchange reactions are saved in a CSV file for further analysis or modification. Exchange reactions represent interactions between the metabolic network and the external environment, often used to simulate fluxes of metabolites in and out of the system. Inputs - ------ - `Model to extract exchange for`: This should be an SBML file containing the GEM model. The tool will identify and extract only the exchange reactions (reactions responsible for importing/exporting metabolites). Outputs - ------- - `GEM exchange reactions`: A CSV file with the following columns: - `reaction_id`: The ID of the exchange reaction. diff --git a/tools/gem_tools/gem_flux_distribution.py b/tools/gem_tools/gem_flux_distribution.py index e61106274d3..8a39d9bb8a1 100644 --- a/tools/gem_tools/gem_flux_distribution.py +++ b/tools/gem_tools/gem_flux_distribution.py @@ -1,4 +1,5 @@ import argparse + import cobra import pandas as pd @@ -46,9 +47,9 @@ def __main__(): cb_model = cobra.io.read_sbml_model(args.cb_model_location) except Exception as e: raise Exception( - "The model could not be read. Ensure " - "it is in correct SBML format." - ) from e + "The model could not be read. Ensure " + "it is in correct SBML format." + ) from e if args.uptake_constraints_file is not None\ and args.uptake_constraints_file != "None": @@ -57,14 +58,14 @@ def __main__(): sep=";", header=0, index_col=False - ) - for index, row in constraints_df.iterrows(): + ) + for _, row in constraints_df.iterrows(): cb_model.reactions.get_by_id( row["reaction_id"] - ).lower_bound = row["lower_bound"] + ).lower_bound = row["lower_bound"] cb_model.reactions.get_by_id( row["reaction_id"] - ).upper_bound = row["upper_bound"] + ).upper_bound = row["upper_bound"] # do pFBA solution = cobra.flux_analysis.pfba(cb_model) @@ -73,7 +74,7 @@ def __main__(): # reaction ids, and flux distribution flux_distribution = pd.DataFrame( columns=["reaction_name", "reaction_id", "flux"] - ) + ) flux_distribution["reaction_name"] = \ [reaction.name for reaction in cb_model.reactions] diff --git a/tools/gem_tools/gem_flux_distribution.xml b/tools/gem_tools/gem_flux_distribution.xml index d8e0ca2af0c..fb930bb6a27 100644 --- a/tools/gem_tools/gem_flux_distribution.xml +++ b/tools/gem_tools/gem_flux_distribution.xml @@ -1,8 +1,8 @@ + Calculate the optimal flux distribution of a GEM gem_macros.xml - Calculate the optimal flux distribution of a GEM @@ -26,6 +26,11 @@ + + + + + @@ -42,7 +47,6 @@ This tool performs Flux Balance Analysis (FBA) to calculate the optimal flux distribution of a Genome-scale Metabolic Model (GEM). What it does - ----------- * Reads a SBML-formatted metabolic model * Applies user-specified uptake constraints @@ -50,20 +54,11 @@ * Outputs the results in CSV format Input files - ----------- - - 1. **Model file** (required): - * Must be in SBML format (.xml) - * Should contain a valid genome-scale metabolic model - * Must be compatible with COBRApy - 2. **Uptake constraints file** (optional): - * CSV format - * Contains exchange reaction constraints - * Format: reaction_id,lower_bound,upper_bound + *Model file** (required): Must be in SBML format (.xml), compatible with COBRApy + *Uptake constraints file* (optional): CSV format Output - ------ The tool generates a CSV file containing: * Reaction IDs @@ -71,7 +66,6 @@ * Optimal flux distribution based on the model's objective function Common Issues - ------------ If the tool fails, check: * Is your SBML model valid? diff --git a/tools/gem_tools/gem_flux_variability_analysis.py b/tools/gem_tools/gem_flux_variability_analysis.py index 3752a9d9015..d6474387bce 100644 --- a/tools/gem_tools/gem_flux_variability_analysis.py +++ b/tools/gem_tools/gem_flux_variability_analysis.py @@ -1,4 +1,5 @@ import argparse + import cobra import pandas as pd @@ -77,7 +78,7 @@ def __main__(): except FileNotFoundError: raise FileNotFoundError( f"Constraints file not found: {args.uptake_constraints_file}" - ) + ) except pd.errors.EmptyDataError: raise ValueError("Constraints file is empty") except Exception as e: @@ -106,12 +107,12 @@ def __main__(): fva_result["reaction_id"] = fva_result.index fva_result["reaction_name"] = fva_result["reaction_id"].apply( lambda x: cb_model.reactions.get_by_id(x).name - ) + ) # reorder the columns fva_result = fva_result[[ "reaction_id", "reaction_name", "minimum", "maximum" - ]] + ]] fva_result.to_csv(args.out_file, sep=";", index=False, header=True) diff --git a/tools/gem_tools/gem_flux_variability_analysis.xml b/tools/gem_tools/gem_flux_variability_analysis.xml index 8c49399a87d..cc9c6cabc1c 100644 --- a/tools/gem_tools/gem_flux_variability_analysis.xml +++ b/tools/gem_tools/gem_flux_variability_analysis.xml @@ -30,11 +30,21 @@ + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -73,7 +88,7 @@ - + @@ -83,7 +98,6 @@ This tool performs single or double gene knockout analysis on a Genome-scale Metabolic Model (GEM) using Flux Balance Analysis (FBA). Input Parameters - -------------- **Model File**: A GEM in SBML format (.xml) that will be analyzed. @@ -96,7 +110,7 @@ **Uptake Constraints File** (optional): A CSV file specifying constraints for exchange reactions. Output - ------ + The tool generates a CSV file containing: - Reaction IDs - Knocked out gene(s) @@ -105,7 +119,7 @@ - Knockout flux values Common Issues - ------------ + - Ensure your model is well-formatted - Verify that specified genes exist in the model - Large models may require significant computation time, especially for double knockouts diff --git a/tools/gem_tools/gem_phenotype_phase_plane.py b/tools/gem_tools/gem_phenotype_phase_plane.py index 0b3009abf68..e4f817e1025 100644 --- a/tools/gem_tools/gem_phenotype_phase_plane.py +++ b/tools/gem_tools/gem_phenotype_phase_plane.py @@ -1,4 +1,5 @@ import argparse + import cobra import pandas as pd @@ -96,8 +97,8 @@ def __main__(): ) from e # set the uptake constraints if provided - if (args.uptake_constraints_file is not None and - args.uptake_constraints_file != "None"): + if (args.uptake_constraints_file is not None + and args.uptake_constraints_file != "None"): constraints_df = pd.read_csv( args.uptake_constraints_file, sep=";", diff --git a/tools/gem_tools/gem_phenotype_phase_plane.xml b/tools/gem_tools/gem_phenotype_phase_plane.xml index 4c0136a28f5..cf936a15aa2 100644 --- a/tools/gem_tools/gem_phenotype_phase_plane.xml +++ b/tools/gem_tools/gem_phenotype_phase_plane.xml @@ -1,11 +1,11 @@ - - gem_macros.xml - Form a production envelope for the model with the given reactions. This sequentially constraints the fluxes of the given reactions and calculates the value of the objective for the given constraints. It returns a CSV file. + + gem_macros.xml + @@ -42,7 +42,11 @@ - + + + + + @@ -51,7 +55,11 @@ - + + + + + @@ -61,7 +69,7 @@ This tool performs a Phenotype Phase Plane (PhPP) analysis on a Genome-scale Metabolic Model (GEM). The PhPP analysis helps visualize how different combinations of two reaction fluxes affect the model's objective function (typically growth rate or product formation). Input Parameters - --------------- + * **Model file**: A GEM in SBML format (.xml) * **First reaction**: The ID of the first reaction to vary (e.g., "EX_glc__D_e" for glucose exchange) * **Second reaction**: The ID of the second reaction to vary (e.g., "EX_o2_e" for oxygen exchange) @@ -70,14 +78,14 @@ * **Uptake constraints**: (Optional) CSV file containing additional flux constraints Output - ------ + The tool produces a CSV file containing: * Values for the first reaction flux * Values for the second reaction flux * Corresponding objective function values Common Issues - ------------ + * Ensure reaction IDs exactly match those in your model * Verify that your model is properly constrained * Check that the reactions you selected can carry flux diff --git a/tools/gem_tools/test-data/test_output_1.csv b/tools/gem_tools/test-data/test_output_1.csv deleted file mode 100644 index a61fab3f3e3..00000000000 --- a/tools/gem_tools/test-data/test_output_1.csv +++ /dev/null @@ -1,10 +0,0 @@ -carbon_source;flux_minimum;carbon_yield_minimum;mass_yield_minimum;flux_maximum;carbon_yield_maximum;mass_yield_maximum;EX_glc__D_e;EX_o2_e -EX_glc__D_e;0.0;0.0;;0.0;9.924154013993375e-15;;-10.0;-60.00000000000002 -EX_glc__D_e;0.0;0.0;;0.686316675665041;12.445474427840669;;-10.0;-30.00000000000001 -EX_glc__D_e;0.0;0.0;;0.21166294973531066;3.8382366648741977;;-10.0;0.0 -EX_glc__D_e;;;;;;;-5.239714285714287;-60.00000000000002 -EX_glc__D_e;0.0;0.0;;0.032903982336170715;1.1387483554129063;;-5.239714285714287;-30.00000000000001 -EX_glc__D_e;0.0;0.0;;0.06666900318174801;2.3072957234959626;;-5.239714285714287;0.0 -EX_glc__D_e;;;;;;;-0.4794285714285742;-60.00000000000002 -EX_glc__D_e;;;;;;;-0.4794285714285742;-30.00000000000001 -EX_glc__D_e;;;;;;;-0.4794285714285742;0.0 diff --git a/tools/gem_tools/test-data/test_output_2.csv b/tools/gem_tools/test-data/test_output_2.csv deleted file mode 100644 index a61fab3f3e3..00000000000 --- a/tools/gem_tools/test-data/test_output_2.csv +++ /dev/null @@ -1,10 +0,0 @@ -carbon_source;flux_minimum;carbon_yield_minimum;mass_yield_minimum;flux_maximum;carbon_yield_maximum;mass_yield_maximum;EX_glc__D_e;EX_o2_e -EX_glc__D_e;0.0;0.0;;0.0;9.924154013993375e-15;;-10.0;-60.00000000000002 -EX_glc__D_e;0.0;0.0;;0.686316675665041;12.445474427840669;;-10.0;-30.00000000000001 -EX_glc__D_e;0.0;0.0;;0.21166294973531066;3.8382366648741977;;-10.0;0.0 -EX_glc__D_e;;;;;;;-5.239714285714287;-60.00000000000002 -EX_glc__D_e;0.0;0.0;;0.032903982336170715;1.1387483554129063;;-5.239714285714287;-30.00000000000001 -EX_glc__D_e;0.0;0.0;;0.06666900318174801;2.3072957234959626;;-5.239714285714287;0.0 -EX_glc__D_e;;;;;;;-0.4794285714285742;-60.00000000000002 -EX_glc__D_e;;;;;;;-0.4794285714285742;-30.00000000000001 -EX_glc__D_e;;;;;;;-0.4794285714285742;0.0