aboutsummaryrefslogtreecommitdiff
path: root/tools/bwa-index2.nix
blob: b02d007e0195144d12b37fce89bbba3c28d7bf09 (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-index2";
  buildInputs = with pkgs; [ bionix.bwa.app2 ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    bwa-mem2 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;
}