aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix1
-rw-r--r--test-tnpair.nix4
-rw-r--r--tools/octopus-call.nix37
-rw-r--r--tools/octopus-callSomatic.nix53
-rw-r--r--tools/octopus.nix8
5 files changed, 103 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 9bc7b6c..3077470 100644
--- a/default.nix
+++ b/default.nix
@@ -36,6 +36,7 @@ let
strelka = callBionix ./tools/strelka.nix {};
ascat = callBionix ./tools/ascat.nix {};
fastp = callBionix ./tools/fastp.nix {};
+ octopus = callBionix ./tools/octopus.nix {};
slurm = attrs: bionix.extend (self: super: with self; rec {
slurmDefs = { ppn = 1; mem = 1; walltime = "24:00:00"; partition = null; slurmFlags = null; salloc = "/usr/bin/salloc"; srun = "/usr/bin/srun"; } // attrs;
diff --git a/test-tnpair.nix b/test-tnpair.nix
index 76fcfab..f90e3a9 100644
--- a/test-tnpair.nix
+++ b/test-tnpair.nix
@@ -37,8 +37,10 @@ let
processPair = { tumour, normal }: rec {
alignments = mapAttrs (_: x: markdup (sort (fixmate (alignWithRG x.name x.files)))) { inherit normal tumour; };
variants = callVariants alignments;
+ octopusSomatic = octopus.callSomatic {} {inherit (alignments) normal; tumours = [ alignments.tumour ];};
glvariants = strelka.call {} (builtins.attrValues alignments);
platypusVars = platypus.call {} (builtins.attrValues alignments);
+ octopusVars = octopus.call {} (builtins.attrValues alignments);
shards = pipe [
(shard.fastQPair 2)
(map (bwa.align {inherit ref;}))
@@ -56,6 +58,8 @@ let
(ln (facets.callCNV {} {vcf = tnpairResult.platypusVars; bams = with tnpairResult.alignments; [ normal tumour ];}) "facets")
(ln cnvkitResults.cnvs "cnvkit")
(ln cnvkitResults.plot "cnvkit.pdf")
+ (ln tnpairResult.octopusVars "octopus.vcf")
+ (ln tnpairResult.octopusSomatic "octopus-somatic.vcf")
(ln tnpairResult.variants "strelka")
(ln tnpairResult.glvariants "strelka-gl")
(ln tnpairResult.variants.indels "strelka.indels.vcf")
diff --git a/tools/octopus-call.nix b/tools/octopus-call.nix
new file mode 100644
index 0000000..f88960c
--- /dev/null
+++ b/tools/octopus-call.nix
@@ -0,0 +1,37 @@
+{ bionix
+, faidxAttrs ? {}
+, indexAttrs ? {}
+, flags ? ""}:
+
+with bionix;
+with lib;
+with types;
+
+inputs:
+
+let
+ getref = f: matchFiletype "octopus-callSomatic" { bam = {ref, ...}: ref; cram = {ref, ...}: ref;} f;
+ refs = map getref inputs;
+ ref = head refs;
+
+in
+
+assert (length (unique refs) == 1);
+
+stage {
+ name = "octopus-call";
+ buildInputs = with pkgs; [ octopus-caller ];
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ ln -s ${samtools.faidx faidxAttrs ref} ref.fai
+ ${concatMapStringsSep "\n" (i: ''
+ ln -s ${i} $(basename ${i}).bam
+ ln -s ${samtools.index indexAttrs i} $(basename ${i}).bai
+ '') inputs}
+ octopus -R ref.fa -I *.bam -o $out \
+ --threads=$NIX_BUILD_CORES \
+ ${flags}
+ '';
+ passthru.filtype = filetype.vcf {ref = ref;};
+ passthru.multicore = true;
+}
diff --git a/tools/octopus-callSomatic.nix b/tools/octopus-callSomatic.nix
new file mode 100644
index 0000000..e1c7ce6
--- /dev/null
+++ b/tools/octopus-callSomatic.nix
@@ -0,0 +1,53 @@
+{ bionix
+, faidxAttrs ? {}
+, indexAttrs ? {}
+, flags ? ""}:
+
+with bionix;
+with lib;
+with types;
+
+{normal, tumours}:
+
+let
+ smScript = pkgs.writeText "smScript.awk" ''
+ /^@RG/{
+ for(i = 1; i <= NF; i++) {
+ n=split($i, fields, ":")
+ if(n == 2 && fields[1] == "SM"){
+ print fields[2]
+ exit
+ }
+ }
+ }
+ '';
+
+ inputs = [normal] ++ tumours;
+ getref = f: matchFiletype "octopus-callSomatic" { bam = {ref, ...}: ref; cram = {ref, ...}: ref;} f;
+ refs = map getref inputs;
+ ref = head refs;
+
+in
+
+assert (length (unique refs) == 1);
+
+
+stage {
+ name = "octopus-callSomatic";
+ buildInputs = with pkgs; [ octopus-caller samtools ];
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ ln -s ${samtools.faidx faidxAttrs ref} ref.fai
+ ${concatMapStringsSep "\n" (i: ''
+ ln -s ${i} $(basename ${i}).bam
+ ln -s ${samtools.index indexAttrs i} $(basename ${i}).bai
+ '') inputs}
+ normal=$(samtools view -H ${normal} | awk -f ${smScript})
+ octopus -R ref.fa -I *.bam -o $out \
+ --threads=$NIX_BUILD_CORES \
+ -N $normal \
+ ${flags}
+ '';
+ passthru.filetype = filetype.vcf {ref = ref;};
+ passthru.multicore = true;
+}
diff --git a/tools/octopus.nix b/tools/octopus.nix
new file mode 100644
index 0000000..4d0c7f6
--- /dev/null
+++ b/tools/octopus.nix
@@ -0,0 +1,8 @@
+{ bionix }:
+
+with bionix;
+
+{
+ call = callBionixE ./octopus-call.nix;
+ callSomatic = callBionixE ./octopus-callSomatic.nix;
+}