aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2021-10-29 15:27:22 +1100
committerJustin Bedo <cu@cua0.org>2021-10-29 15:27:22 +1100
commitab809b8c77efdad9fb54d3591a0193a1cbe888d1 (patch)
tree1917bb1bbe41e38f8dbcb893e4ac9aef92b5d903
parentdf7865ba6ca25b35bdc48e4ea9a2f0249f52cccf (diff)
octopus: write region lists to region files
-rw-r--r--tools/octopus-call.nix29
-rw-r--r--tools/octopus-callSomatic.nix31
2 files changed, 46 insertions, 14 deletions
diff --git a/tools/octopus-call.nix b/tools/octopus-call.nix
index f33d87c..80092e0 100644
--- a/tools/octopus-call.nix
+++ b/tools/octopus-call.nix
@@ -3,9 +3,10 @@
, very-fast ? false
, max-genotypes ? null
, targets ? null
-, faidxAttrs ? {}
-, indexAttrs ? {}
-, flags ? ""}:
+, faidxAttrs ? { }
+, indexAttrs ? { }
+, flags ? ""
+}:
assert !fast || !very-fast;
assert max-genotypes == null || max-genotypes > 0;
@@ -17,10 +18,26 @@ with types;
inputs:
let
- getref = f: matchFiletype "octopus-call" { bam = {ref, ...}: ref; cram = {ref, ...}: ref;} f;
+ getref = f: matchFiletype "octopus-call" { bam = { ref, ... }: ref; cram = { ref, ... }: ref; } f;
refs = map getref inputs;
ref = head refs;
+
+ handleTarget = x:
+ let
+ type = builtins.typeOf x;
+ handler = handlers."${type}" or (builtins.throw "octopus-callSomatic:unhandled target type:${type}");
+ handlers = {
+ string = "-T '${x}'";
+ list =
+ let file = pkgs.writeText "regions.txt" (concatStringsSep "\n" x);
+ in "-t ${file}";
+ path = "-t ${x}";
+ };
+ in
+ handler;
+
+
in
assert (length (unique refs) == 1);
@@ -43,9 +60,9 @@ stage {
${optionalString fast "--fast"} \
${optionalString very-fast "--very-fast"} \
${optionalString (max-genotypes != null) "--max-genotypes ${toString max-genotypes}"} \
- ${optionalString (targets != null) (if builtins.typeOf targets == "list" then "-T ${concatStringsSep "," targets}" else "-t ${targets}")} \
+ ${optionalString (targets != null) (handleTarget targets)} \
${flags}
'';
- passthru.filetype = filetype.vcf {ref = ref;};
+ passthru.filetype = filetype.vcf { ref = ref; };
passthru.multicore = true;
}
diff --git a/tools/octopus-callSomatic.nix b/tools/octopus-callSomatic.nix
index d3e7f96..401eeb8 100644
--- a/tools/octopus-callSomatic.nix
+++ b/tools/octopus-callSomatic.nix
@@ -3,9 +3,10 @@
, very-fast ? false
, max-genotypes ? null
, targets ? null
-, faidxAttrs ? {}
-, indexAttrs ? {}
-, flags ? ""}:
+, faidxAttrs ? { }
+, indexAttrs ? { }
+, flags ? ""
+}:
assert !fast || !very-fast;
assert max-genotypes == null || max-genotypes > 0;
@@ -14,7 +15,7 @@ with bionix;
with lib;
with types;
-{normal, tumours}:
+{ normal, tumours }:
let
smScript = pkgs.writeText "smScript.awk" ''
@@ -29,11 +30,25 @@ let
}
'';
- inputs = [normal] ++ tumours;
- getref = f: matchFiletype "octopus-callSomatic" { bam = {ref, ...}: ref; cram = {ref, ...}: ref;} f;
+ inputs = [ normal ] ++ tumours;
+ getref = f: matchFiletype "octopus-callSomatic" { bam = { ref, ... }: ref; cram = { ref, ... }: ref; } f;
refs = map getref inputs;
ref = head refs;
+ handleTarget = x:
+ let
+ type = builtins.typeOf x;
+ handler = handlers."${type}" or (builtins.throw "octopus-callSomatic:unhandled target type:${type}");
+ handlers = {
+ string = "-T '${x}'";
+ list =
+ let file = pkgs.writeText "regions.txt" (concatStringsSep "\n" x);
+ in "-t ${file}";
+ path = "-t ${x}";
+ };
+ in
+ handler;
+
in
assert (length (unique refs) == 1);
@@ -58,10 +73,10 @@ stage {
${optionalString fast "--fast"} \
${optionalString very-fast "--very-fast"} \
${optionalString (max-genotypes != null) "--max-genotypes ${toString max-genotypes}"} \
- ${optionalString (targets != null) (if builtins.typeOf targets == "list" then "-T ${concatStringsSep "," targets}" else "-t ${targets}")} \
+ ${optionalString (targets != null) (handleTarget targets)} \
-N $normal \
${flags}
'';
- passthru.filetype = filetype.vcf {ref = ref;};
+ passthru.filetype = filetype.vcf { ref = ref; };
passthru.multicore = true;
}