From 92b4ea2ddac572f8bd830858132956829d92a734 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Wed, 24 Oct 2018 16:35:52 +1100 Subject: Simplify types for sorting --- lib/types.nix | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/types.nix') 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; }; -- cgit v1.2.3