5.2.4. cobramod.utils

CobraMod’s helpful function

This module is intended to stored multiple functions, which cannot be grouped to any module. In other words, these functions are general functions. An .. rubric:: Example

  • check_imbalance: Check for unbalanced reactions.

5.2.4.1. Module Contents

5.2.4.1.1. Functions

check_imbalance(reaction: cobra.Reaction, stop_imbalance: bool, show_imbalance: bool)

Verifies if given reaction is unbalanced in given model.

get_key_dict(dictionary: dict, pattern: str) → str

From given pattern, return the first key of the dictionary that matches it

create_replacement(filename: pathlib.Path) → dict

Creates a dictionary build from given file. Key are the first word until

compare_type(first: Any, second: Any)

Returns True is both objects are the same type, else raise TypeError.

compare_DictList(first: cobra.DictList, second: cobra.DictList) → Generator

Yields item identifiers from the first DictList that are not in the second

write_to_file(sequences: Iterable, filename: pathlib.Path)

Writes to given file all items from the iterable in separate lines.

cobramod.utils.check_imbalance(reaction: cobra.Reaction, stop_imbalance: bool, show_imbalance: bool)

Verifies if given reaction is unbalanced in given model.

Parameters
  • reaction (Reaction) – Reaction object to examine.

  • stop_imbalance (bool) – If imbalance is found, stop process.

  • show_imbalance (bool) – If imbalance is found, show output.

Raises

UnbalancedReaction – if given reaction is unbalanced.

cobramod.utils.get_key_dict(dictionary: dict, pattern: str) str

From given pattern, return the first key of the dictionary that matches it or is a sub-string of it. It will raise a Warning if nothing found.

cobramod.utils.create_replacement(filename: pathlib.Path) dict

Creates a dictionary build from given file. Key are the first word until a colon ‘:’ is found. The rest represents the value

cobramod.utils.compare_type(first: Any, second: Any)

Returns True is both objects are the same type, else raise TypeError.

cobramod.utils.compare_DictList(first: cobra.DictList, second: cobra.DictList) Generator

Yields item identifiers from the first DictList that are not in the second DictList

cobramod.utils.write_to_file(sequences: Iterable, filename: pathlib.Path)

Writes to given file all items from the iterable in separate lines.