From 31cad6e3ecb68d919257b905e85ecf552c0e7022 Mon Sep 17 00:00:00 2001 From: Catarina Loureiro Date: Tue, 26 Nov 2024 09:28:53 +0100 Subject: [PATCH] update cli validations & test config path --- big_scape/cli/cli_validations.py | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/big_scape/cli/cli_validations.py b/big_scape/cli/cli_validations.py index f057f8d7..fd0bd365 100644 --- a/big_scape/cli/cli_validations.py +++ b/big_scape/cli/cli_validations.py @@ -118,19 +118,19 @@ def validate_output_paths(ctx) -> None: timestamp = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) - if "db-path" in ctx.obj and ctx.obj["db-path"] is None: - db_path = ctx.obj["output-dir"] / Path(f"{ctx.obj['output-dir'].name}.db") - ctx.obj["db-path"] = db_path + if "db_path" in ctx.obj and ctx.obj["db_path"] is None: + db_path = ctx.obj["output_dir"] / Path(f"{ctx.obj['output_dir'].name}.db") + ctx.obj["db_path"] = db_path - if "log-path" in ctx.obj and ctx.obj["log-path"] is None: + if "log_path" in ctx.obj and ctx.obj["log_path"] is None: log_filename = timestamp + ".log" - log_path = ctx.obj["output-dir"] / Path(log_filename) - ctx.obj["log-path"] = log_path + log_path = ctx.obj["output_dir"] / Path(log_filename) + ctx.obj["log_path"] = log_path - if "profile-path" in ctx.obj and ctx.obj["profile-path"] is None: + if "profile_path" in ctx.obj and ctx.obj["profile_path"] is None: profile_filename = timestamp + ".profile" - profile_path = ctx.obj["output-dir"] / Path(profile_filename) - ctx.obj["profile-path"] = profile_path + profile_path = ctx.obj["output_dir"] / Path(profile_filename) + ctx.obj["profile_path"] = profile_path return None @@ -139,13 +139,13 @@ def validate_output_paths(ctx) -> None: def validate_disk_only(ctx) -> None: """Checks if the database storage/dumping modes that were set are compatible""" - if not ("no-db-dump" in ctx.obj and "disk-only" in ctx.obj): + if not ("no_db_dump" in ctx.obj and "disk_only" in ctx.obj): raise RuntimeError( "Something went wrong with the database storage/dumping mode parameters. " "Please contact the developers." ) - if ctx.obj["no-db-dump"] and ctx.obj["disk-only"]: + if ctx.obj["no_db_dump"] and ctx.obj["disk_only"]: logging.error( "You have selected both --no-db-dump and --disk-only. Please select only one" ) @@ -286,7 +286,7 @@ def validate_includelist_all(ctx, param, domain_includelist_all_path) -> None: pfams = validate_includelist(ctx, param, domain_includelist_all_path) - ctx.params["domain-includelist-all"] = pfams + ctx.params["domain_includelist_all"] = pfams return None @@ -301,7 +301,7 @@ def validate_includelist_any(ctx, param, domain_includelist_any_path) -> None: pfams = validate_includelist(ctx, param, domain_includelist_any_path) - ctx.params["domain-includelist-any"] = pfams + ctx.params["domain_includelist_any"] = pfams return None @@ -316,7 +316,7 @@ def validate_binning_cluster_workflow(ctx) -> None: # --legacy_weights needs a classification method - if ctx.obj["legacy-weights"] and not ctx.obj["classify"]: + if ctx.obj["legacy_weights"] and not ctx.obj["classify"]: logging.error( "You have selected --legacy-weights but no classification method. " "Please select any --classify method" @@ -343,11 +343,11 @@ def validate_binning_cluster_workflow(ctx) -> None: # --classify legacy turns on --legacy_weights if ctx.obj["classify"] == bs_enums.CLASSIFY_MODE.LEGACY: - ctx.obj["legacy-weights"] = True + ctx.obj["legacy_weights"] = True # --hybrids_off needs --classify - if ctx.obj["hybrids-off"]: + if ctx.obj["hybrids_off"]: if not (ctx.obj["classify"]): logging.error( "You have selected --hybrids-off but no classification method. " @@ -379,7 +379,7 @@ def validate_pfam_path(ctx) -> None: """Validates whether a BiG-SCAPE db exists when pfam_path is not provided, which requires already processed gbk files and hence a DB in output""" - if ctx.obj["pfam-path"] is None and ctx.obj["db-path"] is None: + if ctx.obj["pfam_path"] is None and ctx.obj["db_path"] is None: logging.error( "Missing option '-p/--pfam-path'." "BiG-SCAPE database not provided, a pfam file is " @@ -396,8 +396,8 @@ def validate_domain_include_list(ctx) -> None: """Raise an error if both domain includelists are given at the same time""" if ( - ctx.obj["domain-includelist-all-path"] - and ctx.obj["domain-includelist-any-path"] + ctx.obj["domain_includelist_all_path"] + and ctx.obj["domain_includelist_any_path"] ): logging.error( "You have selected both all and any domain-includelist options. " @@ -425,8 +425,8 @@ def validate_query_record(ctx) -> None: with a given record type""" if ( - ctx.obj["query-record-number"] is None - and ctx.obj["record-type"] != bs_enums.genbank.RECORD_TYPE.REGION + ctx.obj["query_record_number"] is None + and ctx.obj["record_type"] != bs_enums.genbank.RECORD_TYPE.REGION ): logging.error( "Missing option '--query-record-number'."