From 599f37078dbe669106a867845da0caddfa259908 Mon Sep 17 00:00:00 2001 From: William Rowell Date: Wed, 26 Jan 2022 06:40:31 -0800 Subject: [PATCH] feat: added wrapper for seqtk seq subcommand (#202) * added wrapper for seqtk seq subcommand * added test and linted --- bio/seqtk/seq/environment.yaml | 5 +++++ bio/seqtk/seq/meta.yaml | 10 ++++++++++ bio/seqtk/seq/test/Snakefile | 11 +++++++++++ bio/seqtk/seq/test/a.fastq | 4 ++++ bio/seqtk/seq/wrapper.py | 15 +++++++++++++++ test.py | 8 ++++++++ 6 files changed, 53 insertions(+) create mode 100644 bio/seqtk/seq/environment.yaml create mode 100644 bio/seqtk/seq/meta.yaml create mode 100644 bio/seqtk/seq/test/Snakefile create mode 100644 bio/seqtk/seq/test/a.fastq create mode 100644 bio/seqtk/seq/wrapper.py diff --git a/bio/seqtk/seq/environment.yaml b/bio/seqtk/seq/environment.yaml new file mode 100644 index 0000000000..b0be2c88b3 --- /dev/null +++ b/bio/seqtk/seq/environment.yaml @@ -0,0 +1,5 @@ +channels: + - bioconda + - conda-forge +dependencies: + - seqtk ==1.3 diff --git a/bio/seqtk/seq/meta.yaml b/bio/seqtk/seq/meta.yaml new file mode 100644 index 0000000000..6c621f27b1 --- /dev/null +++ b/bio/seqtk/seq/meta.yaml @@ -0,0 +1,10 @@ +name: seqtk-seq +description: | + Common transformations of FASTA/Q using seqtk +url: https://github.com/lh3/seqtk +authors: + - William Rowell +input: + - fastn file (can be gzip compressed) +output: + - fastn file (gzip compressed) diff --git a/bio/seqtk/seq/test/Snakefile b/bio/seqtk/seq/test/Snakefile new file mode 100644 index 0000000000..0bf469a6ce --- /dev/null +++ b/bio/seqtk/seq/test/Snakefile @@ -0,0 +1,11 @@ +rule seqtk_seq_fastq_to_fasta: + input: + "{prefix}.fastq", + output: + "{prefix}.fasta", + log: + "{prefix}.log", + params: + extra="-A", + wrapper: + "master/bio/seqtk/seq" diff --git a/bio/seqtk/seq/test/a.fastq b/bio/seqtk/seq/test/a.fastq new file mode 100644 index 0000000000..42735560ae --- /dev/null +++ b/bio/seqtk/seq/test/a.fastq @@ -0,0 +1,4 @@ +@1 +ACGGCAT ++ +!!!!!!! diff --git a/bio/seqtk/seq/wrapper.py b/bio/seqtk/seq/wrapper.py new file mode 100644 index 0000000000..9ecccfaf2d --- /dev/null +++ b/bio/seqtk/seq/wrapper.py @@ -0,0 +1,15 @@ +"""Snakemake wrapper seqtk seq subcommand""" + +__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("(seqtk seq {extra} {snakemake.input} > {snakemake.output}) {log}") diff --git a/test.py b/test.py index 2c4fa2bd14..bd0fa12950 100644 --- a/test.py +++ b/test.py @@ -605,6 +605,14 @@ def test_shovill(): ) +@skip_if_not_modified +def test_seqtk_seq(): + run( + "bio/seqtk/seq", + ["snakemake", "--cores", "1", "--use-conda", "-F", "a.fasta"], + ) + + @skip_if_not_modified def test_seqtk_mergepe(): run(