Skip to content

Commit

Permalink
start of code to use csq
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jul 23, 2023
1 parent 9f7d995 commit 338ab8f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/slivarpkg/evaluator.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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] =
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 338ab8f

Please sign in to comment.