NANOFILT

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/nanopack/nanofilt?label=version%20update%20pull%20requests

nanofilt from nanopack.

URL: https://github.com/wdecoster/nanofilt

Example

This wrapper can be used in the following way:


test/Snakefile not found.

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.

Input/Output

Input:

  • fastq: input fastq file. can be gziped.(such as, fastq, fastq.gz, fq, fq.gz).

Output:

  • out: filtered fastq file. same as the input.

Params

  • nanofilt: nanofilt path (optional).

  • min_len: filter on minimum read length (optional).

  • max_len: filter on maximum read length (optional).

  • extras: extra arguments to nanofilt (optional).

Authors

  • yangqun

Code

# nanofilt wrapper
__author__ = "yangqun"

import sys
from snakemake.shell import shell

# arguments
assert 'fastq' in snakemake.input.keys()
assert 'out' in snakemake.output.keys()
fastq = snakemake.input.get('fastq')
out = snakemake.output.get('out')

# optional arguments
min_len = snakemake.params.get('min_len')
max_len = snakemake.params.get('max_len')
extras = snakemake.params.get('extras', '')
nanofilt = snakemake.params.get('nanofilt', "NanoFilt")

extract_cmd = "zcat " + fastq if fastq.endswith('gz') else "cat " + fastq
nanofilt_options = ""
if min_len:
    nanofilt_options += f" -l {min_len}"

if max_len:
    nanofilt_options += f" --maxlength {max_len}"

nanofilt_options += extras

out_cmd = f" | gzip >{out}" if out.endswith('gz') else f" >{out}"

# run
shell(
    "{extract_cmd} | {nanofilt} {nanofilt_options} {out_cmd}"
)