aboutsummaryrefslogtreecommitdiff
path: root/tools/lumpy-call.nix
blob: fffc32919163c6c39ce396b5e143a6f3b070b8cc (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ bionix, flags ? "", faidxAttrs ? { }, indexAttrs ? { } }:

inputs:

with bionix;
with lib;
with types;

let
  getref = matchFiletype "lumpy-call" { bam = x: x.ref; };
  refs = map getref inputs;
  ref = head refs;

  renameAndIndex = f:
    stage {
      name = "rename";
      buildCommand = ''
        mkdir $out
        ln -s ${f} $out/sample.bam
        ln -s ${samtools.index indexAttrs f} $out/sample.bam.bai
      '';
    };

in assert (length (unique refs) == 1);

stage {
  name = "lumpy";
  buildInputs = with pkgs; [ lumpy ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    ln -s ${samtools.faidx faidxAttrs ref} ref.fa.fai
    lumpyexpress \
      ${
        concatMapStringsSep " " (i: "-B ${renameAndIndex i}/sample.bam") inputs
      } \
      ${flags} \
      -o $out
  '';
  passthru.filetype = filetype.vcf { ref = ref; };
}