aboutsummaryrefslogtreecommitdiff
path: root/tools/sambamba-generic.nix
blob: a6be65c55716020ca4b60a3825d02086b0c313cb (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
{ bionix
, flags ? null
, tool
, region ? null
}:

input:

with bionix;
with lib;

let
  inherit (bionix.types) matchFiletype coordSort matchFileSorting;
in

assert (matchFiletype "sambamba-${tool}" { bam = _: true; } input);

stage {
  name = "sambamba-${tool}";
  buildInputs = [ pkgs.sambamba ];
  buildCommand = ''
    sambamba ${tool} -t $NIX_BUILD_CORES \
      ${optionalString (flags != null) flags} \
      ${if tool == "merge" then "$out ${concatStringsSep " " input}" else if tool == "slice" then "${input} ${region} > $out" else if tool == "flagstat" then "${input} > $out" else "${input} $out"}
  '';
  passthru.filetype = if tool == "flagstat" || tool == "index" then null else if tool == "merge" then (head input).filetype else input.filetype;
  passthru.multicore = true;
}