Skip to content

Commit

Permalink
Check number (wip).
Browse files Browse the repository at this point in the history
  • Loading branch information
niyarin committed Jul 3, 2023
1 parent 2537e4c commit 31226a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/cljam/io/vcf/util/validator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@
(constantly false))
entry))

(defn- check-entry [entry {:keys [type number]}]
(defn- check-entry [entry {:keys [type number]} alt-num]
(let [entries (if (and (= number 1) (not (sequential? entry)))
[entry] entry)
type-check (and entry
(not (every? #(check-entry-type
% type) entries)))
number-check (not (or (= number "A")
(not entry)
(= (count entries) number)))]
number' (cond (= number "A") alt-num
:else number)
number-check (not (or (nil? entry)
(= (count entries) number')))]
(when (or type-check number-check)
(cond
type-check
Expand All @@ -74,7 +75,7 @@
[id entry] (get variant sample)
:let [fmt (get mformat id)
res (if fmt
(check-entry entry fmt)
(check-entry entry fmt (count (:alt variant)))
(format "key %s not in meta." id))]
:when res]
[[sample id] res])))
Expand Down
2 changes: 1 addition & 1 deletion test/cljam/io/vcf/util/validator_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{:A {:type "Integer" :number 2}})))
(is (not
(#'validator/check-each-samples
{:normal {:A [1 2]}} [:normal]
{:normal {:A [1 2]} :alt ["A"]} [:normal]
{:A {:type "Integer" :number "A"}})))
(is (string?
(get-in
Expand Down

0 comments on commit 31226a9

Please sign in to comment.