Skip to content

Commit

Permalink
Chane internal module referencing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulocracy committed Oct 27, 2020
1 parent eaee335 commit 9431228
Show file tree
Hide file tree
Showing 48 changed files with 288 additions and 180 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ An HTML documentation of the source code of AutoPACMEN's Python modules can be f
This HTML documentation was automatically generated using [pdoc3](https://pdoc3.github.io/pdoc/) (link accessed on Oct 30, 2019).
The HTML documentation's starting point is "index.html" in the "./html/autopacmen" subfolder.

In addition, the exemplary usage of AutoPACMEN with iJO1366* is explained in AutoPACMEN's publication Supplementary File 1.
All scripts starting with "ec_model_2019_06_25" show the exemplary usage of AutoPACMEN for the generation of iJO1366*. All these scripts are intended to be run from the "autopacmen" subfolder of this repository. AutoPACMEN's exemplary usage is explained in AutoPACMEN's publication Supplementary File 1.

<b>Note:</b> As it has a huge file size, the downloaded complete BRENDA text file brenda_downloads.txt (as described in
AutoPACMEN's manual) is not included here.
Expand Down
11 changes: 7 additions & 4 deletions autopacmen/analysis_fva_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
# External module for command-line interfaces
import click
# Internal module, contains the actual FBA comparison function
from submodules.fva_comparison import fva_comparison_with_sbml
from .submodules.fva_comparison import fva_comparison_with_sbml


# Set-up command-line parameters using click decorators
@click.command()
@click.option("--sbml_original_path",
required=True,
type=click.Path(exists=True, file_okay=True, dir_okay=True, readable=True),
type=click.Path(exists=True, file_okay=True,
dir_okay=True, readable=True),
prompt="Original SBML path",
help="Full SBML path of original model without protein allocation constraints")
@click.option("--sbml_protein_constrained_path",
required=True,
type=click.Path(exists=True, file_okay=True, dir_okay=True, readable=True),
type=click.Path(exists=True, file_okay=True,
dir_okay=True, readable=True),
prompt="SBML path of sMOMENT-enhanced model",
help="Full SBML path of sMOMENT-enhanced model.")
@click.option("--objective",
Expand All @@ -55,7 +57,8 @@ def fba_comparison_cli(sbml_original_path: str, sbml_protein_constrained_path: s
Example: Print a comparative FVA for the non-constrained model 'C:\\original.xml' and the sMOMENT-model 'C:\\pac.xml' and the objective 'ACALD':
python analysis_fva_comparison.py --sbml_original_path C:\\original.xml --sbml_protein_constrained_path C:\\pac.xml --objective ACALD
"""
fva_comparison_with_sbml(sbml_original_path, sbml_protein_constrained_path, objective)
fva_comparison_with_sbml(
sbml_original_path, sbml_protein_constrained_path, objective)


# Start-up routine if script is called
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/analysis_fva_prot_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import click
from typing import List
# Internal modules
from submodules.fva_prot_pool import fva_prot_pool_with_sbml
from .submodules.fva_prot_pool import fva_prot_pool_with_sbml


# Set-up command-line parameters using click decorators
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/data_create_combined_kcat_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# External modules
import click
# Internal modules
from submodules.create_combined_kcat_database import create_combined_kcat_database
from .submodules.create_combined_kcat_database import create_combined_kcat_database


# Set-up command-line parameters using click decorators
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/data_parse_bigg_metabolites_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# External modules
import click
# Internal modules
from submodules.parse_bigg_metabolites_file import parse_bigg_metabolites_file
from .submodules.parse_bigg_metabolites_file import parse_bigg_metabolites_file


# Set-up command-line parameters using click decorators
Expand Down
8 changes: 5 additions & 3 deletions autopacmen/data_parse_brenda_json_for_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@
# External modules
import click
# Internal modules
from submodules.parse_brenda_json_for_model import parse_brenda_json_for_model
from .submodules.parse_brenda_json_for_model import parse_brenda_json_for_model


# Set-up command-line parameters using click decorators
@click.command()
@click.option("--sbml_path",
required=True,
type=click.Path(exists=True, file_okay=True, dir_okay=True, readable=True),
type=click.Path(exists=True, file_okay=True,
dir_okay=True, readable=True),
prompt="Path to SBML model",
help="Full path to the SBML with the model of which the BRENDA JSON will be derived.")
@click.option("--brenda_json_path",
required=True,
type=click.Path(exists=True, file_okay=True, dir_okay=True, readable=True),
type=click.Path(exists=True, file_okay=True,
dir_okay=True, readable=True),
prompt="BRENDA JSON path",
help="Full path to the BRENDA JSON created with data_parse_brenda_textfile.py")
@click.option("--json_output_path",
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/data_parse_brenda_textfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# External modules
import click
# Internal modules
from submodules.parse_brenda_textfile import parse_brenda_textfile
from .submodules.parse_brenda_textfile import parse_brenda_textfile


# Set-up command-line parameters using click decorators
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/data_parse_sabio_rk_for_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# External modules
import click
# Internal modules
from submodules.parse_sabio_rk_for_model import parse_sabio_rk_for_model_with_sbml
from .submodules.parse_sabio_rk_for_model import parse_sabio_rk_for_model_with_sbml

# Set-up command-line parameters using click decorators
@click.command()
Expand Down
Binary file modified autopacmen/docs/manual.odt
Binary file not shown.
Binary file modified autopacmen/docs/manual.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
# External modules
import cobra
# Internal modules
from ec_model_data_scenarios_for_optimization import ec_model_scenarios_for_optimization
from ec_model_data_set_up_model import set_up_ec_model_with_sbml
from submodules.reaction_flux_control_by_scenario import reaction_flux_control_by_scenario
from submodules.get_differential_reactions import get_differential_reactions
from submodules.helper_general import json_write
from .ec_model_2019_06_25_data_scenarios_for_optimization import ec_model_scenarios_for_optimization
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml
from .submodules.reaction_flux_control_by_scenario import reaction_flux_control_by_scenario
from .submodules.get_differential_reactions import get_differential_reactions
from .submodules.helper_general import json_write


# Set-up of project
Expand Down
4 changes: 2 additions & 2 deletions autopacmen/ec_model_2019_06_25_analysis_fva_prot_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"""

from submodules.fva_prot_pool import fva_prot_pool
from ec_model_data_set_up_model import set_up_ec_model_with_sbml
from .submodules.fva_prot_pool import fva_prot_pool
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml

model = set_up_ec_model_with_sbml("ec_model_output/iJO1366_GECKO.xml", .225)
model.reactions.EX_glc__D_e.lower_bound = -1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@

import cobra

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 = 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 = []
for reaction in gecko.reactions:
if "for gene rule" in reaction.name:
continue
metabolite_ids = [x.id for x in reaction.metabolites.keys() if x.id.startswith("im_")]
metabolite_ids = [x.id for x in reaction.metabolites.keys()
if x.id.startswith("im_")]
if len(metabolite_ids) == 1:
gecko_reactions_with_arm.append(reaction.id.split("_TG_")[0])

analogon_reactions_with_arm = []
for reaction in analogon.reactions:
if "Arm reaction" in reaction.name:
continue
metabolite_ids = [x.id for x in reaction.metabolites.keys() if x.id.startswith("armm_")]
metabolite_ids = [x.id for x in reaction.metabolites.keys()
if x.id.startswith("armm_")]
if len(metabolite_ids) == 1:
analogon_reactions_with_arm.append(reaction.id.split("_GPRSPLIT")[0])

Expand All @@ -40,7 +44,8 @@

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))
print("Number of arm reactions - sMOMENT GECKO analogon:",
len(analogon_reactions_with_arm))
difference = analogon_reactions_with_arm - gecko_reactions_with_arm
print("---")
print("Number of reactions - original GECKO: ", len(gecko.reactions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import openpyxl
from typing import Any, Dict, List

from submodules.helper_general import json_write
from .submodules.helper_general import json_write

# Get kcats
workbook = openpyxl.load_workbook("ec_model_2019_06_25_input_keff_paper/c3mb70119k-1.xlsx", read_only=True)
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/ec_model_2019_06_25_data_set_up_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""ec_model_data_set_up_model.py"""

import cobra
from ec_model_2019_06_25_data_standard_exchange_scenario import ec_model_shut_down_reactions
from .ec_model_2019_06_25_data_standard_exchange_scenario import ec_model_shut_down_reactions


def set_up_ec_model(model: cobra.Model, prot_pool: float):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import linregress, pearsonr, spearmanr
from ec_model_2019_06_25_data_scenarios_for_moment_comparison import exchange_reactions_by_c_source
from ec_model_2019_06_25_data_standard_exchange_scenario import ec_model_shut_down_reactions
from ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml
from .ec_model_2019_06_25_data_scenarios_for_moment_comparison import exchange_reactions_by_c_source
from .ec_model_2019_06_25_data_standard_exchange_scenario import ec_model_shut_down_reactions
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml

with open("ec_model_2019_06_25_input/c_sources_S3_Adadi_2012_with_monk_values.txt", "r") as f:
lines = f.readlines()
Expand Down
36 changes: 24 additions & 12 deletions autopacmen/ec_model_2019_06_25_figure_fva_variability_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,32 @@ def _get_fva_statistics(model):
# Minimum
with model:
if reaction.id.endswith("reverse"):
forward_reaction_name = reaction.id.replace("reverse", "forward")
forward_reaction_name = reaction.id.replace(
"reverse", "forward")
model.reactions.get_by_id(forward_reaction_name).knock_out()
if reaction.id.endswith("forward"):
reverse_reaction_name = reaction.id.replace("forward", "reverse")
reverse_reaction_name = reaction.id.replace(
"forward", "reverse")
model.reactions.get_by_id(reverse_reaction_name).knock_out()

model.objective = model_original.problem.Objective(-1 * model.reactions.get_by_id(reaction.id).flux_expression)
model.objective = model_original.problem.Objective(
-1 * model.reactions.get_by_id(reaction.id).flux_expression)
minimization_solution = model.optimize()
minimum = minimization_solution.fluxes[reaction.id]

# Maximum
with model:
if reaction.id.endswith("reverse"):
forward_reaction_name = reaction.id.replace("reverse", "forward")
forward_reaction_name = reaction.id.replace(
"reverse", "forward")
model.reactions.get_by_id(forward_reaction_name).knock_out()
if reaction.id.endswith("forward"):
reverse_reaction_name = reaction.id.replace("forward", "reverse")
reverse_reaction_name = reaction.id.replace(
"forward", "reverse")
model.reactions.get_by_id(reverse_reaction_name).knock_out()

model.objective = model_original.problem.Objective(1 * model.reactions.get_by_id(reaction.id).flux_expression)
model.objective = model_original.problem.Objective(
1 * model.reactions.get_by_id(reaction.id).flux_expression)

maximization_solution = model.optimize()
maximum = maximization_solution.fluxes[reaction.id]
Expand All @@ -78,8 +84,10 @@ def _get_fva_statistics(model):
mean_minimum = statistics.mean(minimums)
mean_maximum = statistics.mean(maximums)
num_zeroes = len([x for x in variabilities if x < 10e-10])
mean_variability = statistics.mean([x for x in variabilities if x > 10e-10])
median_variability = statistics.median([x for x in variabilities if x > 10e-10])
mean_variability = statistics.mean(
[x for x in variabilities if x > 10e-10])
median_variability = statistics.median(
[x for x in variabilities if x > 10e-10])

fva_dict["MEAN"] = {}
fva_dict["MEAN"]["minimum"] = mean_minimum
Expand Down Expand Up @@ -109,7 +117,8 @@ def split_all_reversibles(model: cobra.Model) -> cobra.Model:
reverse_reaction.id += "_REV"
reverse_reaction.upper_bound = -reaction.lower_bound
reverse_reaction.lower_bound = 0
reverse_reaction_metabolites_copy = copy.deepcopy(reverse_reaction.metabolites)
reverse_reaction_metabolites_copy = copy.deepcopy(
reverse_reaction.metabolites)
for key in list(reverse_reaction_metabolites_copy.keys()):
reverse_reaction_metabolites_copy[key] *= -2
reverse_reaction.add_metabolites(reverse_reaction_metabolites_copy)
Expand Down Expand Up @@ -143,8 +152,10 @@ def _add_worksheet(workbook, model_name, fva_dict):

name_original = "iJO1366_shut_down_scenario"
name_smoment = "sMOMENT_2019_06_25_sds_mc_fm_50"
model_smoment = cobra.io.read_sbml_model("ec_model_2019_06_25_output_optimization/iJO1366_sMOMENT_2019_06_25_STANDARD_EXCHANGE_SCENARIO_MANUAL_CHANGES_FMINCON_CHANGE_FACTOR_50.xml")
model_original = cobra.io.read_sbml_model("ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions_STANDARD_EXCHANGE_SCENARIO.xml")
model_smoment = cobra.io.read_sbml_model(
"ec_model_2019_06_25_output_optimization/iJO1366_sMOMENT_2019_06_25_STANDARD_EXCHANGE_SCENARIO_MANUAL_CHANGES_FMINCON_CHANGE_FACTOR_50.xml")
model_original = cobra.io.read_sbml_model(
"ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions_STANDARD_EXCHANGE_SCENARIO.xml")

model_smoment.reactions.get_by_id("EX_glc__D_e").lower_bound = -9.53
model_smoment.reactions.get_by_id("ER_pool_TG_").upper_bound = .095
Expand Down Expand Up @@ -187,7 +198,8 @@ def _add_worksheet(workbook, model_name, fva_dict):

# Create XLSX
print("Write XLSX \\o/")
workbook = xlsxwriter.Workbook(f"ec_model_2019_06_25_test_fva/fva_comparison_2019_06_25_fitted_mc_fm_50_vs_original_iJO1366_both_with_standard_exchange_scenario.xlsx")
workbook = xlsxwriter.Workbook(
f"ec_model_2019_06_25_test_fva/fva_comparison_2019_06_25_fitted_mc_fm_50_vs_original_iJO1366_both_with_standard_exchange_scenario.xlsx")
workbook = _add_worksheet(workbook, name_original, fva_dict_original)
workbook = _add_worksheet(workbook, name_smoment, fva_dict_smoment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import cobra
import numpy as np
from ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml


def fba_with_glucose_levels(model, glucose_levels, name):
Expand Down
2 changes: 1 addition & 1 deletion autopacmen/ec_model_2019_06_25_fva_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""

from submodules.fva_comparison import fva_comparison_with_sbml
from .submodules.fva_comparison import fva_comparison_with_sbml

SBML_ORIGINAL: str = "./ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions.xml"
SBML_SMOMENT: str = "ec_model_2019_06_25_output/iJO1366_sMOMENT_2019_06_25.xml"
Expand Down
6 changes: 4 additions & 2 deletions autopacmen/ec_model_2019_06_25_leucine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
min_yield = .2
min_growth = .1

model = cobra.io.read_sbml_model("ec_model_2019_06_25_output_optimization/iJO1366star.xml")
model = cobra.io.read_sbml_model(
"ec_model_2019_06_25_output_optimization/iJO1366star.xml")

biomass_reaction = model.reactions.get_by_id(biomass_reaction_id)
substrate_reaction = model.reactions.get_by_id(substrate_reaction_id)
Expand All @@ -30,4 +31,5 @@
print(model.summary())
print(-solution.fluxes[substrate_reaction_id])
print(solution.fluxes[product_reaction_id])
print(solution.fluxes[product_reaction_id] / (-solution.fluxes[substrate_reaction_id]))
print(solution.fluxes[product_reaction_id] /
(-solution.fluxes[substrate_reaction_id]))
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
method was followed as described in Sánchez et al., 2017.
"""

from submodules.create_gecko_model_reaction_wise import create_gecko_model_reaction_wise_with_sbml
from .submodules.create_gecko_model_reaction_wise import create_gecko_model_reaction_wise_with_sbml

INPUT_SBML: str = "./ec_model_2019_06_25_input/iJO1366.xml"
OUTPUT_SBML: str = "iJO1366_2019_06_25_GECKO.xml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ec_model_2019_06_25_data_set_up_model
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml
import cobra

model = ec_model_2019_06_25_data_set_up_model.set_up_ec_model_with_sbml("ec_model_2019_06_25_output_optimization/iJO1366_sMOMENT_2019_06_25_STANDARD_EXCHANGE_SCENARIO_MANUAL_CHANGES.xml", .095)
model = set_up_ec_model_with_sbml("ec_model_2019_06_25_output_optimization/iJO1366_sMOMENT_2019_06_25_STANDARD_EXCHANGE_SCENARIO_MANUAL_CHANGES.xml", .095)

reactions_to_change = [
# Acetate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""ec_model_2019_06_25_optimization_apply_manual_changes.py"""

import cobra
from submodules.apply_manual_changes import apply_manual_changes
from .submodules.apply_manual_changes import apply_manual_changes


KCAT_CHANGE_FACTORS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"""ec_model_original_generate_comparable_model.py"""

import cobra
from ec_model_data_set_up_model import set_up_ec_model_with_sbml
from submodules.helper_create_model import get_irreversible_model
from .ec_model_2019_06_25_data_set_up_model import set_up_ec_model_with_sbml
from .submodules.helper_create_model import get_irreversible_model

model = set_up_ec_model_with_sbml("ec_model_2019_06_25_input/iJO1366.xml", .225)
model = get_irreversible_model(model)
model = get_irreversible_model(model, "_TG_")
cobra.io.write_sbml_model(model, "ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions.xml")
model = set_up_ec_model_with_sbml("ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions.xml", .225)
cobra.io.write_sbml_model(model, "ec_model_2019_06_25_input/iJO1366_saved_by_cobrapy_and_separated_reversible_reactions_SHUT_DOWN_SCENARIO.xml")
Loading

0 comments on commit 9431228

Please sign in to comment.