Skip to content

Commit

Permalink
Merge pull request #38 from RIVM-bioinformatics/bump_shigatyper
Browse files Browse the repository at this point in the history
Bump shigatyper
  • Loading branch information
boasvdp authored Feb 29, 2024
2 parents 9aeb862 + 614db9a commit 58a44f6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ include: "bin/rules/serotype.smk"
include: "bin/rules/serotype_multireports.smk"
include: "bin/rules/16s_extraction.smk"


# @################################################################################
# @#### Finalize pipeline (error/success) #####
# @################################################################################
Expand All @@ -68,6 +67,7 @@ localrules:
all,
aggregate_serotypes,
no_serotyper,
build_seroba_db,


rule all:
Expand Down
14 changes: 5 additions & 9 deletions bin/download_dbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def copy_neisseria_db(self):
).exists():
try:
print(
f"Copying neisseria db from mnt/db/juno to: {characterize_neisseria_capsule_db_dir}"
f"Copying neisseria db from /mnt/db/juno to: {characterize_neisseria_capsule_db_dir}"
)
build = subprocess.run(
[
Expand Down Expand Up @@ -181,7 +181,10 @@ def download_db_serotypefinder(self, version):
return version

def download_db_seroba(self, version, kmersize=71):
"""Function to download the Seroba database if it is not present"""
"""
Function to download the Seroba database if it is not present
Building is done in a Snakemake rule
"""
seroba_db_dir = self.db_dir.joinpath("seroba_db")
if not seroba_db_dir.joinpath("database", "cdhit_cluster").is_file():
print("\x1b[0;33m Downloading Seroba database...\n\033[0;0m")
Expand All @@ -203,14 +206,7 @@ def download_db_seroba(self, version, kmersize=71):
check=True,
timeout=60,
)
build = subprocess.run(
["seroba", "createDBs", "database", kmersize],
cwd=str(seroba_db_dir),
check=True,
timeout=800,
)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as err:
build.kill()
raise err
version = hf.get_commit_git(seroba_db_dir)
return version
Expand Down
18 changes: 17 additions & 1 deletion bin/rules/serotype.smk
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,26 @@ rule ecoli_serotyper:
### Streptococcus pneumoniae serotyper ###


rule build_seroba_db:
output:
temp(OUT + "/audit_trail/seroba_db_built.txt"),
conda:
"../../envs/seroba.yaml"
params:
seroba_db=config["seroba_db"],
kmer_size=config["seroba"]["kmer_size"],
shell:
"""
cd {params.seroba_db}
seroba createDBs database {params.kmer_size}
"""


rule seroba:
input:
r1=lambda wildcards: SAMPLES[wildcards.sample]["R1"],
r2=lambda wildcards: SAMPLES[wildcards.sample]["R2"],
check_db=OUT + "/audit_trail/seroba_db_built.txt",
output:
OUT + "/serotype/{sample}/pred.tsv",
message:
Expand Down Expand Up @@ -199,7 +215,7 @@ rule shigatyper:
CURRENT_DIR=$(pwd)
cd "{params.output_dir}"
shigatyper {input.r1} {input.r2} > "$(basename {output.command_out})" 2> {log}
shigatyper --R1 {input.r1} --R2 {input.r2} | grep -E -A 1 '^sample' > "$(basename {output.command_out})" 2> {log}
if [ -f {wildcards.sample}.csv ]
then
Expand Down
2 changes: 1 addition & 1 deletion envs/shigatyper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ dependencies:
- python=3.8.5
- gsl=2.5
- bcftools=1.9
- shigatyper=1.0.7
- shigatyper=2.0.5

0 comments on commit 58a44f6

Please sign in to comment.