fluxpy.utils.model ================== .. py:module:: fluxpy.utils.model .. autoapi-nested-parse:: Utilities to parse, convert and edit cobra models Attributes ---------- .. autoapisummary:: fluxpy.utils.model.all_namespaces Classes ------- .. autoapisummary:: fluxpy.utils.model._Conversions fluxpy.utils.model.Models fluxpy.utils.model.NameIdConverter fluxpy.utils.model.CompareModels fluxpy.utils.model.CofactorSpecificity Functions --------- .. autoapisummary:: fluxpy.utils.model.map_namespace_to_ModelSEEDDatabase fluxpy.utils.model.map_to_namespace fluxpy.utils.model.sync_with_medium fluxpy.utils.model._check_if_modelseed_model Module Contents --------------- .. py:data:: all_namespaces :value: ['chebi', 'metacyc', 'kegg', 'reactome', 'metanetx', 'hmdb', 'biocyc', 'bigg', 'seed', 'sabiork', 'rhea'] .. py:class:: _Conversions Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: REACTION_NAMES :value: 'reactionNames' .. py:attribute:: REACTION_IDS :value: 'reactionIds' .. py:attribute:: METABOLITE_NAMES :value: 'metaboliteNames' .. py:attribute:: METABOLITE_IDS :value: 'metaboliteIds' .. py:class:: Models(model_list: List[str], model_names: List[str] = None) Load a list of sbml models with cobra as attributes of a class. .. py:class:: NameIdConverter(model, to_convert: Union[pandas.DataFrame, Dict, List, cobra.Solution], convert: str, to: str) A class to switch indexes of a dataframe from ids to names and vice versa for metabolites and reactions of a model. .. py:attribute:: met_map_df .. py:attribute:: react_map_df .. py:attribute:: convert .. py:attribute:: to .. py:attribute:: model .. py:attribute:: isIndex .. py:method:: run_convert() .. py:method:: _met_ids_to_met_names() .. py:method:: _met_names_to_met_ids() .. py:method:: _react_ids_to_react_names() .. py:method:: _react_names_to_react_ids() .. py:class:: CompareModels(model_list: List[str], trans_to_db=None) Using mergem to compare a pair of models and returns a dataframe with reactions unique in model1 and model2 and those they share. Key arguments: model_list -- list of paths to model files to compare trans_to_db -- mergem allows to map metabolite and reaction ids to a series of namespaces. .. py:attribute:: number_of_models .. py:attribute:: model_names .. py:attribute:: models .. py:attribute:: namespace :value: None .. py:attribute:: res .. py:attribute:: metabolites_df .. py:attribute:: reactions_df .. py:method:: unique_metabolites(model_name) Returns: unique_mets -- a pd.Index with the metabolites that are only present in model_name and not in any other of those in model_list .. py:method:: unique_reactions(model_name) Key arguments: model_name -- the name (column name) of the model for which unique reactions will be found Returns: model_unique_reactions -- a pd.Index with the reactions that are only present in the model_name and not in any other of those in model_list .. py:method:: compare_model_pair(base_model=None, model_to_compare=None) Compare pairwise models Key arguments: base_model -- name of the model as in dataframe, i.e. filename without the extension model_to_compare -- name of the model as in dataframe, i.e. filename without the extension Returns: r1 -- reactions only present in base model r2 -- reactions only present in model_to_compare m1 -- metabolites only present in base_model m2 -- metabolites only present in model_to_compare .. py:method:: shared_metabolites(models_subset=None) Key arguments: models_subset -- list of models to get shared metabolites and reactions Returns: shared_reactions -- a pd.Index with rearctions present among all models of models_subset .. py:method:: shared_reactions(models_subset=None) Key arguments: models_subset -- list of models to get shared metabolites and reactions Returns: shared_reactions -- a pd.Index with rearctions present among all models of models_subset .. py:function:: map_namespace_to_ModelSEEDDatabase(seed_compounds: List[str], path_to_modelSEEDDatabase: str, annotations_to_keep=['BiGG', 'BiGG1']) This function makes use of the ModelSEEDpy and the ModelSEEDDatabase libraries to map a list of ModelSEED compounds to their annotations returning a pandas dataframe with those seed_compouds -- a list with seed compound ids path_to_modelSEEDDatabase -- path to the modelSEEDDatabase. To get it: git clone https://github.com/ModelSEED/ModelSEEDDatabase.git .. py:function:: map_to_namespace(compounds, from_namespace='seed', to_namespace='bigg') compounds -- a list from_namesapce -- to_namespace -- .. py:function:: sync_with_medium(model: cobra.Model, medium: Dict) Adds metabolites and reactions required to allow a medium to be assigned to a cobra.Model :param model: model to which the new medium will be assigned to and to which metabolites and reactions will be added to :type model: cobra.Model, mandatory :param medium: a dictionary with the medium to be used with the metabolites as keys and their boundaries as values :type medium: Dict, mandatory :returns: A cobra.Model with added metabolites and reactions to enable medium to be used .. py:function:: _check_if_modelseed_model(model: cobra.Model) .. py:class:: CofactorSpecificity(model) Class is used to identify cases where the same biochemical conversion is carried out by different cofactors in the model, while in reality the organism only uses one of the cofactors. If the cofactor specificity information is available, the reaction with non-specific cofactor can be removed or turned off. This is how to initialize the class: cofactor_specificity = CofactorSpecificity(cobra_model) .. py:attribute:: model .. py:method:: find_reactants_products_cofactors() .. py:method:: find_reactions_combinations() .. py:method:: merge_connected_combinations() This function takes as input the pairwise combinations of reactions from above and creates groups of reactions that are candidates for cofactor specificity. It uses a graph-based approach to find connected components in the graph of reactions. .. py:method:: cofactors_abundance() .. py:method:: remove_reactions() .. py:method:: filter_reactions()