aboutsummaryrefslogtreecommitdiff
path: root/tools/platypus-callVariants.nix
blob: 59a224bd379c42f7a81609ecb5f6f0795c29809e (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
41
42
43
{ bionix
, indexAttrs ? { }
, bamIndexAttrs ? { }
, flags ? null
}:

inputs:

with bionix;
with lib;
with types;


let
  filename = path: last (splitString "/" path);
  getref = matchFiletype "platypus-callVariants" { bam = { ref, ... }: ref; };
  refs = map getref inputs;
  ref = head refs;
in

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

stage {
  name = "platypus";
  buildInputs = with pkgs; [ platypus ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    ln -s ${bionix.samtools.faidx indexAttrs ref} ref.fa.fai
    ${concatMapStringsSep "\n" (p: "ln -s ${p} ${filename p}.bam") inputs}
    ${concatMapStringsSep "\n" (p: "ln -s ${bionix.samtools.index bamIndexAttrs p} ${filename p}.bai") inputs}
    platypus callVariants \
      --nCPU=$NIX_BUILD_CORES \
      --refFile=ref.fa \
      ${optionalString (flags != null) flags} \
      -o $out \
      --bamFiles=${concatMapStringsSep "," (p: "${filename p}.bam") inputs}

    # Remove timestamps from output
    sed -i '/^##fileDate/d' $out
  '';
  passthru.filetype = filetype.vcf { inherit ref; };
  passthru.multicore = true;
}