aboutsummaryrefslogtreecommitdiff
path: root/tools/bwa-index.nix
blob: 65d9bd5c5c0ccc24b446ba9a9ae1a2e46a8917c4 (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
{ bionix
, flags ? null
, altRegex ? "^>.*_alt$"
}:

ref:

with bionix;
with lib;
with types;

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

stage {
  name = "bwa-index";
  buildInputs = with pkgs; [ bwa ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    bwa index ${optionalString (flags != null) flags} ref.fa
    mkdir $out
    mv ref.fa.* $out
    grep -P '${altRegex}' ref.fa | tr -d '^>' > $out/idxbase.alt || true
  '';
  stripStorePaths = false;
}