aboutsummaryrefslogtreecommitdiff
path: root/tools/fastp-check.nix
blob: 06f00aee6d300542f81c7a27c4bc72e9ad9eb65d (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
{ bionix
, flags ? null
} :

{ input1
, input2 ? null
} :

with bionix;
with lib;
with types;

let
  fq = f: matchFiletype "fastp-input" { fq = _: f; gz = matchFiletype' "fastp-input" { fq = _: f; }; } f;

  out =
    stage {
        name = "fastp";
        buildInputs = [ pkgs.fastp ];
        outputs = [ "out" "fastq1" "json" ] ++ (if input2 != null then [ "fastq2" ] else []);
        buildCommand = ''
            mkdir -p $out
            fastp \
                ${optionalString (flags != null) flags} \
                -i ${fq input1} \
                -o fastq1.fq.gz \
                ${optionalString (input2 != null) ''
                    -I ${fq input2} \
                    -O fastq2.fq.gz \

                    cp fastq2.fq.gz $fastq2
                ''}

                cp fastq1.fq.gz $fastq1
                cp fastp.html $out
                cp fastp.json $json
        '';
    };
  fqgz = { filetype = filetype.gz (filetype.fastq {}); };
in out // { fastq1 = out.fastq1 // fqgz; } // (if input2 != null then {fastq2 = out.fastq2 // fqgz; } else {})