aboutsummaryrefslogtreecommitdiff
path: root/tools/gridss-collectMetrics.nix
blob: 8b09886c4999b82e659a6fcbb2fa24ac4a09f72c (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
{ bionix
, thresholdCoverage ? 10000
, flags ? null
, config ? null
, heapSize ? "1G"
}:

with bionix;
with lib;
with types;

input:

let
  ref = matchFiletype "gridss-collectMetrics" { bam = x: x.ref; } input;
in


stage rec {
  name = "gridss-collectMetrics";
  buildInputs = with pkgs; [ jre R ];
  buildCommand = ''
    mkdir $out
    java -Xmx${heapSize} -cp ${bionix.gridss.jar} \
      gridss.analysis.CollectGridssMetrics \
      ${optionalString (config != null) ("OPTIONS_FILE=" + bionix.gridss.gridssConfig config)} \
      VERBOSITY=WARNING \
      I=${input}\
      O=$out/input \
      AS=true \
      THRESHOLD_COVERAGE=${toString thresholdCoverage} \
      ${optionalString (flags != null) flags}

    # Make the output deterministic by removing timestamps
    sed -i '/^# Started on:/d' $out/input.*_metrics
    if [ -e $out/input.insert_size_histogram.pdf ] ; then
      sed -i 's/(D:[0-9]\+)/(D:19700101000000)/g' $out/input.insert_size_histogram.pdf
    fi
  '';
}