Constructor functions

Constructors

bool(x) Convert to a Boolean expression.
float(x) Convert to a 64-bit floating point expression.
float32(x) Convert to a 32-bit floating point expression.
float64(x) Convert to a 64-bit floating point expression.
int(x) Convert to a 32-bit integer expression.
int32(x) Convert to a 32-bit integer expression.
int64(x) Convert to a 64-bit integer expression.
interval(start, end[, includes_start, …]) Construct an interval expression.
struct(**kwargs) Construct a struct expression.
tuple(iterable) Construct a tuple expression.

Collection constructors

array(collection) Construct an array expression.
empty_array(t, hail.expr.functions.str]) Returns an empty array of elements of a type t.
set(collection) Convert a set expression.
empty_set(t, hail.expr.functions.str]) Returns an empty set of elements of a type t.
dict(collection) Creates a dictionary.
empty_dict(key_type, …) Returns an empty dictionary with key type key_type and value type value_type.
hail.expr.functions.bool(x) → hail.expr.expressions.typed_expressions.BooleanExpression[source]

Convert to a Boolean expression.

Examples

>>> hl.eval(hl.bool('TRUE'))
True
>>> hl.eval(hl.bool(1.5))
True

Notes

Numeric expressions return True if they are non-zero, and False if they are zero.

Acceptable string values are: 'True', 'true', 'TRUE', 'False', 'false', and 'FALSE'.

Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:BooleanExpression
hail.expr.functions.float(x) → hail.expr.expressions.typed_expressions.Float64Expression[source]

Convert to a 64-bit floating point expression.

Examples

>>> hl.eval(hl.float('1.1'))
1.1
>>> hl.eval(hl.float(1))
1.0
>>> hl.eval(hl.float(True))
1.0

Note

Alias for float64().

Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tfloat64
hail.expr.functions.float32(x) → hail.expr.expressions.typed_expressions.Float32Expression[source]

Convert to a 32-bit floating point expression.

Examples

>>> hl.eval(hl.float32('1.1'))  
1.1
>>> hl.eval(hl.float32(1))  
1.0
>>> hl.eval(hl.float32(True))  
1.0
Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tfloat32
hail.expr.functions.float64(x) → hail.expr.expressions.typed_expressions.Float64Expression[source]

Convert to a 64-bit floating point expression.

Examples

>>> hl.eval(hl.float64('1.1'))  
1.1
>>> hl.eval(hl.float64(1))  
1.0
>>> hl.eval(hl.float64(True))  
1.0
Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tfloat64
hail.expr.functions.int(x) → hail.expr.expressions.typed_expressions.Int32Expression[source]

Convert to a 32-bit integer expression.

Examples

>>> hl.eval(hl.int('1'))
1
>>> hl.eval(hl.int(1.5))
1
>>> hl.eval(hl.int(True))
1

Note

Alias for int32().

Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tint32
hail.expr.functions.int32(x) → hail.expr.expressions.typed_expressions.Int32Expression[source]

Convert to a 32-bit integer expression.

Examples

>>> hl.eval(hl.int32('1'))
1
>>> hl.eval(hl.int32(1.5))
1
>>> hl.eval(hl.int32(True))
1
Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tint32
hail.expr.functions.int64(x) → hail.expr.expressions.typed_expressions.Int64Expression[source]

Convert to a 64-bit integer expression.

Examples

>>> hl.eval(hl.int64('1'))
1
>>> hl.eval(hl.int64(1.5))
1
>>> hl.eval(hl.int64(True))
1
Parameters:x (NumericExpression or BooleanExpression or StringExpression)
Returns:NumericExpression of type tint64
hail.expr.functions.interval(start, end, includes_start=True, includes_end=False) → hail.expr.expressions.typed_expressions.IntervalExpression[source]

Construct an interval expression.

Examples

>>> hl.eval(hl.interval(5, 100))
Interval(start=5, end=100, includes_start=True, includes_end=False)
>>> hl.eval(hl.interval(hl.locus("1", 100), hl.locus("1", 1000)))
    Interval(start=Locus(contig=1, position=100, reference_genome=GRCh37),
             end=Locus(contig=1, position=1000, reference_genome=GRCh37),
             includes_start=True,
             includes_end=False)

Notes

start and end must have the same type.

Parameters:
Returns:

IntervalExpression

hail.expr.functions.struct(**kwargs) → hail.expr.expressions.typed_expressions.StructExpression[source]

Construct a struct expression.

Examples

>>> s = hl.struct(a=5, b='Foo')
>>> hl.eval(s.a)
5
Returns:StructExpression – Keyword arguments as a struct.
hail.expr.functions.tuple(iterable: Iterable) → hail.expr.expressions.typed_expressions.TupleExpression[source]

Construct a tuple expression.

Examples

>>> t = hl.tuple([1, 2, '3'])
>>> hl.eval(t)
(1, 2, '3')
>>> hl.eval(t[2])
'3'
Parameters:args (Iterable of Expression) – Tuple elements.
Returns:TupleExpression
hail.expr.functions.array(collection) → hail.expr.expressions.typed_expressions.ArrayExpression[source]

Construct an array expression.

Examples

>>> s = {'Bob', 'Charlie', 'Alice'}
>>> hl.eval(hl.array(s))
['Alice', 'Bob', 'Charlie']
Parameters:collection (ArrayExpression or SetExpression or DictExpression)
Returns:ArrayExpression
hail.expr.functions.empty_array(t: Union[hail.expr.types.HailType, hail.expr.functions.str]) → hail.expr.expressions.typed_expressions.ArrayExpression[source]

Returns an empty array of elements of a type t.

Examples

>>> hl.eval(hl.empty_array(hl.tint32))
[]
Parameters:t (str or HailType) – Type of the array elements.
Returns:ArrayExpression
hail.expr.functions.set(collection) → hail.expr.expressions.typed_expressions.SetExpression[source]

Convert a set expression.

Examples

>>> s = hl.set(['Bob', 'Charlie', 'Alice', 'Bob', 'Bob'])
>>> hl.eval(s)  
{'Alice', 'Bob', 'Charlie'}
Returns:SetExpression – Set of all unique elements.
hail.expr.functions.empty_set(t: Union[hail.expr.types.HailType, hail.expr.functions.str]) → hail.expr.expressions.typed_expressions.SetExpression[source]

Returns an empty set of elements of a type t.

Examples

>>> hl.eval(hl.empty_set(hl.tstr))
set()
Parameters:t (str or HailType) – Type of the set elements.
Returns:SetExpression
hail.expr.functions.dict(collection) → hail.expr.expressions.typed_expressions.DictExpression[source]

Creates a dictionary.

Examples

>>> hl.eval(hl.dict([('foo', 1), ('bar', 2), ('baz', 3)]))  
{u'bar': 2, u'baz': 3, u'foo': 1}

Notes

This method expects arrays or sets with elements of type ttuple with 2 fields. The first field of the tuple becomes the key, and the second field becomes the value.

Parameters:collection (DictExpression or ArrayExpression or SetExpression)
Returns:DictExpression
hail.expr.functions.empty_dict(key_type: Union[hail.expr.types.HailType, hail.expr.functions.str], value_type: Union[hail.expr.types.HailType, hail.expr.functions.str]) → hail.expr.expressions.typed_expressions.DictExpression[source]

Returns an empty dictionary with key type key_type and value type value_type.

Examples

>>> hl.eval(hl.empty_dict(hl.tstr, hl.tint32))
{}
Parameters:
Returns:

DictExpression