Skip to content

Commit

Permalink
Changes for 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulocracy committed Jul 23, 2020
1 parent aebd131 commit 8649bfd
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 24 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,7 @@ venv.bak/
/site

# mypy
.mypy_cache/
.mypy_cache/

# Visual Studio Code configuration folders
.vscode
30 changes: 26 additions & 4 deletions autopacmen/compare_gecko_and_gecko_analogon.py
Original file line number Diff line number Diff line change
@@ -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 = []
Expand All @@ -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))
4 changes: 2 additions & 2 deletions autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 :-).
"""

Expand Down
4 changes: 2 additions & 2 deletions autopacmen/ec_model_2019_06_25_sMOMENT_iJO_CREATION.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
26 changes: 22 additions & 4 deletions autopacmen/submodules/create_smoment_model_reaction_wise.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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():
Expand All @@ -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]
Expand All @@ -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)

Expand All @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions autopacmen/submodules/get_differential_reactions.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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'.
Expand All @@ -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]] = {}
Expand Down
4 changes: 2 additions & 2 deletions autopacmen/submodules/get_reactions_kcat_mapping.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions autopacmen/submodules/reaction_flux_control_by_scenario.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions generate_source_code_docs.bat
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions generate_source_code_docs.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="autopacmen-Paulocracy",
version="0.5.3",
version="0.5.4",
author="Paulocracy",
author_email="[email protected]",
description="The AutoPACMEN package",
Expand Down

0 comments on commit 8649bfd

Please sign in to comment.