aboutsummaryrefslogtreecommitdiff
path: root/tools/mutect-call.nix
blob: 52c1e1dfb708670690cdb298df7504c35d388455 (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
, cosmic
, dbsnp
}:

with bionix;
with lib;

let
  inherit (types) matchFiletype;
  getVCFref = matchFiletype "mutect-call" { vcf = { ref }: ref; };
  getBAMref = matchFiletype "mutect-call" { bam = { ref, ... }: ref; };
  refs = map getVCFref [ cosmic dbsnp ];
  ref = head refs;
in

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

{ normal, tumour }:

assert (ref == getBAMref normal && ref == getBAMref tumour);

stage {
  name = "mutect";
  buildInputs = [ bionix.mutect.app ];
  buildCommand = ''
    ln -s ${normal} normal.bam
    ln -s ${tumour} tumour.bam
    ln -s ${dbsnp} dbsnp.vcf
    ln -s ${cosmic} cosmic.vcf
    ln -s ${ref} ref.fa
    ln -s ${bionix.samtools.faidx {} ref} ref.fa.fai
    ln -s ${bionix.samtools.dict {} ref} ref.dict
    mutect --analysis_type MuTect \
      --reference_sequence ref.fa \
      --cosmic cosmic.vcf \
      --dbsnp dbsnp.vcf \
      --input_file:normal normal.bam \
      --input_file:tumour tumour.bam \
      --out $out
  '';
  passthru.filetype = types.filetype.vcf { inherit ref; };
}