aboutsummaryrefslogtreecommitdiff
path: root/tools/compression.nix
blob: b32d05723ceb2bba5a598445085ddc4075c8a669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{ bionix }:

with bionix;
with types;

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;
      sam = _: f;
      cram = _: f;
      vcf = _: f;
      bed = _: f;
      gz = _: gunzip attrs f;
      bgz = _: gunzip attrs f;
      bz2 = _: bunzip2 attrs f;
    }
    f;

  gzip = attrs: f:
    let gz = gzip attrs f;
    in
    types.matchFiletype "compressed"
      {
        fa = _: gz;
        fq = _: gz;
        bam = _: gz;
        sam = _: gz;
        cram = _: gz;
        vcf = _: gz;
        bed = _: gz;
        gz = _: f;
        bgz = _: f;
        bz2 = _: with compression; gzip { } (uncompress { } f);
      }
      f;

  bgzip = attrs: f:
    let gz = gzip (attrs // { block = true; }) f;
    in
    types.matchFiletype "compressed"
      {
        fa = _: gz;
        fq = _: gz;
        bam = _: gz;
        sam = _: gz;
        cram = _: gz;
        vcf = _: gz;
        bed = _: gz;
        bgz = _: f;
        gz = _: with compression; bgzip { } (uncompress { } f);
        bz2 = _: with compression; bgzip { } (uncompress { } f);
      }
      f;


  bzip2 = attrs: f:
    let bz2 = bzip2 attrs f;
    in
    types.matchFiletype "compressed"
      {
        fa = _: gz;
        fq = _: gz;
        bam = _: gz;
        sam = _: gz;
        cram = _: gz;
        vcf = _: gz;
        bed = _: gz;
        bz2 = _: f;
        bgz = _: with compression; bzip2 { } (uncompress { } f);
        gz = _: with compression; bzip2 { } (uncompress { } f);
      }
      f;
}