From 24ee2349c16f159f2627665938fd76d599055a9a Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 22 Nov 2018 10:43:54 +1100 Subject: gridss: fix configure file optional string error --- tools/gridss-annotateVariants.nix | 2 +- tools/gridss-callVariants.nix | 2 +- tools/gridss-collectMetrics.nix | 2 +- tools/gridss-computeSamTags.nix | 2 +- tools/gridss-extractSVReads.nix | 11 ++++++----- tools/gridss-identifyVariants.nix | 10 ++++------ tools/gridss-softClipsToSplitReads.nix | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) (limited to 'tools') diff --git a/tools/gridss-annotateVariants.nix b/tools/gridss-annotateVariants.nix index 33992c4..4422cd6 100644 --- a/tools/gridss-annotateVariants.nix +++ b/tools/gridss-annotateVariants.nix @@ -65,7 +65,7 @@ stdenv.mkDerivation rec { INPUT_VCF=input.vcf \ OUTPUT_VCF=out.vcf \ WORKING_DIR=$TMPDIR/ \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ TMP_DIR=$TMPDIR/ mv out.vcf $out diff --git a/tools/gridss-callVariants.nix b/tools/gridss-callVariants.nix index dc978fa..9afaf65 100644 --- a/tools/gridss-callVariants.nix +++ b/tools/gridss-callVariants.nix @@ -42,7 +42,7 @@ stdenv.mkDerivation rec { WORKER_THREADS=$NIX_BUILD_CORES \ TMP_DIR=. \ WORKING_DIR=. \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ REFERENCE_SEQUENCE="ref.fa" \ ${concatMapStringsSep " " (i: "INPUT=\"${i}\"") inputs} \ OUTPUT="$out/gridss.vcf" \ diff --git a/tools/gridss-collectMetrics.nix b/tools/gridss-collectMetrics.nix index c1909f1..38bacc6 100644 --- a/tools/gridss-collectMetrics.nix +++ b/tools/gridss-collectMetrics.nix @@ -23,7 +23,7 @@ stdenv.mkDerivation rec { mkdir $out java -Xmx1G -cp ${bionix.gridss.jar} \ gridss.analysis.CollectGridssMetrics \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ I=${input}\ O=$out/input \ AS=true \ diff --git a/tools/gridss-computeSamTags.nix b/tools/gridss-computeSamTags.nix index 5b19a3a..ebcc5b8 100644 --- a/tools/gridss-computeSamTags.nix +++ b/tools/gridss-computeSamTags.nix @@ -35,7 +35,7 @@ stdenv.mkDerivation rec { REFERENCE_SEQUENCE=ref.fa \ WORKING_DIR=$TMP_DIR \ TMP_DIR=$TMP_DIR \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ I=${input} \ O=$out \ AS=true diff --git a/tools/gridss-extractSVReads.nix b/tools/gridss-extractSVReads.nix index e3ed1cc..b5ceffb 100644 --- a/tools/gridss-extractSVReads.nix +++ b/tools/gridss-extractSVReads.nix @@ -27,16 +27,17 @@ stdenv.mkDerivation rec { 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 - mkdir $out + 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/input.sv.bam \ - METRICS_OUTPUT=$out/input.sv_metrics \ - INSERT_SIZE_METRICS=$out/input.insert_size_metrics \ + O=$out \ UNMAPPED_READS=${if unmappedReads then "true" else "false"} \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ MIN_CLIP_LENGTH=${toString minClipLength} ''; + passthru.filetype = input.filetype; } diff --git a/tools/gridss-identifyVariants.nix b/tools/gridss-identifyVariants.nix index 16982e2..c91de00 100644 --- a/tools/gridss-identifyVariants.nix +++ b/tools/gridss-identifyVariants.nix @@ -42,26 +42,24 @@ assert (homoRef); stdenv.mkDerivation rec { name = "gridss-identifyVariants"; - buildInputs = [ jre ]; + buildInputs = [ jre samtools ]; 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 extractSVReads extractSVReadsAttrs) inputs} + ${concatMapStringsSep "\n" (linkSV) inputs} + ${linkSV assembly} ${concatMapStringsSep "\n" (linkInput collectMetrics collectMetricsAttrs) inputs} ${linkInput collectMetrics collectMetricsAttrs assembly} - ASSBASE=$(basename ${assembly}) - ln -s ${assembly} $ASSBASE.gridss.working/$ASSBASE.sv.bam - ln -s ${bionix.samtools.index {} assembly} $ASSBASE.gridss.working/$ASSBASE.sv.bai java -Xmx4g -Dsamjdk.create_index=true \ -cp ${jar} gridss.IdentifyVariants \ REFERENCE_SEQUENCE=ref.fa \ ${concatMapStringsSep " " (i: "INPUT='${i}'") inputs} \ ASSEMBLY=${assembly} \ OUTPUT_VCF=out.vcf \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + gridssConfig config)} \ WORKING_DIR=$TMPDIR/ \ TMP_DIR=$TMPDIR/ diff --git a/tools/gridss-softClipsToSplitReads.nix b/tools/gridss-softClipsToSplitReads.nix index 5fce894..1f9c8b4 100644 --- a/tools/gridss-softClipsToSplitReads.nix +++ b/tools/gridss-softClipsToSplitReads.nix @@ -34,8 +34,8 @@ stdenv.mkDerivation rec { I=${input} \ O=$out \ ${optionalString alignerStreaming "ALIGNER_STREAMING=true"} \ - ${optionalString config ("CONFIGURATION_FILE=" + gridssConfig config)} \ + ${optionalString (config != null) ("CONFIGURATION_FILE=" + bionix.gridss.gridssConfig config)} \ WORKER_THREADS=$NIX_BUILD_CORES ''; - passthru.filetype = filetype.bam { ref = ref; sort = sorting.none {}; } + passthru.filetype = filetype.bam { ref = ref; sorting = matchFileSorting "grids-softClipsToSplitReads" { coord = _: input.sorting; name = _: sort.none {}; none = _: input.sorting;} input;}; } -- cgit v1.2.3 From 98e79735080b379e9a674a69771707951bbdc1ac Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 22 Nov 2018 10:44:16 +1100 Subject: samtools-sort: handle missing 'none' sorting case --- tools/samtools-sort.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/samtools-sort.nix b/tools/samtools-sort.nix index 5a02dab..e77f3db 100644 --- a/tools/samtools-sort.nix +++ b/tools/samtools-sort.nix @@ -19,7 +19,7 @@ assert (matchFiletype "samtools-sort" { bam = _: true; sam = _: true; cram = _: let outfmtR = if outfmt != null then outfmt input else input.filetype; outFmtFlags = matchFiletype "samtools-sort-outfmt" { bam = _: "-O BAM"; sam = _: "-O SAM"; cram = ref: "-O CRAM -T ${ref}"; } {filetype = outfmtR;}; - alreadySorted = matchFileSorting "samtools-sort" { name = _: nameSort; coord = _: !nameSort; } input; + alreadySorted = matchFileSorting "samtools-sort" { name = _: nameSort; coord = _: !nameSort; none = _: false;} input; in stdenv.mkDerivation { name = "samtools-sort"; buildInputs = [ samtools ]; -- cgit v1.2.3 From 0ade062d2da8a7111b14aa3d72ef7c741e98352d Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 22 Nov 2018 10:44:31 +1100 Subject: gridss: restructure gridss pipeline --- tools/gridss-annotateVariants.nix | 18 +++++++++++++----- tools/gridss-assemble.nix | 7 +++---- tools/gridss-extractSVReads.nix | 1 + tools/gridss-identifyVariants.nix | 12 +++++++++++- tools/gridss-softClipsToSplitReads.nix | 2 -- tools/gridss.nix | 4 ++-- 6 files changed, 30 insertions(+), 14 deletions(-) (limited to 'tools') diff --git a/tools/gridss-annotateVariants.nix b/tools/gridss-annotateVariants.nix index 4422cd6..cae5daf 100644 --- a/tools/gridss-annotateVariants.nix +++ b/tools/gridss-annotateVariants.nix @@ -2,8 +2,8 @@ , nixpkgs , bwaIndexAttrs ? {} , faidxAttrs ? {} +, indexAttrs ? {} , assemblyAttrs ? {} -, extractSVReadsAttrs ? {} , collectMetricsAttrs ? {} , softClipsToSplitReadsAttrs ? {} , identifyVariantsAttrs ? {} @@ -35,6 +35,16 @@ let done ''; + linkSV = input: '' + BASENAME=$(basename ${input}) + WRKDIR="''${BASENAME}.gridss.working" + if [[ ! -e $WRKDIR ]] ; then + mkdir $WRKDIR + fi + ln -s ${input} $WRKDIR/$BASENAME.sv.bam + ln -s ${bionix.samtools.index indexAttrs input} $WRKDIR/$BASENAME.sv.bai + ''; + assembly = bionix.samtools.sort {} (softClipsToSplitReads softClipsToSplitReadsAttrs (bionix.samtools.sort { nameSort = true;} (bionix.gridss.assemble assemblyAttrs inputs))); in @@ -50,12 +60,10 @@ stdenv.mkDerivation rec { for f in ${bionix.bwa.index bwaIndexAttrs ref}/*; do ln -s $f done - ${concatMapStringsSep "\n" (linkInput extractSVReads extractSVReadsAttrs) inputs} + ${concatMapStringsSep "\n" (linkSV) inputs} + ${linkSV assembly} ${concatMapStringsSep "\n" (linkInput collectMetrics collectMetricsAttrs) inputs} ${linkInput collectMetrics collectMetricsAttrs assembly} - ASSBASE=$(basename ${assembly}) - ln -s ${assembly} $ASSBASE.gridss.working/$ASSBASE.sv.bam - ln -s ${bionix.samtools.index {} assembly} $ASSBASE.gridss.working/$ASSBASE.sv.bai ln -s ${identifyVariants identifyVariantsAttrs inputs} input.vcf java -Xmx4g -Dsamjdk.create_index=true \ -cp ${jar} gridss.AnnotateVariants \ diff --git a/tools/gridss-assemble.nix b/tools/gridss-assemble.nix index cdda748..1bda91f 100644 --- a/tools/gridss-assemble.nix +++ b/tools/gridss-assemble.nix @@ -2,8 +2,8 @@ , nixpkgs , bwaIndexAttrs ? {} , faidxAttrs ? {} +, indexAttrs ? {} , collectMetricsAttrs ? {} -, extractSVReadsAttrs ? {} , flags ? null }: @@ -23,9 +23,8 @@ let 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 + ln -s ${input} $WRKDIR/$BASENAME.sv.bam + ln -s ${bionix.samtools.index indexAttrs input} $WRKDIR/$BASENAME.sv.bai for f in ${bionix.gridss.collectMetrics collectMetricsAttrs input}/* ; do ln -s $f $WRKDIR/$BASENAME.''${f#*.} done diff --git a/tools/gridss-extractSVReads.nix b/tools/gridss-extractSVReads.nix index b5ceffb..d260086 100644 --- a/tools/gridss-extractSVReads.nix +++ b/tools/gridss-extractSVReads.nix @@ -5,6 +5,7 @@ , flags ? null , unmappedReads ? false , minClipLength ? 5 +, collectMetricsAttrs ? {} , config ? null }: diff --git a/tools/gridss-identifyVariants.nix b/tools/gridss-identifyVariants.nix index c91de00..d37e7ae 100644 --- a/tools/gridss-identifyVariants.nix +++ b/tools/gridss-identifyVariants.nix @@ -2,8 +2,8 @@ , nixpkgs , bwaIndexAttrs ? {} , faidxAttrs ? {} +, indexAttrs ? {} , assemblyAttrs ? {} -, extractSVReadsAttrs ? {} , collectMetricsAttrs ? {} , softClipsToSplitReadsAttrs ? {} , flags ? null @@ -34,6 +34,16 @@ let done ''; + linkSV = input: '' + BASENAME=$(basename ${input}) + WRKDIR="''${BASENAME}.gridss.working" + if [[ ! -e $WRKDIR ]] ; then + mkdir $WRKDIR + fi + ln -s ${input} $WRKDIR/$BASENAME.sv.bam + ln -s ${bionix.samtools.index indexAttrs input} $WRKDIR/$BASENAME.sv.bai + ''; + assembly = bionix.samtools.sort {} (softClipsToSplitReads softClipsToSplitReadsAttrs (bionix.samtools.sort { nameSort = true;} (bionix.gridss.assemble assemblyAttrs inputs))); in diff --git a/tools/gridss-softClipsToSplitReads.nix b/tools/gridss-softClipsToSplitReads.nix index 1f9c8b4..2fff15c 100644 --- a/tools/gridss-softClipsToSplitReads.nix +++ b/tools/gridss-softClipsToSplitReads.nix @@ -17,8 +17,6 @@ let ref = matchFiletype "gridss-softClipsToSplitReads" { bam = x: x.ref; } input; in -assert (matchFileSorting "gridss-softClipsToSplitReads" { name = _: true; } input); - stdenv.mkDerivation rec { name = "gridss-softClipsToSplitReads"; buildInputs = [ jre bwa ]; diff --git a/tools/gridss.nix b/tools/gridss.nix index 1e4e2d1..b85e84e 100644 --- a/tools/gridss.nix +++ b/tools/gridss.nix @@ -17,6 +17,6 @@ rec { assemble = callBionix ./gridss-assemble.nix; identifyVariants = callBionix ./gridss-identifyVariants.nix; annotateVariants = callBionix ./gridss-annotateVariants.nix; - preprocessBam = input: with samtools; markdup {} (sort {} (fixmate {mateScore = true;} (bionix.gridss.softClipsToSplitReads {} (bionix.gridss.computeSamTags {} (sort {nameSort = true;} input))))); - call = inputs: bionix.gridss.annotateVariants {} (map bionix.gridss.preprocessBam inputs); + preprocessBam = input: with samtools; sort {} (gridss.softClipsToSplitReads {} (gridss.computeSamTags {} (sort {nameSort = true;} (gridss.extractSVReads {} (markdup {} (sort {} (fixmate {mateScore = true;} (sort {nameSort = true;} input)))))))); + call = inputs: bionix.gridss.annotateVariants {} (map gridss.preprocessBam inputs); } -- cgit v1.2.3