Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .tests/e2e/test_full_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# sbx_induceome

<!-- Badges start -->
[![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/)
<!-- Badges end -->
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
63 changes: 59 additions & 4 deletions sbx_induceome.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),

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


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