diff options
author | Justin Bedo <cu@cua0.org> | 2018-10-05 16:16:20 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2018-10-05 16:19:06 +1000 |
commit | 871ef64f3c43199dfa01216ac86db56650c2c8a2 (patch) | |
tree | 7053b4533d7306b3fc0eed8f9bc25e8e2abb6d6e /tools/samtools-sort.nix | |
parent | dd3666f6a069105e61f8889665cf55eed9a14e51 (diff) |
implement types
Diffstat (limited to 'tools/samtools-sort.nix')
-rw-r--r-- | tools/samtools-sort.nix | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/samtools-sort.nix b/tools/samtools-sort.nix index 2de579e..ab9d603 100644 --- a/tools/samtools-sort.nix +++ b/tools/samtools-sort.nix @@ -2,6 +2,7 @@ , nixpkgs , nameSort ? false , flags ? null +, outfmt ? null }: input: @@ -9,10 +10,20 @@ input: with nixpkgs; with lib; -stdenv.mkDerivation { +let + inherit (bionix.types) matchFiletype coordSort; +in + +assert (matchFiletype "samtools-sort" { bam = _: true; sam = _: true; cram = _: true; } input); + +let + outfmtR = if outfmt != null then outfmt input else input.filetype; + outFmtFlags = matchFiletype "samtools-sort-outfmt" { bam = _: "-O BAM"; sam = _: "-O SAM"; cram = ref: "-O CRAM -T ${ref}"; } {filetype = outfmtR;}; +in stdenv.mkDerivation { name = "samtools-sort"; buildInputs = [ samtools ]; buildCommand = '' - samtools sort -@ $NIX_BUILD_CORES ${optionalString nameSort "-n"} ${optionalString (flags != null) flags} ${input} > $out + samtools sort -@ $NIX_BUILD_CORES ${optionalString nameSort "-n"} ${outFmtFlags} ${optionalString (flags != null) flags} ${input} > $out ''; + passthru.filetype = if nameSort then bionix.types.nameSort outfmtR else coordSort outfmtR; } |