From 654f4257cddd5914049e0d9a468e6ec43b008c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nina=20Ro=C3=9Fbach?= <167868803+niinina@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:33:34 +0200 Subject: [PATCH] small updates #8 --- src/specimen/cmpb/workflow.py | 17 ++++++++++------- src/specimen/hqtb/core/refinement/annotation.py | 3 ++- src/specimen/hqtb/core/refinement/extension.py | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/specimen/cmpb/workflow.py b/src/specimen/cmpb/workflow.py index ac376a1..c5cb253 100644 --- a/src/specimen/cmpb/workflow.py +++ b/src/specimen/cmpb/workflow.py @@ -22,7 +22,7 @@ from refinegems.analysis import growth from refinegems.analysis.investigate import plot_rea_sbo_single from refinegems.classes.reports import ModelInfoReport -from refinegems.utility.entities import test_biomass_presence +from refinegems.utility.util import test_biomass_presence from refinegems.curation.biomass import check_normalise_biomass from refinegems.curation.charges import correct_charges_modelseed from refinegems.curation.curate import resolve_duplicates @@ -120,10 +120,6 @@ def between_analysis(model: Model, cfg:dict, step:str): else: config = validate_config(configpath, 'cmpb') - 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 ... - # create directory structure # -------------------------- @@ -139,6 +135,12 @@ def between_analysis(model: Model, cfg:dict, step:str): Path(dir,"cmpb_out",'misc', 'kegg_pathway').mkdir(parents=True, exist_ok=False) # |- kegg_pathways Path(dir,"cmpb_out",'misc', 'auxotrophy').mkdir(parents=True, exist_ok=False) # |- auxothrophy + # save modelpath + # -------------- + if not config['general']['save_all_models']: + only_modelpath = Path(dir,'cmpb_out','models','model.xml') # @TODO Use model ID here... + # model might not exist here ... + # create log # ---------- today = date.today().strftime("%Y%m%d") @@ -314,8 +316,8 @@ def between_analysis(model: Model, cfg:dict, step:str): current_libmodel = load_model(str(current_modelpath),'libsbml') if config['general']['save_all_models']: current_libmodel = run_SBOannotator(current_libmodel) - write_model_to_file(current_libmodel, str(Path(dir,'cmpb_out','models', 'SBOannotated.xml'))) - current_modelpath = Path(dir,'cmpb_out','models', 'SBOannotated.xml') + write_model_to_file(current_libmodel, str(Path(dir,'cmpb_out','models', f'{current_libmodel.getId()}_SBOannotated.xml'))) + current_modelpath = Path(dir,'cmpb_out','models', f'{current_libmodel.getId()}_SBOannotated.xml') else: current_libmodel = run_SBOannotator(current_libmodel) write_model_to_file(current_libmodel, str(current_modelpath)) @@ -416,6 +418,7 @@ def between_analysis(model: Model, cfg:dict, step:str): # MCC # --- + Path(dir,"cmpb_out",'misc','mcc').mkdir(parents=True, exist_ok=False) current_model = perform_mcc(current_model, Path(dir,'cmpb_out','misc','mcc'),apply=True) # save the final model diff --git a/src/specimen/hqtb/core/refinement/annotation.py b/src/specimen/hqtb/core/refinement/annotation.py index 788bf33..d1ea683 100644 --- a/src/specimen/hqtb/core/refinement/annotation.py +++ b/src/specimen/hqtb/core/refinement/annotation.py @@ -17,8 +17,9 @@ import urllib.error # refinegems -from refinegems.utility.io import load_model, kegg_reaction_parser, write_model_to_file +from refinegems.utility.io import load_model, write_model_to_file from refinegems.utility.connections import run_memote, run_SBOannotator +from refinegems.utility.db_access import kegg_reaction_parser ################################################################################ # functions diff --git a/src/specimen/hqtb/core/refinement/extension.py b/src/specimen/hqtb/core/refinement/extension.py index 3136984..3628672 100644 --- a/src/specimen/hqtb/core/refinement/extension.py +++ b/src/specimen/hqtb/core/refinement/extension.py @@ -30,9 +30,10 @@ from Bio.KEGG import REST from Bio.KEGG import Enzyme, Compound -from refinegems.utility.io import kegg_reaction_parser, load_a_table_from_database +from refinegems.utility.io import load_a_table_from_database from refinegems.utility.entities import create_random_id, get_reaction_annotation_dict, match_id_to_namespace from refinegems.utility.connections import run_memote +from refinegems.utility.db_access import kegg_reaction_parser # further required programs: # - DIAMOND, tested with version 0.9.14 (works only for certain sensitivity mode)