BAMTOOLS FILTER WITH JSON¶
Filters BAM files with JSON-script for filtering parameters and rules. For more information about bamtools see bamtools documentation
URL: https://github.com/pezmaster31/bamtools
Example¶
This wrapper can be used in the following way:
rule bamtools_filter_json:
input:
"{sample}.bam"
output:
"filtered/{sample}.bam"
params:
json="filtering-rules.json",
region="" # optional parameter for defining a specific region, e.g. "chr1:500..chr3:750"
log:
"logs/bamtools/filtered/{sample}.log"
wrapper:
"v1.17.4/bio/bamtools/filter_json"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes¶
A complete usage documentation is available here: https://raw.githubusercontent.com/wiki/pezmaster31/bamtools/Tutorial_Toolkit_BamTools-1.0.pdf
This tool/wrapper does not handle multi threading
Software dependencies¶
bamtools==2.5.1
Input/Output¶
Input:
- bam files (.bam), must be in first position
Output:
- bam file (.bam), must be in first position
Params¶
json
: Path to filter file, json formatted.region
: see documentation for more information about multiple formats.
Authors¶
- Antonie Vietor
Code¶
__author__ = "Antonie Vietor"
__copyright__ = "Copyright 2020, Antonie Vietor"
__email__ = "antonie.v@gmx.de"
__license__ = "MIT"
from snakemake.shell import shell
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
region = snakemake.params.get("region")
region_param = ""
if region and region is not None:
region_param = ' -region "' + region + '"'
shell(
"(bamtools filter"
" -in {snakemake.input[0]}"
" -out {snakemake.output[0]}"
+ region_param
+ " -script {snakemake.params.json}) {log}"
)