aboutsummaryrefslogtreecommitdiff
path: root/tools/gridss-callVariants.nix
blob: d55db23e9a1f13614f19ecbc63ff7b3c779477b6 (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
{ bionix
, nixpkgs
, blacklist ? null
, bwaIndexAttrs ? {}
, faidxAttrs ? {}
, flags ? null
, config ? null
, heapSize ? "31g"
}:

with nixpkgs;
with lib;
with bionix.types;

inputs:

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

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

stdenv.mkDerivation rec {
  name = "gridss-callVariants";
  buildInputs = [ 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 \
      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}
  '';
}