diff --git a/.tests/e2e/test_full_run.py b/.tests/e2e/test_full_run.py index bc07c38..fc6bae2 100755 --- a/.tests/e2e/test_full_run.py +++ b/.tests/e2e/test_full_run.py @@ -13,6 +13,9 @@ def setup(tmp_path): blast_db_fp = tmp_path / "blast_db" blast_db_fp.mkdir(parents=True, exist_ok=True) (blast_db_fp / "db.faa").touch() + pharokka_dp_fp = tmp_path / "pharokka_db" + pharokka_dp_fp.mkdir(parents=True, exist_ok=True) + (pharokka_dp_fp / ".installed").touch() phold_db_fp = tmp_path / "phold_db" phold_db_fp.mkdir(parents=True, exist_ok=True) (phold_db_fp / "phold_annots.tsv").touch() @@ -56,6 +59,17 @@ def setup(tmp_path): ] ) + config_str = f"sbx_induceome: {{pharokka_dp: {pharokka_dp_fp}}}" + sp.check_output( + [ + "sunbeam", + "config", + "--modify", + f"{config_str}", + f"{config_fp}", + ] + ) + config_str = f"sbx_induceome: {{phold_db: {phold_db_fp}}}" sp.check_output( [ @@ -87,6 +101,11 @@ def run_sunbeam(setup): "--directory", tmp_path, "-n", + "--include", + "sbx_induceome", + "--include", + "sbx_assembly", + "--show-failed-logs", ], capture_output=True, text=True, diff --git a/README.md b/README.md index f296fa3..5e1be73 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # sbx_induceome -[![Tests](https://github.com/Ulthran/sbx_induceome/actions/workflows/tests.yml/badge.svg)](https://github.com/Ulthran/sbx_induceome/actions/workflows/tests.yml) +[![Tests](https://github.com/sunbeam-labs/sbx_induceome/actions/workflows/tests.yml/badge.svg)](https://github.com/sunbeam-labs/sbx_induceome/actions/workflows/tests.yml) ![Condabot](https://img.shields.io/badge/condabot-active-purple) [![DockerHub](https://img.shields.io/docker/pulls/sunbeamlabs/sbx_induceome)](https://hub.docker.com/repository/docker/sunbeamlabs/sbx_induceome/) @@ -20,6 +20,7 @@ NOTE: sbx_induceome makes a couple assumptions about your reference genomes and - reference_fp: Directory with reference genomes - mapping_fp: Path to the file mapping samples to strains (.csv) - blast_db: Path to the viral blast db (full path including .faa file name) + - pharokka_db: Path to the pharokka db (full path to the directory that will hold db files) - phold_db: Path to the phold db (full path to the directory that will hold the tsv and other db files) - min_width: The sliding window size for peak finding - smoothing_factor: The number of below-threshold sliding windows to tolerate as being part of one peak diff --git a/config.yml b/config.yml index 7b74fd3..a3c80d3 100644 --- a/config.yml +++ b/config.yml @@ -3,6 +3,7 @@ sbx_induceome: reference_fp: /path/to/refs/ mapping_fp: /path/to/mapping.csv blast_db: /path/to/blast/db.faa + pharokka_db: /path/to/pharokka/db/ phold_db: /path/to/phold/db/ min_width: 100 smoothing_factor: 10 \ No newline at end of file diff --git a/sbx_induceome.smk b/sbx_induceome.smk index 4f987f1..7194a48 100644 --- a/sbx_induceome.smk +++ b/sbx_induceome.smk @@ -64,7 +64,7 @@ rule all_induceome: expand(INDUCEOME_FP / "peaks" / "{sample}.csv", sample=SBX_INDUCEOME_SAMPLES), expand(INDUCEOME_FP / "blastx" / "{sample}.btf", sample=SBX_INDUCEOME_SAMPLES), expand( - INDUCEOME_FP / "phold" / "{sample}_compare" / "phold.gbk", + INDUCEOME_FP / "phold" / "{sample}_plot" / "phold.png", sample=SBX_INDUCEOME_SAMPLES, ), @@ -215,20 +215,56 @@ rule induceome_blastx: ### -# PHOLD +# PHAROKKA/PHOLD/PHYNTENY ### -rule induceome_install_phold_database: +rule induceome_install_ph_databases: output: + pharokka=Path(Cfg["sbx_induceome"]["pharokka_db"]) + / "pharokka_db" + / ".installed", annotations=Path(Cfg["sbx_induceome"]["phold_db"]) / "phold_annots.tsv", + benchmark: + BENCHMARK_FP / "induceome_install_ph_databases.tsv" + log: + LOG_FP / "induceome_install_ph_databases.log", + conda: + "envs/sbx_induceome_env.yml" + container: + f"docker://sunbeamlabs/sbx_induceome:{SBX_INDUCEOME_VERSION}" + shell: + """ + echo "Installing pharokka database" > {log} + install_databases.py -o $(dirname {output.pharokka}) >> {log} 2>&1 + touch {output.pharokka} + + echo "Installing phold annotations" >> {log} + phold install --database $(dirname {output.annotations}) >> {log} 2>&1 + """ + + +rule induceome_pharokka: + input: + contigs=ASSEMBLY_FP / "megahit" / "{sample}_asm" / "final.contigs.fa", + pharokka_db=Path(Cfg["sbx_induceome"]["pharokka_db"]) / "pharokka_db", + output: + pharokka_gbk=INDUCEOME_FP / "pharokka" / "{sample}_pharokka.gbk", + benchmark: + BENCHMARK_FP / "induceome_pharokka_{sample}.tsv" + log: + LOG_FP / "induceome_pharokka_{sample}.log", conda: "envs/sbx_induceome_env.yml" container: f"docker://sunbeamlabs/sbx_induceome:{SBX_INDUCEOME_VERSION}" shell: """ - phold install --database $(dirname {output.annotations}) + if [ ! -s {input.contigs} ]; then + touch {output.pharokka_gbk} + else + pharokka run -i {input.contigs} -o $(dirname {output.pharokka_gbk}) --database {input.pharokka_db} --force + fi """ @@ -280,3 +316,22 @@ rule induceome_phold_compare: phold compare -i {input.contigs} --predictions_dir $(dirname {input._3di}) -o $(dirname {output.gbk}) --database $(dirname {input.annotations}) -t 8 --force fi """ + + +rule induceome_phold_plot: + input: + gbk=INDUCEOME_FP / "phold" / "{sample}_compare" / "phold.gbk", + output: + png=INDUCEOME_FP / "phold" / "{sample}_plot" / "phold.png", + benchmark: + BENCHMARK_FP / "induceome_phold_plot_{sample}.tsv" + log: + LOG_FP / "induceome_phold_plot_{sample}.log", + conda: + "envs/sbx_induceome_env.yml" + container: + f"docker://sunbeamlabs/sbx_induceome:{SBX_INDUCEOME_VERSION}" + shell: + """ + phold plot -i {input.gbk} -o $(dirname {output.png}) --force + """