diff options
author | Justin Bedo <cu@cua0.org> | 2018-10-29 15:33:53 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2018-10-29 15:36:33 +1100 |
commit | e7cd661d1c5fb4135e3d436e151294e26aef9127 (patch) | |
tree | 71ef7647d15d57bc2db2cf8ec532da794fddb2fa /tools/gridss-assemble.nix | |
parent | 8fb986fd88705fc01be7145b04fa229092c1e69e (diff) |
Split gridss into constituents
Wrap each individual command for GRIDSS so that bionix executed the pipeline
rather than GRIDSS. This patch introduces a "call" function that executed the
whole pipeline in bionix on an arbitrary BAM file.
Resolves #10.
Diffstat (limited to 'tools/gridss-assemble.nix')
-rw-r--r-- | tools/gridss-assemble.nix | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/gridss-assemble.nix b/tools/gridss-assemble.nix new file mode 100644 index 0000000..cdda748 --- /dev/null +++ b/tools/gridss-assemble.nix @@ -0,0 +1,58 @@ +{ bionix +, nixpkgs +, bwaIndexAttrs ? {} +, faidxAttrs ? {} +, collectMetricsAttrs ? {} +, extractSVReadsAttrs ? {} +, flags ? null +}: + +with nixpkgs; +with lib; +with bionix.types; + +inputs: + +let + getref = matchFiletype "gridss-assemble" { bam = x: x.ref; }; + ref = getref (head inputs); + sorted = matchFileSorting "gridss-assemble" { coord = _: true; }; + homoRef = length (unique (map getref inputs)) == 1; + + linkInput = input: '' + BASENAME=$(basename ${input}) + WRKDIR="''${BASENAME}.gridss.working" + mkdir $WRKDIR + for f in ${bionix.gridss.extractSVReads extractSVReadsAttrs input}/* ; do + ln -s $f $WRKDIR/$BASENAME.''${f#*.} + done + for f in ${bionix.gridss.collectMetrics collectMetricsAttrs input}/* ; do + ln -s $f $WRKDIR/$BASENAME.''${f#*.} + done + ''; +in + +assert (all sorted inputs); +assert (homoRef); + +stdenv.mkDerivation rec { + name = "gridss-assemble"; + buildInputs = [ jre 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 + ${concatMapStringsSep "\n" linkInput inputs} + java -Xmx31g -Dsamjdk.create_index=true \ + -cp ${bionix.gridss.jar} gridss.AssembleBreakends \ + REFERENCE_SEQUENCE=ref.fa \ + ${concatMapStringsSep " " (i: "INPUT='${i}'") inputs} \ + WORKER_THREADS=$NIX_BUILD_CORES \ + OUTPUT=$out \ + WORKING_DIR=$TMPDIR/ \ + TMP_DIR=$TMPDIR/ + ''; + passthru.filetype = filetype.bam { ref = ref; sorting = sort.coord {}; }; +} |