Skip to content

Commit

Permalink
Updated get_model_reacs_or_metabs in entities to be more general #43
Browse files Browse the repository at this point in the history
The function get_model_reacs_or_metabs now takes a new parameter. If the model's metabolites/reactions are not from the BiGG namespace the parameter col_name can now be changed to  a user-specific string. To not break the original code, col_name is by default set to 'bigg_id'.
  • Loading branch information
GwennyGit committed Aug 21, 2023
1 parent 8fb98ff commit 8928352
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions refinegems/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ def compare_gene_lists(gps_in_model: pd.DataFrame, db_genes: pd.DataFrame, kegg:


# Function originally from refineGEMs.genecomp/refineGEMs.KEGG_analysis --- Modified
def get_model_reacs_or_metabs(model_libsbml: libModel, metabolites: bool=False) -> pd.DataFrame:
def get_model_reacs_or_metabs(model_libsbml: libModel, metabolites: bool=False, col_name: str='bigg_id') -> pd.DataFrame:
"""Extracts table of reactions/metabolites with BiGG IDs from model
Args:
- model_libsbml (libModel): Model loaded with libSBML
- metabolites (bool): Set to True if metabolites from model should be extracted
- col_name (str): Name to be used for column in Table, default: 'bigg_id'
Returns:
pd.DataFrame: Table with BiGG IDs of reactions in the model
pd.DataFrame: Table with model identifiers for either metabolites or reactions
"""
reac_or_metab_list = model_libsbml.getListOfSpecies() if metabolites else model_libsbml.getListOfReactions()

Expand All @@ -76,7 +77,7 @@ def get_model_reacs_or_metabs(model_libsbml: libModel, metabolites: bool=False)
list_of_reacs_or_metabs.append(reac_or_metab.id[2:])

reac_or_metab_list_df = pd.Series(list_of_reacs_or_metabs)
reac_or_metab_list_df = pd.DataFrame(reac_or_metab_list_df, columns=['bigg_id'])
reac_or_metab_list_df = pd.DataFrame(reac_or_metab_list_df, columns=[col_name])

return reac_or_metab_list_df

Expand Down

0 comments on commit 8928352

Please sign in to comment.