diff --git a/.gitignore b/.gitignore index 7126ece..6e705ac 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,7 @@ venv.bak/ /site # mypy -.mypy_cache/ \ No newline at end of file +.mypy_cache/ + +# Visual Studio Code configuration folders +.vscode diff --git a/autopacmen/compare_gecko_and_gecko_analogon.py b/autopacmen/compare_gecko_and_gecko_analogon.py index 2da5c2a..c7e12f4 100644 --- a/autopacmen/compare_gecko_and_gecko_analogon.py +++ b/autopacmen/compare_gecko_and_gecko_analogon.py @@ -1,6 +1,22 @@ +#!/usr/bin/env python3 +# +# Copyright 2019-2020 PSB +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import cobra -gecko = cobra.io.read_sbml_model("ec_model_2019_06_25_output/iJO1366_sMOMENT_2019_06_25_GECKO.xml") +gecko = cobra.io.read_sbml_model("ec_model_2019_06_25_output/iJO1366_2019_06_25_GECKO.xml") analogon = cobra.io.read_sbml_model("ec_model_2019_06_25_output/iJO1366_sMOMENT_2019_06_25_GECKO_ANALOGON.xml") gecko_reactions_with_arm = [] @@ -22,7 +38,13 @@ gecko_reactions_with_arm = set(gecko_reactions_with_arm) analogon_reactions_with_arm = set(analogon_reactions_with_arm) -print(len(gecko_reactions_with_arm)) -print(len(analogon_reactions_with_arm)) +print("===STRUCTURAL COMPARISON OF ORIGINAL GECKO AND SMOMENT-BASED GECKO-ANALOGOUS MODEL===") +print("Number of arm reactions - original GECKO:", len(gecko_reactions_with_arm)) +print("Number of arm reactions - sMOMENT GECKO analogon:", len(analogon_reactions_with_arm)) difference = analogon_reactions_with_arm - gecko_reactions_with_arm -print("A") +print("---") +print("Number of reactions - original GECKO: ", len(gecko.reactions)) +print("Number of reactions - sMOMENT GECKO analogon: ", len(analogon.reactions)) +print("---") +print("Number of metabolites - original GECKO: ", len(gecko.metabolites)) +print("Number of metabolites - sMOMENT GECKO analogon: ", len(analogon.metabolites)) diff --git a/autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py b/autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py index 725965b..bb6bf98 100644 --- a/autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py +++ b/autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ This is the script for the generation of the comparative cumulative distributions of flux variabilities of iJO1366 vs. iJO1366* at a given maximal glucose uptake -rate. The box-form in the legends was edited later to lines for optimal reasons (no +rate. The box-form in the legends was edited later to lines for aesthetic reasons (no actual data was changed :-). """ diff --git a/autopacmen/ec_model_2019_06_25_sMOMENT_iJO_CREATION.py b/autopacmen/ec_model_2019_06_25_sMOMENT_iJO_CREATION.py index 7ba56ba..56279ec 100644 --- a/autopacmen/ec_model_2019_06_25_sMOMENT_iJO_CREATION.py +++ b/autopacmen/ec_model_2019_06_25_sMOMENT_iJO_CREATION.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ # limitations under the License. """This script consists of all steps needed for the genration of iJO1366-sMOMENT. -The single steps are explained in the supplementary file 1 of sMOMENT's publication. +The single steps are explained in the supplementary file 1 of sMOMENT's publication (Bekiaris & Klamt, 2020). """ # IMPORTS diff --git a/autopacmen/submodules/create_smoment_model_reaction_wise.py b/autopacmen/submodules/create_smoment_model_reaction_wise.py index a8c128f..f981f17 100644 --- a/autopacmen/submodules/create_smoment_model_reaction_wise.py +++ b/autopacmen/submodules/create_smoment_model_reaction_wise.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -166,7 +166,7 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str continue # Check if all proteins in the reaction's gene rule have a found mass - # This is not the case for e.g. spontaneous reactions whcih often get the pseudo-enzyme 's0001' + # This is not the case for e.g. spontaneous reactions which often get the pseudo-enzyme 's0001' all_available = True for enzyme in gene_rule: if type(enzyme) == str: @@ -212,7 +212,8 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str reaction_kcat = forward_kcat # Add protein pool pseudo-metabolite depending on isozyme complex presence - stoichiometries = [] + stoichiometries: List[float] = [] + stoichiometry_enzyme_name_list: List[str] = [] for isozyme_id in gene_rule: # If it's not a complex :O... if type(isozyme_id) is str: @@ -230,6 +231,7 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str # 3) Setting the right direction (educt) stoichiometry *= -1 stoichiometries.append(stoichiometry) + stoichiometry_enzyme_name_list.append(isozyme_id) # Add proteomics constraints if isozyme_id in protein_id_concentration_mapping.keys(): @@ -245,6 +247,7 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str stoichiometry = 0 # ...go through each single ID of the complex... + stoichiometry_enzyme_name_list.append("") for single_id in isozyme_id: # ...get the reaction ID without additions... reaction_id = reaction_id.split("_TG_")[0] @@ -260,6 +263,9 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str single_stoichiometry *= -1 # 4) and add it to the complex's stoichiometry stoichiometry += single_stoichiometry + # Add name of current single ID + stoichiometry_enzyme_name_list[-1] += single_id + " " + stoichiometry_enzyme_name_list[-1] = stoichiometry_enzyme_name_list[-1].rstrip() # Add to list of stoichiometries stoichiometries.append(stoichiometry) @@ -275,8 +281,20 @@ def create_smoment_model_reaction_wise(model: cobra.Model, output_sbml_name: str # Take the maximal stoichiometry (i.e., the one with the least cost since this one will usually be prefered # anyway in an FBA). metabolites = {} - metabolites[prot_pool_metabolite] = max(stoichiometries) + max_stoichiometry = max(stoichiometries) + metabolites[prot_pool_metabolite] = max_stoichiometry reaction.add_metabolites(metabolites) + selected_enzyme = stoichiometry_enzyme_name_list[stoichiometries.index(max_stoichiometry)] + print("Reaction: ", model_reaction_id) + print("Selected kcat: ", reaction_kcat) + print("Selected molecular weight: ", end="") + if " " in selected_enzyme: # Multiple enzymes + mass_sum = .0 + for single_enzyme in selected_enzyme.split(" "): + mass_sum += protein_id_mass_mapping[single_enzyme] + print(mass_sum) + else: # Single enzyme + print(protein_id_mass_mapping[selected_enzyme]) # Output as SBML (without constraints due to cobrapy limitations) cobra.io.write_sbml_model(model, project_folder + output_sbml_name) diff --git a/autopacmen/submodules/get_differential_reactions.py b/autopacmen/submodules/get_differential_reactions.py index b5db81d..6c1ea76 100644 --- a/autopacmen/submodules/get_differential_reactions.py +++ b/autopacmen/submodules/get_differential_reactions.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -77,9 +77,9 @@ def get_differential_reactions(scenario_names: List[str], flux_control_files_pat Definition of 'differential reaction' ---------- - In a protein-constraint-enhanced metabolic network, the deletion of the constrain constraint in a reaction + In a protein-constraint-enhanced metabolic network, the deletion of the protein constraint in a reaction can have an influence on the objective solution value, or not. A 'differential reaction' is a reaction in - which the constraint deletion has an influence over the given threshold. I.e., if the original objective solution + which the constraint's deletion has an influence over the given threshold. I.e., if the original objective solution is 1.0 and - after the deletion of the protein constraint for the reaction - again 1.0, the reaction is not differential. If the deletion of the protein constraint leads e.g. to the solution 1.001 or .999, and the threshold is smaller or equal to .001, the reaction is 'differential'. @@ -96,8 +96,10 @@ def get_differential_reactions(scenario_names: List[str], flux_control_files_pat Output ---------- 2 values: - * unique_differential_proteins_of_scenario: Dict[str, List[str]] ~ - * differential_proteins_of_all_scenarios: List[str] ~ A list of all differential + * unique_differential_proteins_of_scenario: Dict[str, List[str]] ~ A list of all differential + reactions which occur in *only one* given scenario. + * differential_reactions_of_all_scenarios: List[str] ~ A list of all differential reactions which + occur in *all* given scenarios. """ # Get the differential reactions of each single scenario differential_reactions_by_scenario: Dict[str, List[str]] = {} diff --git a/autopacmen/submodules/get_reactions_kcat_mapping.py b/autopacmen/submodules/get_reactions_kcat_mapping.py index 729d0ee..6acad0f 100644 --- a/autopacmen/submodules/get_reactions_kcat_mapping.py +++ b/autopacmen/submodules/get_reactions_kcat_mapping.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -308,7 +308,7 @@ def _print_assigned_kcats(reaction_id: str, forward_kcat: float, reverse_kcat: f # PUBLIC FUNCTIONS def get_reactions_kcat_mapping(sbml_path: str, project_folder: str, project_name: str, organism: str, kcat_database_path: str, protein_kcat_database_path: str, - type_of_kcat_selection: str) -> None: + type_of_kcat_selection: str = "mean") -> None: """Returns a reaction<->kcat mapping for the given model :D The selection of kcats is depending on the affected metabolites of the reaction direction (one diff --git a/autopacmen/submodules/reaction_flux_control_by_scenario.py b/autopacmen/submodules/reaction_flux_control_by_scenario.py index b87ee49..0dd8e4f 100644 --- a/autopacmen/submodules/reaction_flux_control_by_scenario.py +++ b/autopacmen/submodules/reaction_flux_control_by_scenario.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019 PSB +# Copyright 2019-2020 PSB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ # PRIVATE FUNCTIONS def _reaction_flux_control(model: cobra.Model, output_folder: str, project_name: str, scenario_key: str, objective: str): - """Calculated the reaction flux control for the given model. + """Calculate the reaction flux control for the given model. Arguments ---------- @@ -112,7 +112,7 @@ def reaction_flux_control_by_scenario(model: cobra.Model, output_folder: str, pr Output ---------- - Rection flux control files in the given folder (see _reaction_flux_control()'s comment for more) + Reaction flux control files in the given folder (see _reaction_flux_control()'s comment for more) """ # Standardize output folder output_folder = standardize_folder(output_folder) diff --git a/generate_source_code_docs.bat b/generate_source_code_docs.bat new file mode 100644 index 0000000..256fc5a --- /dev/null +++ b/generate_source_code_docs.bat @@ -0,0 +1,5 @@ +REM This Windows script generates AutoPACMEN's source code documentation +REM In order to run this script, you have to install pdoc3 first +REM and you have to remove all active Python scripts (such as all +REM beggining with "ec_model_") +pdoc3 --force --output-dir "./autopacmen/html/" "autopacmen" diff --git a/generate_source_code_docs.sh b/generate_source_code_docs.sh new file mode 100755 index 0000000..4481526 --- /dev/null +++ b/generate_source_code_docs.sh @@ -0,0 +1,5 @@ +# This Unix script generates AutoPACMEN's source code documentation +# In order to run this script, you have to install pdoc3 first +# and you have to remove all active Python scripts (such as all +# beggining with "ec_model_") +pdoc3 --force --output-dir "./autopacmen/html/" "autopacmen" diff --git a/setup.py b/setup.py index c46f61f..f610337 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="autopacmen-Paulocracy", - version="0.5.3", + version="0.5.4", author="Paulocracy", author_email="bekiaris@mpi-magdeburg.mpg.de", description="The AutoPACMEN package",