aboutsummaryrefslogtreecommitdiff
path: root/tools/fastp-check.nix
blob: be807d64d6cdce1276dd3ca41329d4ad183b5e03 (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 pkgs.lib;
with types;

# Match input file type—how to do .fq and .fq.gz? Does bz2 work?

let
  out =
    stage {
        name = "fastp";
        buildInputs = [ fastp.app ];
        outputs = [ "out" "fastq1" "json" ] ++ (if input2 != null then [ "fastq2" ] else []);
        buildCommand = ''
            mkdir -p $out
            fastp \
                ${optionalString (flags != null) flags} \
                -i ${input1} \
                -o fastq1.fq.gz \
                ${optionalString (input2 != null) ''
                    -I ${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 {})