5.1.1.1.2. cobramod.core.extension

Pathway extension

This module handles the addition of reactions as a pathway into a model and the corresponding test that comes with it.

Most important functions: - add_pathway: Adds a pathway or multiple reactions into a model. - test_non_zero_flux: Checks that the given reaction in a model is active and

gives a non-zero flux.

5.1.1.1.2.1. Module Contents

5.1.1.1.2.1.1. Functions

test_non_zero_flux(model: cobra.Model, reaction: str, times: int = 0, ignore_list: List[str] = [])

Verifies that a simple FBA can be performed. A demand reaction is created

add_pathway(model: cobra.Model, pathway: Union[list, str], directory: pathlib.Path, database: str, compartment: str, group: Optional[str] = None, avoid_list: List[str] = [], replacement: dict = {}, ignore_list: List[str] = [], filename: pathlib.Path = None, stop_imbalance: bool = False, show_imbalance: bool = True, model_id: str = 'universal', genome: Optional[str] = None)

Adds a pathway from the given database into a model. The argument ‘pathway’

5.1.1.1.2.1.2. Attributes

cobra_tolerance

cobramod.core.extension.cobra_tolerance :float
cobramod.core.extension.test_non_zero_flux(model: cobra.Model, reaction: str, times: int = 0, ignore_list: List[str] = [])

Verifies that a simple FBA can be performed. A demand reaction is created with a minimum flux based on the COBRApy Configuration object. It will use its variable ‘tolerance’ multiplied by 10. The function is recursive and checks if sink reactions are sufficient or exceeded. It generates a demand reaction for the reaction used for testing and removes it if necessary.

Parameters
  • model (Model) – Model in which the reaction is present.

  • reaction (str) – Reaction identifier in model to test.

  • times (int, optional) – Track of recursions. Defaults to 0.

  • ignore_list (list, optional) – A sequence of formatted metabolites to be

  • [] (ignored when testing new reactions. Defaults to) –

Raises

NotInRangeError – If the solution is infeasible after many recursions. Depends on the number of metabolites in the reaction.

cobramod.core.extension.add_pathway(model: cobra.Model, pathway: Union[list, str], directory: pathlib.Path, database: str, compartment: str, group: Optional[str] = None, avoid_list: List[str] = [], replacement: dict = {}, ignore_list: List[str] = [], filename: pathlib.Path = None, stop_imbalance: bool = False, show_imbalance: bool = True, model_id: str = 'universal', genome: Optional[str] = None)

Adds a pathway from the given database into a model. The argument ‘pathway’ can be a list of reactions identifiers or explicitly a pathway identifier. A group of reactions will be included in a custom group. The data will be downloaded and structured according to the database.

Parameters
  • model (Model) – Model to expand.

  • pathway (list, str) – Sequence of reaction identifiers or a single identifier for a pathway. Examples: [“RXN-2206”, “RXN-207”] or “PWY-886”

  • directory (Path) – Path for the directory to stored and retrieve data.

  • database (str) – Name of the database. Check cobramod.available_databases for a list of names.

  • compartment – Location of the reactions.

  • group (str, optional) – Common cobramod.pathway.Pathway identifier. This will overwrite the name of the pathway.

Arguments for complex pathways: avoid_list (list, optional): A sequence of reactions identifiers to avoid

adding to the model. This is useful for long pathways, where X reactions need to be excluded.

replacement (dict, optional): Original identifiers to be replaced.

Values are the new identifiers.

ignore_list (list): A sequence of formatted metabolites to be ignored when testing, and/or reactions that should be added but not tested.

This is useful for long cyclical pathways.

Arguments for summary:
filename (Path, optional): Location for the summary. Defaults to

“summary” in the current working directory. The file format is defined by the suffix. The suffixes ‘.txt’, ‘.csv’ and ‘.xlsx’ can be used. If the filename is set to None, no summary will be created.

Arguments for utilities:
stop_imbalance (bool, optional): If an unbalanced reaction is found,

stop the process. Defaults to False.

show_imbalance (bool, optional): If an unbalanced reaction is found,

print output. Defaults to True.

model_id (str, optional): Exclusive for BIGG. Retrieve object from

specified model. Pathways are not available. Defaults to: “universal”

genome (str, optional): Exclusive for KEGG. Abbreviation for the

species involved. Genes will be obtained for this species. List available at https://www.genome.jp/kegg/catalog/org_list.html