From 7b7f7c5eddfb3829cef8df7bf217d8309507cf2d Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 21 May 2019 18:20:24 +1000 Subject: fastp: split outputs and set filetypes --- tools/fastp-check.nix | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/fastp-check.nix b/tools/fastp-check.nix index c7cbb3c..be807d6 100644 --- a/tools/fastp-check.nix +++ b/tools/fastp-check.nix @@ -8,33 +8,33 @@ with bionix; with pkgs.lib; +with types; # Match input file type—how to do .fq and .fq.gz? Does bz2 work? -stage { - name = "fastp"; - buildInputs = [ fastp.app ]; - outputs = [ "out" "fastq1" "fastq2" "html" "json" ]; - buildCommand = '' - mkdir -p $out - fastp \ - ${optionalString (flags != null) flags} \ - -i ${input1} \ - -o fastq1.fq.gz \ - ${optionalString (input2 != null) '' - -I ${input2} \ - -O fastq2.fq.gz \ +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 - ln -s $fastq2 $out/fastq2.fq.gz - ''} + cp fastq2.fq.gz $fastq2 + ''} - cp fastq1.fq.gz $fastq1 - cp fastp.html $html - cp fastp.json $json - - ln -s $fastq1 $out/fastq1.fq.gz - ln -s $html $out/fastp.html - ln -s $json $out/fastp.json - ''; -} \ No newline at end of file + 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 {}) -- cgit v1.2.3 From b714521422af63a910ff660dcc019cbaeb6a5d17 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 21 May 2019 18:23:02 +1000 Subject: fastp: input filetypes --- tools/fastp-check.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/fastp-check.nix b/tools/fastp-check.nix index be807d6..bd522d8 100644 --- a/tools/fastp-check.nix +++ b/tools/fastp-check.nix @@ -7,12 +7,12 @@ } : with bionix; -with pkgs.lib; +with lib; with types; -# Match input file type—how to do .fq and .fq.gz? Does bz2 work? - let + fq = f: matchFiletype "fastp-input" { fq = _: f; gz = matchFiletype' "fastp-input" { fq = _: f; }; } f; + out = stage { name = "fastp"; @@ -22,10 +22,10 @@ let mkdir -p $out fastp \ ${optionalString (flags != null) flags} \ - -i ${input1} \ + -i ${fq input1} \ -o fastq1.fq.gz \ ${optionalString (input2 != null) '' - -I ${input2} \ + -I ${fq input2} \ -O fastq2.fq.gz \ cp fastq2.fq.gz $fastq2 -- cgit v1.2.3 From a7b06b941b30feaf8b3b0e0ad1bc986d58d9f9ac Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 4 Jun 2019 18:53:09 +1000 Subject: strip: handle non-buildCommand based stages --- default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 15b8d87..450118d 100644 --- a/default.nix +++ b/default.nix @@ -77,8 +77,8 @@ let lib = nixpkgs.lib // { types = types; shard = callBionix ./lib/shard.nix {};}; stage = x@{ name, stripStorePaths ? true, multicore ? false, ... }: (if stripStorePaths then strip else x: x) (nixpkgs.stdenvNoCC.mkDerivation (x // {name = "bionix-" + name; inherit multicore;})); - strip = drv: drv.overrideAttrs (attrs: { - buildCommand = attrs.buildCommand + '' + strip = drv: let + stripCommand = '' function rewrite { sed -i 's|/nix/store/[^-]*|/nix/store/00000000000000000000000000000000|g' $1 @@ -96,7 +96,12 @@ let rewriteOutput $o done ''; - }); + in drv.overrideAttrs (attrs: + if attrs ? buildCommand then + {buildCommand = attrs.buildCommand + stripCommand;} + else + { fixupPhase = (if attrs ? fixupPhase then attrs.fixupPhase else "") + stripCommand; } + ); # splitting/joining splitFile = file: drv: stage { -- cgit v1.2.3