aboutsummaryrefslogtreecommitdiff
path: root/tools/compression.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-10-05 16:16:20 +1000
committerJustin Bedo <cu@cua0.org>2018-10-05 16:19:06 +1000
commit871ef64f3c43199dfa01216ac86db56650c2c8a2 (patch)
tree7053b4533d7306b3fc0eed8f9bc25e8e2abb6d6e /tools/compression.nix
parentdd3666f6a069105e61f8889665cf55eed9a14e51 (diff)
implement types
Diffstat (limited to 'tools/compression.nix')
-rw-r--r--tools/compression.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/compression.nix b/tools/compression.nix
new file mode 100644
index 0000000..aea7e13
--- /dev/null
+++ b/tools/compression.nix
@@ -0,0 +1,58 @@
+{bionix, nixpkgs}:
+
+with nixpkgs;
+with bionix;
+
+{
+ uncompress = f: types.matchFiletype "uncompress" {
+ fa = _: f;
+ fq = _: f;
+ bam = _: f;
+ sam = _: f;
+ cram = _: f;
+ vcf = _: f;
+ bed = _: f;
+ gz = _: types.tagFiletype (types.gunzip f.filetype) (stdenv.mkDerivation {
+ name = "gunzip";
+ buildCommand = "gunzip < ${f} > $out";
+ });
+ bz2 = _: types.tagFiletype (types.bunzip2 f.filetype) (stdenv.mkDerivation {
+ name = "bunzip2";
+ buildCommand = "bunzip2 < ${f} > $out";
+ });
+ } f.filetype;
+
+ gzip = f:
+ let
+ gz = (stdenv.mkDerivation {
+ name = "gzip";
+ buildCommand = "gzip < ${f} > $out";
+ passthru = { filetype = types.filetype.gz f.filetype; };
+ });
+ in types.matchFiletype "compressed" {
+ fa = _: gz;
+ fq = _: gz;
+ bam = _: gz;
+ sam = _: gz;
+ cram = _: gz;
+ vcf = _: gz;
+ bed = _: gz;
+ } f;
+
+ bzip2 = f:
+ let
+ bz2 = (stdenv.mkDerivation {
+ name = "bzip2";
+ buildCommand = "bzip2 < ${f} > $out";
+ passthru = { filetype = types.filetype.bz2 f.filetype; };
+ });
+ in types.matchFiletype "compressed" {
+ fa = _: gz;
+ fq = _: gz;
+ bam = _: gz;
+ sam = _: gz;
+ cram = _: gz;
+ vcf = _: gz;
+ bed = _: gz;
+ } f;
+}