How can I get an array of the alleles from a CallExpresion

I am trying to get the alleles from a GT call into an array for some downstream processing.

Trying the following with a simple VCF based matrix table does not work

mt = mt.annotate_entries(calls = mt.GT.alleles)

This gives the error

AttributeError: ‘CallExpression’ object has no attribute ‘alleles’

It seems that the mt.GT entry field is a CallExpression which does not have the alleles attribute, while the hail.genetics.Call class DOES have the alleles attribute, but not sure how I “convert” the CallExpression to a Call class object.

hl.eval on a single CallExpression does work, but not in the mt.annotate_entries expression.

c =, 1, phased=False)

< CallExpression of type call>


[0, 1]

Is there any way to get the alleles array to be used in the annotate_entries?

huh, this is an oversight. We can add this pretty easily.

For now, a solution that works with unphased calls (or if you don’t care about phase) is:

def alleles_array(call):
    return hl.range(call.ploidy).map(lambda idx: call[idx])
1 Like

OK…Thanks for the help…I figured it was something like that!