aboutsummaryrefslogtreecommitdiff
path: root/tools/gridss-extractSVReads.nix
blob: b50a01c01bc5bc1e11b70fd9779396a1e444d35a (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
{ bionix
, nixpkgs
, dictIndexAttrs ? {}
, faidxAttrs ? {}
, flags ? null
, unmappedReads ? false
, minClipLength ? 5
, collectMetricsAttrs ? {}
, config ? null
}:

with nixpkgs;
with lib;
with bionix.types;

input:

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


stdenv.mkDerivation rec {
  name = "gridss-extractSVReads";
  buildInputs = [ jre R ];
  buildCommand = ''
    ln -s ${ref} ref.fa
    ln -s ${bionix.samtools.faidx faidxAttrs ref} ref.fa.fai
    ln -s ${bionix.samtools.dict dictIndexAttrs ref} ref.fa.dict
    ln -s ${input} input.bam
    for f in ${bionix.gridss.collectMetrics collectMetricsAttrs input}/* ; do
      ln -s $f
    done
    java -Dsamjdk.create_index=true \
      -cp ${bionix.gridss.jar} gridss.ExtractSVReads \
      REFERENCE_SEQUENCE=ref.fa \
      I=input.bam \
      O=$out \
      UNMAPPED_READS=${if unmappedReads then "true" else "false"} \
      ${optionalString (config != null) ("CONFIGURATION_FILE=" + bionix.gridss.gridssConfig config)} \
      MIN_CLIP_LENGTH=${toString minClipLength}
  '';
  passthru.filetype = input.filetype;
}