Skip to content

Commit

Permalink
feat: added wrapper for bcftools stats (#201)
Browse files Browse the repository at this point in the history
* added wrapper for bcftools stats

* added test case, updated bcftools version

* formatted wrapper with black

* added bcftools stats test case

* updated test output, added log

* corrected name of input in bcftools_stats test wrapper

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
williamrowell and johanneskoester committed Jan 26, 2022
1 parent 6b4d6a1 commit 2caecb9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
5 changes: 5 additions & 0 deletions bio/bcftools/stats/environment.yaml
@@ -0,0 +1,5 @@
channels:
- bioconda
- conda-forge
dependencies:
- bcftools ==1.12
9 changes: 9 additions & 0 deletions bio/bcftools/stats/meta.yaml
@@ -0,0 +1,9 @@
name: bcftools stats
description: Generate VCF stats using bcftools stats.
url: https://github.com/samtools/bcftools
authors:
- William Rowell
input:
- BCF, VCF, or VCF.gz input
output:
- stats text file
11 changes: 11 additions & 0 deletions bio/bcftools/stats/test/Snakefile
@@ -0,0 +1,11 @@
rule bcf_stats:
input:
"{prefix}"
output:
"{prefix}.stats.txt"
log:
"{prefix}.bcftools.stats.log"
params:
""
wrapper:
"master/bio/bcftools/stats"
Binary file added bio/bcftools/stats/test/a.bcf
Binary file not shown.
18 changes: 18 additions & 0 deletions bio/bcftools/stats/wrapper.py
@@ -0,0 +1,18 @@
__author__ = "William Rowell"
__copyright__ = "Copyright 2020, William Rowell"
__email__ = "wrowell@pacb.com"
__license__ = "MIT"


from snakemake.shell import shell

# bcftools takes additional decompression threads through --threads
# Other threads are *additional* threads passed to the '--threads' argument
threads = (
"" if snakemake.threads <= 1 else " --threads {} ".format(snakemake.threads - 1)
)
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

shell(
"bcftools stats {threads} {snakemake.params} {snakemake.input} > {snakemake.output} {log}"
)
6 changes: 3 additions & 3 deletions test.py
Expand Up @@ -781,10 +781,10 @@ def test_bcftools_reheader():


@skip_if_not_modified
def test_bcftools_reheader():
def test_bcftools_stats():
run(
"bio/bcftools/reheader",
["snakemake", "--cores", "1", "a.reheader.bcf", "--use-conda", "-F"],
"bio/bcftools/stats",
["snakemake", "--cores", "1", "a.bcf.stats.txt", "--use-conda", "-F"],
)


Expand Down

0 comments on commit 2caecb9

Please sign in to comment.