aboutsummaryrefslogtreecommitdiff
path: root/tools/samtools-index.nix
blob: 6919f976faf41e9515acf3f8d1cb7a1180ad726c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ bionix
, nixpkgs
, flags ? null
}:

input:

with nixpkgs;
with lib;
with bionix.types;

assert (matchFiletype "samtools-index" { bam = _: true; } input);
assert (matchFileSorting "samtools-index" { coord = _: true; } input);

stdenv.mkDerivation {
  name = "samtools-index";
  buildInputs = [ samtools ];
  buildCommand = ''
    ln -s ${input} input.bam
    samtools index -@ $NIX_BUILD_CORES ${optionalString (flags != null) flags} input.bam
    cp input.bam.bai $out
  '';
}