genome_spy.when¶
- genome_spy.when(predicate)View on GitHub¶
Start an Altair-style selection condition.
Accept a selection handle, a generated selection predicate, or a mapping using GenomeSpy’s
and,or,not, selection-union, or namedrefgrammar. Selection handles can appear inside mappings, including as theparamof an endpoint projection. Declare selections withadd_paramsand named predicates with the unit view’spredicatesproperty.- Parameters:
predicate – A selection parameter or a composed selection test.
- Returns:
A builder whose
then()method defines the selected branch.- Raises:
TypeError – If a value parameter or unsupported input is supplied.
SchemaValidationError – If the predicate does not match the Core grammar.
Example
>>> import genome_spy as gs >>> brush = gs.selection_interval(encodings=["x"]) >>> condition = gs.when(brush).then(gs.value("red")).otherwise( ... gs.value("gray") ... ) >>> condition.to_dict()["condition"]["param"] == brush.name True