Skip to content

Commit

Permalink
Fixed CMPB workflow #8
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-Hades committed Aug 22, 2024
1 parent 91ebf0b commit 71794de
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 79 deletions.
89 changes: 23 additions & 66 deletions dev/CB_test_modules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1549,13 +1549,16 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/brune/miniconda3/envs/sprg/lib/python3.10/site-packages/pydantic/_internal/_config.py:322: UserWarning: Valid config keys have changed in V2:\n",
"* 'underscore_attrs_are_private' has been removed\n",
" warnings.warn(message, UserWarning)\n",
"WARNING:root:Keyword USER detected in config (gram). Either due to skipped options or missing required information.\n",
"Reminder: This may lead to downstream problems.\n",
"WARNING:root:Keyword USER detected in config (gene-table). Either due to skipped options or missing required information.\n",
Expand All @@ -1575,19 +1578,28 @@
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running in debugging mode.\n",
"fill_model: Running in debugging mode\n"
]
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "571a86b91c4b4bfd97d7510cbf21dfc0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/3 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Trying to add missing reacs: 100%|██████████| 10/10 [00:10<00:00, 1.04s/it]\n",
"Adding genes to model: 100%|██████████| 3/3 [00:00<00:00, 5197.40it/s]\n",
"Adding genes to model: 100%|██████████| 5/5 [00:00<00:00, 5902.48it/s]\n",
"Trying to add missing reacs: 0%| | 1/2581 [00:05<3:39:27, 5.10s/it]/Users/brune/Documents/10_Code/refinegems/build/__editable__.refineGEMs-1.4.2-py3-none-any/refinegems/utility/entities.py:630: UserWarning: HTTPError: G10554(n)\n",
" warnings.warn(F'HTTPError: {kegg_id}')\n",
"Trying to add missing reacs: 100%|██████████| 2581/2581 [32:07<00:00, 1.34it/s]\n",
"Adding genes to model: 100%|██████████| 146/146 [00:00<00:00, 20753.33it/s]\n",
"/Users/brune/Documents/10_Code/refinegems/build/__editable__.refineGEMs-1.4.2-py3-none-any/refinegems/classes/reports.py:234: UserWarning: Model is not able to grow sensible on any medium. Returning empty figure.\n",
" warnings.warn('Model is not able to grow sensible on any medium. Returning empty figure.')\n"
]
Expand All @@ -1607,15 +1619,15 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 1538/1538 [01:35<00:00, 16.11it/s]\n"
"100%|██████████| 1538/1538 [01:52<00:00, 13.65it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Model with SBO annotations written to /var/folders/xd/zl0vk7sj60xcc0zmc4k4mxxc0000gr/T/tmphkr5txa_/dud.xml ...\n",
"Model with SBO annotations written to /var/folders/xd/zl0vk7sj60xcc0zmc4k4mxxc0000gr/T/tmpzhcgfxa0/dud.xml ...\n",
"\n",
"\tDuplicate metabolite(s) nh3_c, nh4_c found.\n",
"\tDuplicate metabolite(s) fdxo_2_2_c, fdxox_c found.\n",
Expand Down Expand Up @@ -1721,61 +1733,6 @@
"run(cfg)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/brune/miniconda3/envs/sprg/lib/python3.10/site-packages/pydantic/_internal/_config.py:322: UserWarning: Valid config keys have changed in V2:\n",
"* 'underscore_attrs_are_private' has been removed\n",
" warnings.warn(message, UserWarning)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\tSpecial case -Duplicate NH4/NH3- detected.\n",
"\tTrying to solve by additionally removing reactions containing both metabolites.\n",
"\tDuplicate metabolite nh4_c found (duplicate to nh3_c based on annotation).\n",
"\t\tAutomated deletion not possible due to problems with consistency.\n",
"\tDuplicate metabolite fdxox_c found. Replaced with fdxo_2_2_c.\n",
"\tDuplicate metabolite metsox_S__L_c found. Replaced with metox_c.\n",
"\tDuplicate metabolite shcl_c found. Replaced with dscl_c.\n",
"\tDuplicate metabolite srch_c found (duplicate to scl_c based on annotation).\n",
"\t\tAutomated deletion not possible due to problems with consistency.\n",
"unknown metabolite 'acorn__L_c' created\n",
"\tDuplicate metabolite orn_c found (duplicate to orn__L_c based on annotation).\n",
"\t\tAutomated deletion not possible due to problems with consistency.\n",
"\tDuplicate metabolite metsox_S__L_e found. Replaced with metox_e.\n",
"\tDuplicate reaction OPTCCL found. Combined to OPETDC and deleted.\n",
"\tDuplicate reaction THZPSN_1 found. Combined to THZPSN and deleted.\n",
"\tDuplicate reaction METSR_S1 found. Combined to METSOXR1 and deleted.\n",
"\tDuplicate reaction METSabc found. Combined to METSOX1abc and deleted.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/brune/miniconda3/envs/sprg/lib/python3.10/site-packages/cobra/core/group.py:147: UserWarning: need to pass in a list\n",
" warn(\"need to pass in a list\")\n"
]
}
],
"source": [
"from refinegems.utility.io import load_model \n",
"from refinegems.curation.curate import resolve_duplicates\n",
"\n",
"testmodel = load_model('/Users/brune/Documents/11_Test_Data/test_SPECIMEN/cmpb/testrun/cmpb_out/model.xml','cobra')\n",
"\n",
"mod = resolve_duplicates(testmodel, replace_dupl_meta=True, check_reac=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
12 changes: 5 additions & 7 deletions src/specimen/cmpb/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ def between_analysis(model: Model, cfg:dict, step:str):

dir = config['general']['dir']
if not config['general']['save_all_models']:
only_modelpath = Path(dir,'cmpb_out','model.xml') # @TODO Use model ID here...
# model might not exist here ...
only_modelpath = Path(dir,'cmpb_out','model.xml')

# create directory structure
# --------------------------
Expand Down Expand Up @@ -377,8 +376,6 @@ def between_analysis(model: Model, cfg:dict, step:str):

# in-between testing
between_growth_test(current_model,config,step='after_duplicate_removal')
import sys
sys.exit(0) # ------------------ issue above ------------------------
between_analysis(current_model,config,step='after_duplicate_removal')

# BOF
Expand Down Expand Up @@ -469,10 +466,11 @@ def between_analysis(model: Model, cfg:dict, step:str):

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

# @TODO / @IDEAS Add option to have specific colour list per model for plots
# @TODO
# - 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?
# @TODO Add optional FROG report at end of pipeline
# - Maybe get models at first and then add model IDs to every save filename?
# - Add optional FROG report at end of pipeline

# run for multiple models
def wrapper():
Expand Down
11 changes: 7 additions & 4 deletions src/specimen/data/config/cmpb_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Meaning of the default parameters:
# The value __USER__ indicates parameters required to be specified by the user
# The value USER indicates parameters required only in specific cases
# To avoid warnings, set parameters you do not use to null or NULL

# Meta info:
# model: USER
Expand All @@ -14,8 +15,7 @@
# ----------------------
input:
modelpath: NULL # Optional, path to a model.
# If not given, runs CarveMe -> Future update!
# annotated_genome: USER # Some alternative input if not model is given
# If not given, runs CarveMe
mediapath: __USER__ # Path to a media config to test growth with

# General options
Expand Down Expand Up @@ -50,10 +50,11 @@ tech-resources:
# Build a model using CarveMe
# ---------------------------
carveme:
# requires protein_fasta under general to be set
# CarveMe requires protein_fasta under general to be set instead of modelpath
# if CarveMe should be run,
# fill out the params below
gram: USER # grampos or gramneg?
gram: USER # Choose either grampos or gramneg, depending on the Gram-test
# resilts of your organism

# Polish a CarveMe model
# Only neccessary, if the model will or has been build with CarveMe
Expand All @@ -67,6 +68,7 @@ cm-polish:
# Filling gaps, optional
# ----------------------
gapfilling:

########### general options ###########
# parameters, that apply to all the gap filling algorithmns
idprefix: 'CMPB' # prefix to use for fantasy IDs, if IDs for
Expand All @@ -79,6 +81,7 @@ gapfilling:
# from being added to the model.
exclude-rna: True # Exclude reactions containing 'RNA' in their name
# from being added to the model.

########## enable algorithms ##########
# via KEGG ...................
# requires KEGG organism ID to be set
Expand Down
6 changes: 4 additions & 2 deletions src/specimen/util/set_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
HQTB_CONFIG_PATH_REQUIRED = ['annotated_genome','full_sequence','model','diamond',
'mnx_chem_prop', 'mnx_chem_xref','mnx_reac_prop','mnx_reac_xref',
'media_analysis'] #: :meta:
CMPB_CONFIG_PATHS_REQUIRED = ['mediapath','protein_fasta','refseq_gff','annotated_genome'] #: :meta:
CMPB_CONFIG_PATHS_OPTIONAL = ['modelpath','biocyc_files','full_genome_sequence'] # :meta:
CMPB_CONFIG_PATHS_REQUIRED = ['mediapath'] #: :meta:
CMPB_CONFIG_PATHS_OPTIONAL = ['modelpath','full_genome_sequence','refseq_gff', 'protein_fasta',
'gene-table','reacs-table','gff','swissprot-dmnd',
'swissprot-mapping'] # :meta:
PIPELINE_PATHS_OPTIONAL = {'hqtb':HQTB_CONFIG_PATH_OPTIONAL,
'cmpb':CMPB_CONFIG_PATHS_OPTIONAL} #: :meta:
PIPELINE_PATHS_REQUIRED = {'hqtb':HQTB_CONFIG_PATH_REQUIRED,
Expand Down

0 comments on commit 71794de

Please sign in to comment.