Skip to content

Commit

Permalink
Better formatted error message for ancestral alleles
Browse files Browse the repository at this point in the history
  • Loading branch information
hyanwong committed Jan 20, 2024
1 parent 7db1d38 commit 5e282e4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tsinfer/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2405,11 +2405,16 @@ def sites_ancestral_allele(self):
except IndexError:
unknown_alleles[allele] += 1
ret[i] = allele_index
if sum(unknown_alleles.values()) > 0:
tot = sum(unknown_alleles.values())
if tot > 0:
warnings.warn(
"The following alleles were not found in the variant_allele array "
"and will be treated as unknown:\n"
f"{unknown_alleles}"
"Ancestral alleles were not found in the variant_allele "
f"array for {tot} sites ({tot/len(string_allele)*100:.2f}%). "
"They are listed below, and will be treated as unknown:\n "
+ "\n ".join(
f"'{k}': {v} ({v/len(string_allele)*100:.2f}% of sites)"
for k, v in unknown_alleles.items()
)
)
return ret

Expand Down

0 comments on commit 5e282e4

Please sign in to comment.