fluxpy.utils.model¶
Utilities to parse, convert and edit cobra models
Attributes¶
Classes¶
Generic enumeration. |
|
Load a list of sbml models with cobra as attributes of a class. |
|
A class to switch indexes of a dataframe from ids to names and vice versa for metabolites and reactions of a model. |
|
Using mergem <https://mergem.readthedocs.io/> to compare a pair of models and returns a dataframe with |
|
Class is used to identify cases where the same biochemical conversion is carried out by different cofactors in the model, |
Functions¶
|
This function makes use of the ModelSEEDpy and the ModelSEEDDatabase libraries to map a list of ModelSEED compounds |
|
compounds -- a list |
|
Adds metabolites and reactions required to allow a medium to be assigned to a cobra.Model |
|
Module Contents¶
- fluxpy.utils.model.all_namespaces = ['chebi', 'metacyc', 'kegg', 'reactome', 'metanetx', 'hmdb', 'biocyc', 'bigg', 'seed', 'sabiork', 'rhea'][source]¶
- class fluxpy.utils.model._Conversions[source]¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- class fluxpy.utils.model.Models(model_list: List[str], model_names: List[str] = None)[source]¶
Load a list of sbml models with cobra as attributes of a class.
- class fluxpy.utils.model.NameIdConverter(model, to_convert: pandas.DataFrame | Dict | List | cobra.Solution, convert: str, to: str)[source]¶
A class to switch indexes of a dataframe from ids to names and vice versa for metabolites and reactions of a model.
- class fluxpy.utils.model.CompareModels(model_list: List[str], trans_to_db=None)[source]¶
Using mergem <https://mergem.readthedocs.io/> 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.
- unique_metabolites(model_name)[source]¶
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
- unique_reactions(model_name)[source]¶
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
- compare_model_pair(base_model=None, model_to_compare=None)[source]¶
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
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
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
- fluxpy.utils.model.map_namespace_to_ModelSEEDDatabase(seed_compounds: List[str], path_to_modelSEEDDatabase: str, annotations_to_keep=['BiGG', 'BiGG1'])[source]¶
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
- fluxpy.utils.model.map_to_namespace(compounds, from_namespace='seed', to_namespace='bigg')[source]¶
compounds – a list from_namesapce – to_namespace –
- fluxpy.utils.model.sync_with_medium(model: cobra.Model, medium: Dict)[source]¶
Adds metabolites and reactions required to allow a medium to be assigned to a cobra.Model
- Parameters:
model (cobra.Model, mandatory) – model to which the new medium will be assigned to and to which metabolites and reactions will be added to
medium (Dict, mandatory) – a dictionary with the medium to be used with the metabolites as keys and their boundaries as values
- Returns:
A cobra.Model with added metabolites and reactions to enable medium to be used
- fluxpy.utils.model._check_if_modelseed_model(model: cobra.Model)[source]¶
- class fluxpy.utils.model.CofactorSpecificity(model)[source]¶
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)