Constructor functions
Constructors
|
Convert to a Boolean expression. |
|
Convert to a 64-bit floating point expression. |
|
Convert to a 32-bit floating point expression. |
|
Convert to a 64-bit floating point expression. |
|
Convert to a 32-bit integer expression. |
|
Convert to a 32-bit integer expression. |
|
Convert to a 64-bit integer expression. |
|
Construct an interval expression. |
|
Construct a struct expression. |
|
Construct a tuple expression. |
Collection constructors
|
Construct an array expression. |
|
Returns an empty array of elements of a type t. |
|
Convert a set expression. |
|
Returns an empty set of elements of a type t. |
|
Creates a dictionary. |
|
Returns an empty dictionary with key type key_type and value type value_type. |
- hail.expr.functions.bool(x)[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, andFalse
if they are zero.Acceptable string values are:
'True'
,'true'
,'TRUE'
,'False'
,'false'
, and'FALSE'
.- Parameters:
x (
NumericExpression
orBooleanExpression
orStringExpression
)- Returns:
- hail.expr.functions.float(x)[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
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetfloat64
- hail.expr.functions.float32(x)[source]
Convert to a 32-bit floating point expression.
Examples
>>> hl.eval(hl.float32('1.1')) 1.100000023841858
>>> hl.eval(hl.float32(1)) 1.0
>>> hl.eval(hl.float32(True)) 1.0
- Parameters:
x (
NumericExpression
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetfloat32
- hail.expr.functions.float64(x)[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
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetfloat64
- hail.expr.functions.int(x)[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
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetint32
- hail.expr.functions.int32(x)[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
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetint32
- hail.expr.functions.int64(x)[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
orBooleanExpression
orStringExpression
)- Returns:
NumericExpression
of typetint64
- hail.expr.functions.interval(start, end, includes_start=True, includes_end=False)[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:
start (
Expression
) – Start point.end (
Expression
) – End point.includes_start (
BooleanExpression
) – IfTrue
, interval includes start point.includes_end (
BooleanExpression
) – IfTrue
, interval includes end point.
- Returns:
- hail.expr.functions.struct(**kwargs)[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)[source]
Construct a tuple expression.
Examples
>>> t = hl.tuple([1, 2, '3']) >>> hl.eval(t) (1, 2, '3')
>>> hl.eval(t[2]) '3'
- Parameters:
iterable (an iterable of
Expression
) – Tuple elements.- Returns:
- hail.expr.functions.array(collection)[source]
Construct an array expression.
Examples
>>> s = {'Bob', 'Charlie', 'Alice'}
>>> hl.eval(hl.array(s)) ['Alice', 'Bob', 'Charlie']
- Parameters:
collection (
ArrayExpression
orSetExpression
orDictExpression
)- Returns:
- hail.expr.functions.empty_array(t)[source]
Returns an empty array of elements of a type t.
Examples
>>> hl.eval(hl.empty_array(hl.tint32)) []
- Parameters:
- Returns:
- hail.expr.functions.set(collection)[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)[source]
Returns an empty set of elements of a type t.
Examples
>>> hl.eval(hl.empty_set(hl.tstr)) set()
- Parameters:
- Returns:
- hail.expr.functions.dict(collection)[source]
Creates a dictionary.
Examples
>>> hl.eval(hl.dict([('foo', 1), ('bar', 2), ('baz', 3)])) {'bar': 2, 'baz': 3, '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
orArrayExpression
orSetExpression
)- Returns: