Skip to content

Commit

Permalink
Added colour option to cmpb pipeline #8
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-Hades committed May 24, 2024
1 parent 1f4e3af commit 5465e0e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 68 deletions.
61 changes: 4 additions & 57 deletions dev/CB_test_modules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@
{
"data": {
"text/plain": [
"<bound method SBase.getNotesString of <Model Kp_std \"Genome-scale metabolic model of K. pneumoniae HS11286\">>"
"'test'"
]
},
"execution_count": 2,
Expand All @@ -2778,63 +2778,10 @@
}
],
"source": [
"from refinegems.utility.io import load_model\n",
"import cobra\n",
"\n",
"p = '/Users/brune/Documents/11_Test_Data/test_SPECIMEN/thesis/Kp_std/02_generate_draft_model/Kp_std_draft.xml'\n",
"model = load_model(p,'libsbml')\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"model.getModelHistory()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'<notes>\\n <html xmlns=\"http://www.w3.org/1999/xhtml\">\\n <p>Description: This model was built with CarveMe version 1.5.1</p>\\n </html>\\n</notes>'"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = model.getNotesString()\n",
"x\n",
"# 'CarveMe' in x"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Description': 'This model was built with CarveMe version 1.5.1'}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mod2 = load_model(p, 'cobra')\n",
"mod2.notes"
"m = cobra.Model('test')\n",
"m.id"
]
},
{
Expand Down
25 changes: 14 additions & 11 deletions src/specimen/cmpb/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@

# ....................................................
# @TODO / @IDEAS
# global options
# run memote after every step
# calculate model stats after each step
# use temp folder or report all model/in-between steps
# what to write in the log file
# ....................................................
Expand All @@ -51,9 +48,6 @@
# in the run function: current_model means the cobrapy model,
# while current_libmodel means the libsbml model

# @TODO / @IDEAS Add option to have specific colour list per model for plots
# @TODO Maybe get models at first and then add model IDs to every save filename?

def run(configpath:str):

def between_growth_test(model, cfg, step):
Expand All @@ -66,7 +60,8 @@ def between_growth_test(model, cfg, step):
growth_report = growth.growth_analysis(model, cfg['input']['mediapath'],
namespace=cfg['general']['namespace'],
retrieve='report')
growth_report.save(Path(cfg['general']["dir"], 'cmpb_out', 'misc', 'growth', step))
growth_report.save(Path(cfg['general']["dir"], 'cmpb_out', 'misc', 'growth', step),
color_palette=config['general']['colours'])
else:
mes = f'No growth/biomass function detected, growth simulation for step {step} will be skipped.'
warnings.warn(mes)
Expand All @@ -80,7 +75,8 @@ def between_analysis(model, cfg, step):
verbose=False)
if cfg['general']['stats_always_on']:
report = ModelInfoReport(model)
report.save(Path(cfg['general']["dir"],'cmpb_out', 'misc', 'stats',f'{step}_.html'))
report.save(Path(cfg['general']["dir"],'cmpb_out', 'misc', 'stats',f'{step}_.html'),
color_palette=config['general']['colours'])


# setup phase
Expand Down Expand Up @@ -374,12 +370,14 @@ def between_analysis(model, cfg, step):
# stats
# -----
stats_report = ModelInfoReport(current_model)
stats_report.save(Path(dir,'cmpb_out', 'misc','stats'))
stats_report.save(Path(dir,'cmpb_out', 'misc','stats'),
color_palette=config['general']['colours'])

# kegg pathway
# ------------
pathway_report = kegg_pathway_analysis(current_model)
pathway_report.save(Path(dir,'cmpb_out','misc','kegg_pathway'))
pathway_report.save(Path(dir,'cmpb_out','misc','kegg_pathway'),
colors=config['general']['colours'])

# sbo term
# --------
Expand All @@ -398,11 +396,16 @@ def between_analysis(model, cfg, step):
# ------------
media_list = growth.read_media_config(config['input']['mediapath'])
auxo_report = growth.test_auxotrophies(current_model, media_list[0], media_list[1], config['general']['namespace'])
auxo_report.save(Path(dir,'cmpb_out','misc','auxotrophies'))
auxo_report.save(Path(dir,'cmpb_out','misc','auxotrophies'),
color_palette=config['general']['colours'])


####### IDEAS below ####

# @TODO / @IDEAS Add option to have specific colour list per model for plots
# for the comparison when runnin this on multiple models
# @TODO Maybe get models at first and then add model IDs to every save filename?

# run for multiple models
def wrapper():
pass
3 changes: 3 additions & 0 deletions src/specimen/data/config/cmpb_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ input:
# ---------------
general:
dir: './' # Path/Name of a directory to save output to
colours: 'YlGn' # set the colour scheme for the plots
# should be a valid matplotlib continuous color palette
namespace: BiGG # Namespace to use for the model
# Possible identifiers, currently: BiGG
save_all_models: True # save all models (models for each step)
memote_always_on: False # run memote after every step
stats_always_on: False # calculate the model statistics after every step
# below are options used by multiple steps
refseq_gff: USER # Path to RefSeq GFF file: Required for gap analysis with 'KEGG'.
# Can be optionally provided for cm-polish.
kegg_organism_id: USER # KEGG ID of the organism: Required for gap analysis with KEGG.
Expand Down

0 comments on commit 5465e0e

Please sign in to comment.