From f361afeab23a4e7b74e0f58bb64b142f6bc3652b Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 2 Jul 2019 16:02:54 +1000 Subject: CNVkit: split into multiple outputs cnvkit: restructure out to link to multioutputs --- test-tnpair.nix | 2 +- tools/cnvkit-batch.nix | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test-tnpair.nix b/test-tnpair.nix index 7fe5750..701748d 100644 --- a/test-tnpair.nix +++ b/test-tnpair.nix @@ -51,7 +51,7 @@ let cnvkitResults = rec { cnvs = cnvkit.callCNV {} (with tnpairResult.alignments; { normals = [ normal ]; tumours = [ tumour ];}); - plot = cnvkit.scatterPlot {} cnvs; + plot = cnvkit.scatterPlot {} cnvs.out1; }; alignments = { diff --git a/tools/cnvkit-batch.nix b/tools/cnvkit-batch.nix index 5160867..113e0c9 100644 --- a/tools/cnvkit-batch.nix +++ b/tools/cnvkit-batch.nix @@ -23,6 +23,7 @@ assert (all sorted (normals ++ tumours)); stage { name = "cnvkit"; buildInputs = with pkgs; [ python3Packages.cnvkit ]; + outputs = [ "out" ] ++ builtins.genList (x: "out${toString (x + 1)}") (length tumours); buildCommand = '' ln -s ${ref} ref.fa ln -s ${samtools.faidx indexAttrs ref} ref.fa.fai @@ -34,8 +35,19 @@ stage { -p $NIX_BUILD_CORES \ -d $TMPDIR \ ${optionalString (flags != null) flags} + + # Copy individual tumour files mkdir $out - cp *.cn{r,s,n} $out + cnt=1 + for f in ${concatStringsSep " " tumours} ; do + output="out$cnt" + mkdir ''${!output} + for g in $(basename $f)*.{cnr,cnn,cns} ; do + cp $g ''${!output}/sample-''${g#*-} + done + cnt=$((cnt+1)) + ln -s ''${!output} $out/$output + done ''; passthru.multicore = true; } -- cgit v1.2.3