aboutsummaryrefslogtreecommitdiff
path: root/tools/gridss-callVariants.nix
blob: f42e3f30978d86fdd8999bc4fa1de5f18a72003c (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ bionix
, blacklist ? null
, bwaIndexAttrs ? {}
, faidxAttrs ? {}
, flags ? null
, config ? null
, heapSize ? "31g"
}:

with bionix;
with lib;
with types;

inputs:

let
  getref = matchFiletype "gridss-callVariants" { bam = x: x.ref; };
  refs = map getref inputs;
  ref = head refs;
in

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

stage rec {
  name = "gridss-callVariants";
  buildInputs = with pkgs; [ jre R bwa ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    ln -s ${bionix.samtools.faidx faidxAttrs ref} ref.fa.fai
    for f in ${bionix.bwa.index bwaIndexAttrs ref}/*; do
      ln -s $f
    done
    mkdir $out
    java -ea -Xmx${heapSize} \
	    -Dreference_fasta="ref.fa" \
	    -Dsamjdk.create_index=true \
	    -Dsamjdk.use_async_io_read_samtools=true \
	    -Dsamjdk.use_async_io_write_samtools=true \
	    -Dsamjdk.use_async_io_write_tribble=true \
	    -Dgridss.gridss.output_to_temp_file=true \
	    -cp ${bionix.gridss.jar} gridss.CallVariants \
      VERBOSITY=WARNING \
      WORKER_THREADS=$NIX_BUILD_CORES \
	    TMP_DIR=. \
	    WORKING_DIR=. \
      ${optionalString (config != null) ("OPTIONS_FILE=" + bionix.gridss.gridssConfig config)} \
	    REFERENCE_SEQUENCE="ref.fa" \
      ${concatMapStringsSep " " (i: "INPUT=\"${i}\"") inputs} \
	    OUTPUT="$out/gridss.vcf" \
	    ASSEMBLY="$out/gridss.bam" \
      ${optionalString (blacklist != null) ("BLACKLIST=" + blacklist)} \
      ${optionalString (flags != null) flags}

    # The VCF index is non-deterministic
    rm $out/gridss.vcf.idx
  '';
  passthru.multicore = true;
}