diff options
author | Justin Bedo <cu@cua0.org> | 2018-10-24 16:35:52 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2018-10-25 07:26:48 +1100 |
commit | 92b4ea2ddac572f8bd830858132956829d92a734 (patch) | |
tree | a455e9f8737bcfd437063c1cb0fb498a3e309918 /lib | |
parent | 7daac8bb4bd0d705662c18b677a69d3785f4d8f8 (diff) |
Simplify types for sorting
Diffstat (limited to 'lib')
-rw-r--r-- | lib/types.nix | 17 |
1 files changed, 8 insertions, 9 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; }; |