aboutsummaryrefslogtreecommitdiff
path: root/tools/samtools-merge.nix
blob: eacf520b8a07aeef0ec4c8f2b7ee9972f4952991 (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
{ bionix
, nixpkgs
, flags ? null
, outfmt ? null
}:

inputs:

with nixpkgs;
with lib;

let
  inherit (bionix.types) matchFiletype matchSorting;
  inputIsHomogenous = length (unique (map (matchFiletype "samtools-merge" {bam = x: x // {sorting = matchSorting "samtools-merge" {coord = _: "coord";} x;};}) inputs)) == 1;
in

assert inputIsHomogenous;

stdenv.mkDerivation {
  name = "samtools-merge";
  buildInputs = [ samtools ];
  buildCommand = ''
    samtools merge ${optionalString (flags != null) flags} $out ${concatStringsSep " " inputs}
  '';
  passthru.filetype = (builtins.elemAt inputs 0).filetype;
}