aboutsummaryrefslogtreecommitdiff
path: root/tools/cnvkit-batch.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2019-01-10 11:47:05 +1100
committerJustin Bedo <cu@cua0.org>2019-01-10 11:47:05 +1100
commit5cb6f6001ea3aefd52ebaf42c1714343d51a8822 (patch)
tree34235ce75e24e5754946813c263ace635e1ea532 /tools/cnvkit-batch.nix
parent1b5e2b206d00967100e4ddf48c48ba0662bb0eb9 (diff)
cnvkit: init
Diffstat (limited to 'tools/cnvkit-batch.nix')
-rw-r--r--tools/cnvkit-batch.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/cnvkit-batch.nix b/tools/cnvkit-batch.nix
new file mode 100644
index 0000000..6b69f1a
--- /dev/null
+++ b/tools/cnvkit-batch.nix
@@ -0,0 +1,41 @@
+{bionix
+,normals ? []
+,targets ? null
+,annotations ? null
+,flags ? null
+,indexAttrs ? {}}:
+
+{normals ? normals, tumours}:
+
+with bionix;
+with lib;
+with types;
+
+let
+ getref = f: matchFiletype "cnvkit-batch" { bam = {ref, ...}: ref; } f;
+ refs = map getref normals ++ map getref tumours;
+ ref = head refs;
+ sorted = matchFileSorting "cnvkit-batch" { coord = _: true; };
+in
+
+assert (length (unique refs) == 1);
+assert (all sorted (normals ++ tumours));
+
+stage {
+ name = "cnvkit";
+ buildInputs = [ cnvkit.app ];
+ buildCommand = ''
+ ln -s ${ref} ref.fa
+ ln -s ${samtools.faidx indexAttrs ref} ref.fa.fai
+ cnvkit.py batch ${concatStringsSep " " tumours} \
+ ${optionalString (normals != []) ("-n " + concatStringsSep " " normals)} \
+ ${optionalString (annotations != null) annotations} \
+ ${if targets != null then "--targets ${targets}" else "-m wgs"} \
+ -f ref.fa \
+ -p $NIX_BUILD_CORES \
+ -d $TMPDIR \
+ ${optionalString (flags != null) flags}
+ mkdir $out
+ cp * $out
+ '';
+}