diff --git a/funannotate2/annotate.py b/funannotate2/annotate.py index e5ee0d9..bb7f369 100755 --- a/funannotate2/annotate.py +++ b/funannotate2/annotate.py @@ -363,7 +363,8 @@ def annotate(args): else: # choose best busco species busco_species = choose_best_busco_species(taxonomy) - # Ensure the BUSCO lineage is available under FUNANNOTATE2_DB, + # Ensure the BUSCO lineage is available under BUSCO_DOWNLOAD_PATH, + # falling back to FUNANNOTATE2_DB i BUSCO_DOWNLOAD_PATH is not set, # downloading it if needed. In dockerized usage the lineage from a # previous train/predict run is gone when annotate starts in a fresh # container, so this guards against the cryptic " is not a diff --git a/funannotate2/config.py b/funannotate2/config.py index 66e9a2d..775c0c3 100755 --- a/funannotate2/config.py +++ b/funannotate2/config.py @@ -22,6 +22,9 @@ os.path.dirname(env["AUGUSTUS_CONFIG"]), "scripts" ) +if "BUSCO_DOWNLOAD_PATH" in os.environ: + env["BUSCO_DOWNLOAD_PATH"] = os.environ["BUSCO_DOWNLOAD_PATH"] + augustus_species = { "pea_aphid": { diff --git a/funannotate2/utilities.py b/funannotate2/utilities.py index b4a9d54..8f3c1b4 100755 --- a/funannotate2/utilities.py +++ b/funannotate2/utilities.py @@ -162,9 +162,10 @@ def get_odb_version(downloads_json_file): def ensure_busco_lineage(species, logger): """ Ensure the BUSCO lineage `_` is present under - FUNANNOTATE2_DB, downloading and extracting it from the URL in - downloads.json if missing. The check is a no-op when the directory - already exists, so callers can invoke this idempotently. + BUSCO_DOWNLOAD_PATH, falling back to FUNANNOTATE2_DB if not, downloading + and extracting it from the URL in downloads.json if missing. The check + is a no-op when the directory already exists, so callers can invoke this + idempotently. Parameters: - species (str): BUSCO lineage species name (e.g. "fungi", "aspergillus"). @@ -179,21 +180,26 @@ def ensure_busco_lineage(species, logger): """ downloads_json = os.path.join(os.path.dirname(__file__), "downloads_v2.json") odb_version = get_odb_version(downloads_json) - busco_model_path = os.path.join( - env["FUNANNOTATE2_DB"], f"{species}_{odb_version}" - ) + + if "BUSCO_DOWNLOAD_PATH" in env: + busco_dir_path = env["BUSCO_DOWNLOAD_PATH"] + else: + busco_dir_path = env["FUNANNOTATE2_DB"] + busco_model_path = os.path.join(busco_dir_path, + f"{species}_{odb_version}" + ) if os.path.isdir(busco_model_path): return busco_model_path download_urls = load_json(downloads_json) busco_url = download_urls["busco"][species][0] - busco_tgz = os.path.join(env["FUNANNOTATE2_DB"], os.path.basename(busco_url)) + busco_tgz = os.path.join(busco_dir_path, os.path.basename(busco_url)) logger.info(f"Downloading {species}_{odb_version} model from {busco_url}") download(busco_url, busco_tgz, wget=False) if os.path.isfile(busco_tgz): runSubprocess( ["tar", "-zxf", os.path.basename(busco_tgz)], logger, - cwd=env["FUNANNOTATE2_DB"], + cwd=busco_dir_path, ) if os.path.isdir(busco_model_path): os.remove(busco_tgz)