From 338ab8f8f63fe74ac576f5b0c20a0b6f1e312705 Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Sun, 23 Jul 2023 14:27:11 +0200 Subject: [PATCH] start of code to use csq --- src/slivarpkg/evaluator.nim | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/slivarpkg/evaluator.nim b/src/slivarpkg/evaluator.nim index fe5017c..bbce12c 100644 --- a/src/slivarpkg/evaluator.nim +++ b/src/slivarpkg/evaluator.nim @@ -123,6 +123,7 @@ type Evaluator* = ref object info_field_sets: FieldSets[uint16] fmt_field_sets: FieldSets[uint8] + csq_field_sets: FieldSets[uint8] allow_fmt_strings: bool empty: Duko @@ -137,6 +138,8 @@ type Evaluator* = ref object variant: Duko gnos*:seq[Gnotater] + CSQ: Duko + trios: seq[Trio] families: seq[Family] trio_expressions*: seq[CompiledExpression] @@ -421,17 +424,19 @@ proc newEvaluator*(ivcf:VCF, samples: seq[Sample], groups: seq[Group], float_exp stderr.write_line &"[slivar] evaluating on {result.trios.len} trios" else: stderr.write_line &"[slivar] WARNING! specified --trio expressions without any trios" + + let parse_csq = getEnv("SLIVAR_PARSE_CSQ") != "" if strict: result.INFO = result.ctx.newStrictObject("INFO") result.variant = result.ctx.newStrictObject("variant") - #if getEnv("SLIVAR_IMPACT_SET") != "": - # result.info_impact_set = result.INFO.newStrictObject("info_impact_set") + if parse_csq: + result.CSQ = result.ctx.newStrictObject("CSQ") else: result.INFO = result.ctx.newObject("INFO") result.variant = result.ctx.newObject("variant") - #if getEnv("SLIVAR_IMPACT_SET") != "": - # result.info_impact_set = result.INFO.newStrictObject("info_impact_set") + if parse_csq: + result.CSQ = result.ctx.newObject("CSQ") result.set_sample_attributes(by_name) proc id2names*(h:Header): seq[idpair] = @@ -575,6 +580,10 @@ proc clear_unused_infos(ev: Evaluator, f:FieldSets) {.inline.} = var info_warn = 0 +template clear_unused_csqs(ev: Evaluator) = + for idx in ev.csq_field_sets.last.sub(ev.csq_field_sets.curr): + ev.CSQ.del(ev.field_names[idx].name) + proc write_warning(variant:Variant, nerrors: var int) {.inline.} = nerrors.inc if nerrors < 10: @@ -775,6 +784,7 @@ iterator evaluate_groups(ev:Evaluator, nerrors: var int, variant:Variant): exRes elif ev.INFO.hasKey(namedexpr.name): ev.INFO.del(namedexpr.name) + template clear_unused_formats(ev:Evaluator) = #for idx in ev.fmt_field_sets.last - ev.fmt_field_sets.curr: for idx in ev.fmt_field_sets.last.sub(ev.fmt_field_sets.curr):