aboutsummaryrefslogtreecommitdiff
path: root/tools/bwa-index.nix
blob: c879bc4cf8cc13b4f99ea7ca8cbaffc7cad739bf (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
{ bionix
, nixpkgs
, flags ? null
}:

ref:

with nixpkgs;
with lib;
with bionix.types;

assert (matchFiletype "bwa-index" { fa = _: true; } ref);

stdenv.mkDerivation {
  name = "bwa-index";
  buildInputs = [ bwa ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    bwa index ${optionalString (flags != null) flags} ref.fa
    mkdir $out
    mv ref.fa.* $out
    grep '^>[^ \t]*_alt$' ref.fa | tr -d '^>' > $out/idxbase.alt || true
  '';
}