From 64f8b0cb124445620b30e10e268fd7670ccb3189 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Fri, 19 Feb 2021 11:18:10 +1100 Subject: samtools-index: support cram indexing --- test-tnpair.nix | 1 + tools/samtools-index.nix | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test-tnpair.nix b/test-tnpair.nix index 70fb5c8..7cc5453 100644 --- a/test-tnpair.nix +++ b/test-tnpair.nix @@ -64,6 +64,7 @@ let }; testNaming = linkOutputs { + crai = samtools.index {} (samtools.view { outfmt = types.toCram; } tnpairResult.alignments.tumour); kallisto = kallisto.quant {inherit ref;} (attrValues tnpair.tumour.files); facets = facets.callCNV {} {vcf = tnpairResult.platypusVars; bams = with tnpairResult.alignments; [ normal tumour ];}; cnvkit = cnvkitResults.cnvs; diff --git a/tools/samtools-index.nix b/tools/samtools-index.nix index d0f8d7a..62ee4c9 100644 --- a/tools/samtools-index.nix +++ b/tools/samtools-index.nix @@ -8,16 +8,19 @@ with bionix; with lib; with types; -assert (matchFiletype "samtools-index" { bam = _: true; } input); +assert (matchFiletype "samtools-index" { bam = _: true; cram = _: true; } input); assert (matchFileSorting "samtools-index" { coord = _: true; } input); +let + ext = matchFiletype "samtools-index-ext" { bam = _: "bam"; cram = _: "cram"; }; +in + stage { name = "samtools-index"; buildInputs = with pkgs; [ samtools ]; buildCommand = '' - ln -s ${input} input.bam - samtools index -@ $NIX_BUILD_CORES ${optionalString (flags != null) flags} input.bam - cp input.bam.bai $out + ln -s ${input} input.${ext input} + samtools index -@ $NIX_BUILD_CORES ${optionalString (flags != null) flags} input.${ext input} $out ''; passthru.multicore = true; } -- cgit v1.2.3