diff --git a/src/cljam/io/vcf/util/validator.clj b/src/cljam/io/vcf/util/validator.clj index 63747e3a..28138141 100644 --- a/src/cljam/io/vcf/util/validator.clj +++ b/src/cljam/io/vcf/util/validator.clj @@ -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 @@ -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]))) diff --git a/test/cljam/io/vcf/util/validator_test.clj b/test/cljam/io/vcf/util/validator_test.clj index 2ab42436..a8efd04d 100644 --- a/test/cljam/io/vcf/util/validator_test.clj +++ b/test/cljam/io/vcf/util/validator_test.clj @@ -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