cobramod.utils ============== .. py:module:: cobramod.utils .. autoapi-nested-parse:: 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. Attributes ---------- .. autoapisummary:: cobramod.utils.debug_log cobramod.utils.ARROWS Functions --------- .. autoapisummary:: cobramod.utils.build_metabolite cobramod.utils.fix_name cobramod.utils.check_imbalance cobramod.utils.get_key_dict cobramod.utils.read_lines cobramod.utils.create_replacement cobramod.utils.compare_type cobramod.utils.compare_DictList cobramod.utils.write_to_file cobramod.utils.find_intersection cobramod.utils.is_compound cobramod.utils.get_arrow_position cobramod.utils.is_transport cobramod.utils.convert_to_transport cobramod.utils.confirm_metabolite cobramod.utils.confirm_sink cobramod.utils.add_reactions_to_model cobramod.utils.reaction_is_minimize cobramod.utils.inform_new_sinks cobramod.utils.get_credentials cobramod.utils.kegg_info_to_version Module Contents --------------- .. py:data:: debug_log .. py:data:: ARROWS :type: dict[str, tuple[int, int]] .. py:function:: build_metabolite(identifier, formula, name, charge, compartment) Returns a basic :class:`cobra.Metabolite`. Creation of the metabolite writes in the log a with a DEBUG level. level. :param identifier: Short name for Metabolite. :type identifier: str :param formula: Chemical formula :type formula: str :param name: Long name for Metabolite :type name: name :param charge: Charge of the metabolite :type charge: float :param compartment: Location :type compartment: str :returns: new created metabolite :rtype: Metabolite .. py:function:: fix_name(name) Returns new string, where hyphens are replaced to underscores .. py:function:: check_imbalance(reaction, stop_imbalance, show_imbalance) Verifies if given reaction is unbalanced in given model. :param reaction: Reaction object to examine. :type reaction: Reaction :param stop_imbalance: If imbalance is found, stop process. :type stop_imbalance: bool :param show_imbalance: If imbalance is found, show output. :type show_imbalance: bool :raises UnbalancedReaction: if given reaction is unbalanced. .. py:function:: 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. .. py:function:: read_lines(f) Reads Text I/O and returns iterator of line that are not comments nor blanks spaces .. py:function:: 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 .. py:function:: compare_type(first, second) Returns True is both objects are the same type, else raise TypeError. .. py:function:: compare_DictList(first, second) Yields item identifiers from the first DictList that are not in the second DictList .. py:function:: write_to_file(sequences, filename) Writes to given file all items from the iterable in separate lines. .. py:function:: 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 .. py:function:: is_compound(string) .. py:function:: get_arrow_position(reaction_str) .. py:function:: 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. .. py:function:: convert_to_transport(reaction_str, compartment) Modifies the reaction string such that the left side of the equation comes from the extracelullar compartment .. py:function:: confirm_metabolite(model, metabolites) Checks if given metabolites are already in the model. If not, they will be added into the model. :param model: Model to extend. :type model: Model :param metabolites: List with Metabolites. :type metabolites: List[Metabolites] .. py:function:: 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 .. py:function:: 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. .. py:function:: reaction_is_minimize(model, identifier) Return whether given reaction should be minimized when optimizing .. py:function:: 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. .. py:function:: get_credentials(file) .. py:function:: kegg_info_to_version(info)