aboutsummaryrefslogtreecommitdiff
path: root/tools/octopus-call.nix
blob: 37a6400ee3f8787c9716a5cb5d68ee87377fcab4 (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
{ bionix
, faidxAttrs ? {}
, indexAttrs ? {}
, flags ? ""}:

with bionix;
with lib;
with types;

inputs:

let
  getref = f: matchFiletype "octopus-call" { bam = {ref, ...}: ref; cram = {ref, ...}: ref;} f;
  refs = map getref inputs;
  ref = head refs;

in

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

stage {
  name = "octopus-call";
  buildInputs = with pkgs; [ octopus-caller ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    ln -s ${samtools.faidx faidxAttrs ref} ref.fai
    ${concatMapStringsSep "\n" (i: ''
      ln -s ${i} $(basename ${i}).bam
      ln -s ${samtools.index indexAttrs i} $(basename ${i}).bai
    '') inputs}
    octopus -R ref.fa -I *.bam -o $out \
      --threads=$NIX_BUILD_CORES \
      ${flags}
  '';
  passthru.filtype = filetype.vcf {ref = ref;};
  passthru.multicore = true;
}