From 43e1e2b9d80b18705fcc989e89e9f9af51f09f3b Mon Sep 17 00:00:00 2001 From: Maximilian Danielsson Date: Mon, 5 Aug 2024 16:06:12 +0200 Subject: [PATCH] Avoid KeyError --- src/models/discrete_models/codon_models.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/discrete_models/codon_models.jl b/src/models/discrete_models/codon_models.jl index 7cc3d82..081eb5f 100644 --- a/src/models/discrete_models/codon_models.jl +++ b/src/models/discrete_models/codon_models.jl @@ -178,10 +178,10 @@ function count_F3x4(seqs::Array{String}) for k = 1:3 pos1inds = [3 * (i - 1) + k for i = 1:Int(length(seqs[1]) / 3)] d = proportionmap(collect(join([s[pos1inds] for s in seqs]))) - F3x4[k, 1] = d['A'] - F3x4[k, 2] = d['C'] - F3x4[k, 3] = d['G'] - F3x4[k, 4] = d['T'] + F3x4[k, 1] = get(d, 'A', 0.0) + F3x4[k, 2] = get(d, 'C', 0.0) + F3x4[k, 3] = get(d, 'G', 0.0) + F3x4[k, 4] = get(d, 'T', 0.0) end return F3x4 end