aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-10-24 16:35:52 +1100
committerJustin Bedo <cu@cua0.org>2018-10-25 07:26:48 +1100
commit92b4ea2ddac572f8bd830858132956829d92a734 (patch)
treea455e9f8737bcfd437063c1cb0fb498a3e309918
parent7daac8bb4bd0d705662c18b677a69d3785f4d8f8 (diff)
Simplify types for sorting
-rw-r--r--lib/types.nix17
-rw-r--r--tools/bwa-mem.nix2
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 8dabc4f..2e5adca 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -21,15 +21,13 @@ let
in
rec {
- option-sort = option sorting;
-
matchFiletype = sym: y: x: if x ? filetype then match x.filetype (defError (idft sym) y filetype) else abort "unknown filetype for ${sym}";
filetype = make-type "filetype" {
fa = {};
fq = {};
- bam = {ref = any; sorting = option-sort;};
- sam = {ref = any; sorting = option-sort;};
- cram = {ref = any; sorting = option-sort;};
+ bam = {ref = any; sorting = sort;};
+ sam = {ref = any; sorting = sort;};
+ cram = {ref = any; sorting = sort;};
vcf = {ref = any;};
bed = {ref = any;};
gz = filetype;
@@ -40,13 +38,14 @@ rec {
toBam = matchFiletype "bam2cram" { bam = filetype.bam; sam = filetype.bam; cram = filetype.bam; };
toSam = matchFiletype "bam2cram" { bam = filetype.sam; sam = filetype.sam; cram = filetype.sam; };
- matchSorting = sym: y: let f = x: match x.sorting { some = z: match z (defError (idst sym) y sorting); none = abort "unknown sort for ${sym}"; }; in matchFiletype sym { bam = f; sam = f; cram = f; };
- sorting = make-type "sorting" {
+ matchSorting = sym: y: let f = x: match x.sorting (defError (idst sym) y sort); in matchFiletype sym { bam = f; sam = f; cram = f; };
+ sort = make-type "sort" {
+ none = {};
coord = {};
name = {};
};
- coordSort = f: matchFiletype "coordSort" { bam = x: filetype.bam (x // {sorting = option-sort.some (sorting.coord {});}); } {filetype = f;};
- nameSort = f: matchFiletype "nameSort" { bam = x: filetype.bam (x // {sorting = option-sort.some (sorting.name {});}); } {filetype = f;};
+ coordSort = f: matchFiletype "coordSort" { bam = x: filetype.bam (x // {sorting = sort.coord {};}); } {filetype = f;};
+ nameSort = f: matchFiletype "nameSort" { bam = x: filetype.bam (x // {sorting = sort.name {};}); } {filetype = f;};
gunzip = matchFiletype "gunzip" { gz = x: x; };
bunzip2 = matchFiletype "bunzip2" { bz2 = x: x; };
diff --git a/tools/bwa-mem.nix b/tools/bwa-mem.nix
index 3208e48..eed488e 100644
--- a/tools/bwa-mem.nix
+++ b/tools/bwa-mem.nix
@@ -36,5 +36,5 @@ in stdenv.mkDerivation {
${optionalString bamOutput "| samtools view -b"} \
> $out
'';
- passthru.filetype = if bamOutput then filetype.bam {ref = ref; sorting = option-sort.none;} else filetype.sam {ref = ref; sorting = option-sort.none;};
+ passthru.filetype = if bamOutput then filetype.bam {ref = ref; sorting = sort.none {};} else filetype.sam {ref = ref; sorting = sort.none {};};
}