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, str]) |
Returns an empty array of elements of a type t. |
set (collection) |
Convert a set expression. |
empty_set (t, str]) |
Returns an empty set of elements of a type t. |
dict (collection) |
Creates a dictionary. |
-
hail.expr.functions.
bool
(x) → hail.expr.expressions.typed_expressions.BooleanExpression[source]¶ Convert to a Boolean expression.
Examples
>>> hl.bool('TRUE').value True
>>> hl.bool(1.5).value 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: BooleanExpression
-
hail.expr.functions.
float
(x) → hail.expr.expressions.typed_expressions.Float64Expression[source]¶ Convert to a 64-bit floating point expression.
Examples
>>> hl.float('1.1').value 1.1
>>> hl.float(1).value 1.0
>>> hl.float(True).value 1.0
Note
Alias for
float64()
.Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetfloat64
-
hail.expr.functions.
float32
(x) → hail.expr.expressions.typed_expressions.Float32Expression[source]¶ Convert to a 32-bit floating point expression.
Examples
>>> hl.float32('1.1').value 1.1
>>> hl.float32(1).value 1.0
>>> hl.float32(True).value 1.0
Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetfloat32
-
hail.expr.functions.
float64
(x) → hail.expr.expressions.typed_expressions.Float64Expression[source]¶ Convert to a 64-bit floating point expression.
Examples
>>> hl.float64('1.1').value 1.1
>>> hl.float64(1).value 1.0
>>> hl.float64(True).value 1.0
Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetfloat64
-
hail.expr.functions.
int
(x) → hail.expr.expressions.typed_expressions.Int32Expression[source]¶ Convert to a 32-bit integer expression.
Examples
>>> hl.int('1').value 1
>>> hl.int(1.5).value 1
>>> hl.int(True).value 1
Note
Alias for
int32()
.Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetint32
-
hail.expr.functions.
int32
(x) → hail.expr.expressions.typed_expressions.Int32Expression[source]¶ Convert to a 32-bit integer expression.
Examples
>>> hl.int32('1').value 1
>>> hl.int32(1.5).value 1
>>> hl.int32(True).value 1
Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetint32
-
hail.expr.functions.
int64
(x) → hail.expr.expressions.typed_expressions.Int64Expression[source]¶ Convert to a 64-bit integer expression.
Examples
>>> hl.int64('1').value 1
>>> hl.int64(1.5).value 1
>>> hl.int64(True).value 1
Parameters: x ( NumericExpression
orBooleanExpression
orStringExpression
)Returns: NumericExpression
of typetint64
-
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.interval(5, 100).value Interval(start=5, end=100)
>>> hl.interval(hl.locus("1", 100), hl.locus("1", 1000)).value Interval(start=Locus(contig=1, position=100, reference_genome=GRCh37), end=Locus(contig=1, position=1000, reference_genome=GRCh37))
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: - start (
-
hail.expr.functions.
struct
(**kwargs) → hail.expr.expressions.typed_expressions.StructExpression[source]¶ Construct a struct expression.
Examples
>>> s = hl.struct(a=5, b='Foo') >>> s.a.value 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']) >>> t.value (1, 2, '3')
>>> t[2].value '3'
Parameters: args ( Iterable
ofExpression
) – 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.array(s).value ['Charlie', 'Alice', 'Bob']
Parameters: collection ( ArrayExpression
orSetExpression
orDictExpression
)Returns: ArrayExpression
-
hail.expr.functions.
empty_array
(t: Union[hail.expr.types.HailType, str]) → hail.expr.expressions.typed_expressions.ArrayExpression[source]¶ Returns an empty array of elements of a type t.
Examples
>>> hl.empty_array(hl.tint32).value []
Parameters: t ( str
orHailType
) – 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']) >>> s.show() {'Alice', 'Bob', 'Charlie'}
Returns: SetExpression
– Set of all unique elements.
-
hail.expr.functions.
empty_set
(t: Union[hail.expr.types.HailType, str]) → hail.expr.expressions.typed_expressions.SetExpression[source]¶ Returns an empty set of elements of a type t.
Examples
>>> hl.empty_set(hl.tstr).value set()
Parameters: t ( str
orHailType
) – Type of the set elements.Returns: SetExpression
-
hail.expr.functions.
dict
(collection) → hail.expr.expressions.typed_expressions.DictExpression[source]¶ Creates a dictionary.
Examples
>>> hl.dict([('foo', 1), ('bar', 2), ('baz', 3)]).value {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
orArrayExpression
orSetExpression
)Returns: DictExpression