From 3a5f0e65b97071b5825519b08bf24f03fcb89224 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 17 Jan 2019 09:54:26 +1100 Subject: compression: refactor compression framework --- tools/compression-bunzip2.nix | 12 ++++++++++++ tools/compression-bzip2.nix | 12 ++++++++++++ tools/compression-gunzip.nix | 12 ++++++++++++ tools/compression-gzip.nix | 12 ++++++++++++ tools/compression.nix | 40 +++++++++++++++------------------------- 5 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 tools/compression-bunzip2.nix create mode 100644 tools/compression-bzip2.nix create mode 100644 tools/compression-gunzip.nix create mode 100644 tools/compression-gzip.nix (limited to 'tools') diff --git a/tools/compression-bunzip2.nix b/tools/compression-bunzip2.nix new file mode 100644 index 0000000..06fe682 --- /dev/null +++ b/tools/compression-bunzip2.nix @@ -0,0 +1,12 @@ +{bionix}: + +with bionix; + +input: + +stage { + name = "bunzip2"; + buildInputs = with pkgs; [ bzip2 ]; + buildCommand = "bunzip2 < ${input} > $out"; + passthru.filetype = types.bunzip2 input; +} diff --git a/tools/compression-bzip2.nix b/tools/compression-bzip2.nix new file mode 100644 index 0000000..6dfb749 --- /dev/null +++ b/tools/compression-bzip2.nix @@ -0,0 +1,12 @@ +{bionix}: + +with bionix; + +input: + +stage { + name = "bzip2"; + buildInputs = with pkgs; [ bzip2 ]; + buildCommand = "bzip2 < ${input} > $out"; + passthru.filetype = filetype.bz2 input.filetype; +} diff --git a/tools/compression-gunzip.nix b/tools/compression-gunzip.nix new file mode 100644 index 0000000..6c98f91 --- /dev/null +++ b/tools/compression-gunzip.nix @@ -0,0 +1,12 @@ +{bionix}: + +with bionix; + +input: + +stage { + name = "gunzip"; + buildInputs = with pkgs; [ gzip ]; + buildCommand = "gunzip < ${input} > $out"; + passthru.filetype = types.gunzip input; +} diff --git a/tools/compression-gzip.nix b/tools/compression-gzip.nix new file mode 100644 index 0000000..50fca9e --- /dev/null +++ b/tools/compression-gzip.nix @@ -0,0 +1,12 @@ +{bionix}: + +with bionix; + +input: + +stage { + name = "gzip"; + buildInputs = with pkgs; [ gzip ]; + buildCommand = "gzip < ${input} > $out"; + passthru.filetype = filetype.gzip input.filetype; +} diff --git a/tools/compression.nix b/tools/compression.nix index 6e69d7e..bfcc292 100644 --- a/tools/compression.nix +++ b/tools/compression.nix @@ -1,9 +1,15 @@ {bionix}: with bionix; +with types; -{ - uncompress = f: types.matchFiletype "uncompress" { +let + gzip = callBionixE ./compression-gzip.nix; + gunzip = callBionixE ./compression-gunzip.nix; + bunzip2 = callBionixE ./compression-bunzip2.nix; + +in { + uncompress = attrs: f: matchFiletype "uncompress" { fa = _: f; fq = _: f; bam = _: f; @@ -11,23 +17,12 @@ with bionix; cram = _: f; vcf = _: f; bed = _: f; - gz = _: types.tagFiletype (types.gunzip f.filetype) (stage { - name = "gunzip"; - buildCommand = "gunzip < ${f} > $out"; - }); - bz2 = _: types.tagFiletype (types.bunzip2 f.filetype) (stage { - name = "bunzip2"; - buildCommand = "bunzip2 < ${f} > $out"; - }); - } f.filetype; + gz = _: gunzip attrs f; + bz2 = _: bunzip2 attrs f; + } f; - gzip = f: - let - gz = (stage { - name = "gzip"; - buildCommand = "gzip < ${f} > $out"; - passthru = { filetype = types.filetype.gz f.filetype; }; - }); + gzip = attrs: f: + let gz = gzip attrs f; in types.matchFiletype "compressed" { fa = _: gz; fq = _: gz; @@ -39,13 +34,8 @@ with bionix; gz = x: x; } f; - bzip2 = f: - let - bz2 = (stage { - name = "bzip2"; - buildCommand = "bzip2 < ${f} > $out"; - passthru = { filetype = types.filetype.bz2 f.filetype; }; - }); + bzip2 = attrs: f: + let bz2 = bzip2 attrs f; in types.matchFiletype "compressed" { fa = _: gz; fq = _: gz; -- cgit v1.2.3