Skip to content

Commit

Permalink
update cli validations & test config path
Browse files Browse the repository at this point in the history
  • Loading branch information
CatarinaCarolina committed Nov 26, 2024
1 parent c564dc7 commit 31cad6e
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions big_scape/cli/cli_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
)
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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"
Expand All @@ -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. "
Expand Down Expand Up @@ -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 "
Expand All @@ -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. "
Expand Down Expand Up @@ -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'."
Expand Down

0 comments on commit 31cad6e

Please sign in to comment.