aboutsummaryrefslogtreecommitdiff
path: root/tools/samtools-index.nix
blob: aad46a7a644f9d74dfa336168457e6cd37a48d45 (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 (matchSorting "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
  '';
}