7.1.2.5. 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.
7.1.2.5.1. Attributes¶
7.1.2.5.2. Functions¶
|
Returns a basic |
|
Returns new string, where hyphens are replaced to underscores |
|
Verifies if given reaction is unbalanced in given model. |
|
From given pattern, return the first key of the dictionary that matches it |
|
Reads Text I/O and returns iterator of line that are not comments nor |
|
Creates a dictionary build from given file. Key are the first word until |
|
Returns True is both objects are the same type, else raise TypeError. |
|
Yields item identifiers from the first DictList that are not in the second |
|
Writes to given file all items from the iterable in separate lines. |
|
Return the first item from the intersection of a DictList and the values of |
|
|
|
|
|
Check if given reaction includes same participant in both sides, |
|
Modifies the reaction string such that the left side of the equation |
|
Checks if given metabolites are already in the model. If not, they will be |
|
Creates sink reactions for the metabolites that participate in given |
|
Check function that adds Reactions to given model if it does not |
|
Return whether given reaction should be minimized when optimizing |
|
Warns the user if sinks were created during the extension of the Model. |
|
|
|
7.1.2.5.3. Module Contents¶
- cobramod.utils.debug_log¶
- cobramod.utils.build_metabolite(identifier, formula, name, charge, compartment)¶
Returns a basic
cobra.Metabolite. Creation of the metabolite writes in the log a with a DEBUG level. level.
- cobramod.utils.fix_name(name)¶
Returns new string, where hyphens are replaced to underscores
- cobramod.utils.check_imbalance(reaction, stop_imbalance, show_imbalance)¶
Verifies if given reaction is unbalanced in given model.
- Parameters:
- Raises:
UnbalancedReaction – if given reaction is unbalanced.
- cobramod.utils.get_key_dict(dictionary, pattern)¶
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.read_lines(f)¶
Reads Text I/O and returns iterator of line that are not comments nor blanks spaces
- Parameters:
f (TextIO)
- Return type:
Iterator
- cobramod.utils.create_replacement(filename)¶
Creates a dictionary build from given file. Key are the first word until a colon ‘:’ is found. The rest represents the value
- Parameters:
filename (pathlib.Path)
- Return type:
- cobramod.utils.compare_type(first, second)¶
Returns True is both objects are the same type, else raise TypeError.
- Parameters:
first (Any)
second (Any)
- cobramod.utils.compare_DictList(first, second)¶
Yields item identifiers from the first DictList that are not in the second DictList
- Parameters:
first (cobra.DictList)
second (cobra.DictList)
- Return type:
Generator
- cobramod.utils.write_to_file(sequences, filename)¶
Writes to given file all items from the iterable in separate lines.
- Parameters:
sequences (Iterable)
filename (pathlib.Path)
- cobramod.utils.find_intersection(dictlist, query, revert)¶
Return the first item from the intersection of a DictList and the values of a dictionary. The identifiers from the DictList can be reverted to their original. Returns None if no intersection is found
- cobramod.utils.is_transport(reaction_str)¶
Check if given reaction includes same participant in both sides, meaning that there is a tranport reaction. Prefix is not taken into consideration.
- cobramod.utils.convert_to_transport(reaction_str, compartment)¶
Modifies the reaction string such that the left side of the equation comes from the extracelullar compartment
- cobramod.utils.confirm_metabolite(model, metabolites)¶
Checks if given metabolites are already in the model. If not, they will be added into the model.
- Parameters:
model (Model) – Model to extend.
metabolites (List[Metabolites]) – List with Metabolites.
- cobramod.utils.confirm_sink(model, identifier)¶
Creates sink reactions for the metabolites that participate in given reaction. They can only be created if the corresponding metabolite only participates in one reaction. Otherwise, the metabolite can be somehow turnover
- Parameters:
model (cobra.core.Model)
identifier (str)
- cobramod.utils.add_reactions_to_model(model, reactions)¶
Check function that adds Reactions to given model if it does not contain the reaction. It logs the skipped reactions.
- Parameters:
model (cobra.core.Model)
reactions (list[cobra.core.Reaction])
- cobramod.utils.reaction_is_minimize(model, identifier)¶
Return whether given reaction should be minimized when optimizing
- Parameters:
model (cobra.core.Model)
identifier (str)
- Return type:
- cobramod.utils.inform_new_sinks(model, previous_sinks)¶
Warns the user if sinks were created during the extension of the Model. i.e. Function compares a set with sink identifiers with the actual sinks in a model.
- Parameters:
model (cobra.core.Model)
- cobramod.utils.get_credentials(file)¶
- Parameters:
file (pathlib.Path)
- Return type: