Skip to content

Commit

Permalink
feat: added wrapper for using tabix to query an indexed file (#203)
Browse files Browse the repository at this point in the history
* added wrapper for using tabix to query an indexed file

* updated htslib version and added test
  • Loading branch information
williamrowell committed Jan 26, 2022
1 parent 599f370 commit 2bb9131
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bio/tabix/query/environment.yaml
@@ -0,0 +1,5 @@
channels:
- bioconda
- conda-forge
dependencies:
- htslib==1.12
11 changes: 11 additions & 0 deletions bio/tabix/query/meta.yaml
@@ -0,0 +1,11 @@
name: tabix
description: Query given file with tabix.
url: https://github.com/samtools/htslib
authors:
- William Rowell
input:
- Bgzip compressed file (e.g. BED.gz, GFF.gz, or VCF.gz)
- Tabix index file
- Region of interest to retrieve (params.region)
output:
- Uncompressed subset of the input file from the given region
Binary file added bio/tabix/query/test/A.bed.gz
Binary file not shown.
Binary file added bio/tabix/query/test/A.bed.gz.tbi
Binary file not shown.
14 changes: 14 additions & 0 deletions bio/tabix/query/test/Snakefile
@@ -0,0 +1,14 @@
rule tabix:
input:
"{prefix}.bed.gz",
"{prefix}.bed.gz.tbi"
## list the VCF/BCF as the first input
## and the index as the second input
output:
"{prefix}.output.bed"
params:
region = "1"
log:
"logs/tabix/query/{prefix}.log"
wrapper:
"master/bio/tabix/query"
13 changes: 13 additions & 0 deletions bio/tabix/query/wrapper.py
@@ -0,0 +1,13 @@
__author__ = "William Rowell"
__copyright__ = "Copyright 2020, William Rowell"
__email__ = "wrowell@pacb.com"
__license__ = "MIT"

from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

shell(
"tabix {extra} {snakemake.input[0]} {snakemake.params.region} > {snakemake.output} {log}"
)
8 changes: 8 additions & 0 deletions test.py
Expand Up @@ -3732,6 +3732,14 @@ def test_tabix():
)


@skip_if_not_modified
def test_tabix_query():
run(
"bio/tabix/query",
["snakemake", "--cores", "1", "--use-conda", "-F", "A.output.bed"],
)


@skip_if_not_modified
def test_msisensor_scan():
run(
Expand Down

0 comments on commit 2bb9131

Please sign in to comment.