aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test-tnpair.nix34
-rw-r--r--tools/strelka.nix40
2 files changed, 74 insertions, 0 deletions
diff --git a/test-tnpair.nix b/test-tnpair.nix
new file mode 100644
index 0000000..371ef81
--- /dev/null
+++ b/test-tnpair.nix
@@ -0,0 +1,34 @@
+{pkgs ? import <nixpkgs> {}}:
+
+with pkgs;
+with lib;
+
+let
+ ref = ../bioshake/examples/ref.fa;
+ alignWithRG = rg: callPackage ./tools/bwa.nix { inherit ref; flags = "-R'@RG\\tID:${rg}\\tSM:${rg}'";};
+ sort = callPackage ./tools/samtools-sort.nix { };
+ callVariants = callPackage ./tools/strelka.nix { inherit ref; };
+
+ tnpair = { tumour = {name = "mysample1"; files = {input1 = ./example/sample1-1.fq; input2 = ./example/sample1-2.fq;};};
+ normal = {name = "mysample2"; files = {input1 = ./example/sample2-1.fq; input2 = ./example/sample2-1.fq;};};};
+
+ processPair = { tumour, normal }: rec {
+ alignments = { normal = sort(alignWithRG normal.name normal.files); tumour = sort (alignWithRG tumour.name tumour.files); };
+ variants = callVariants alignments;
+ };
+
+ #results = map processPair tnpairs;
+ tnpairResult = processPair tnpair;
+
+ testNaming = stdenv.mkDerivation {
+ name = "test-naming";
+ buildCommand = ''
+ mkdir $out
+ ln -s ${tnpairResult.variants} $out/strelka
+ mkdir $out/alignments
+ ln -s ${tnpairResult.alignments.tumour} $out/alignments/${tnpair.tumour.name}.bam
+ ln -s ${tnpairResult.alignments.normal} $out/alignments/${tnpair.normal.name}.bam
+ '';
+ };
+
+in testNaming
diff --git a/tools/strelka.nix b/tools/strelka.nix
new file mode 100644
index 0000000..ec7a764
--- /dev/null
+++ b/tools/strelka.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, callPackage
+, lib
+, strelka
+, ref
+, index ? callPackage ./samtools-faidx.nix {}
+, bamIndex ? callPackage ./samtools-index.nix {}
+, flags ? null
+}:
+
+{normal, tumour}:
+
+with lib;
+
+let
+ filename = path: last (splitString "/" path);
+ inputs = [ normal tumour ];
+
+in stdenv.mkDerivation {
+ name = "strelka";
+ buildInputs = [ strelka ];
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ ln -s ${index ref} ref.fa.fai
+ ${concatMapStringsSep "\n" (p: "ln -s ${p} ${filename p}.bam") inputs}
+ ${concatMapStringsSep "\n" (p: "ln -s ${bamIndex p} ${filename p}.bai") inputs}
+
+ configureStrelkaSomaticWorkflow.py \
+ --normalBam ${filename normal}.bam \
+ --tumourBam ${filename tumour}.bam \
+ --ref ref.fa \
+ --runDir $TMPDIR
+
+ ./runWorkflow.py \
+ -m local \
+ -j $NIX_BUILD_CORES
+
+ cp -r results $out
+ '';
+}