L7|ESP Expression Language
Key Terms
Term | Definition |
Python | A high-level, interpreted, general purpose programming language with a design focus on readable and maintainable code. |
L7|ESP Expression Language | An embedded programming language, based on Python, that offers a set of pre-defined functions for interacting with L7|ESP.
|
Data Types
Data Type | Definition |
bool | Boolean - true or false. |
int | Integer - positive or negative whole number. |
str | String - sequence of unicode characters (alphanumeric, including punctuation, spaces, and symbols for supported human languages). |
list | List - ordered collection of values, including duplicates. |
An Overview of L7|ESP Expressions
L7|ESP provides the necessary building blocks to model complete business processes through the use of Entities and Protocols. However, there are times when another level of "programming" may be desired to provide dynamic content, driven by choices the End User makes while running an Experiment.
The L7|ESP Expression Language is an embedded programming language that offers deep access to L7|ESP, and is natively available in every L7|ESP instance. It is used primarily to:
Perform simple computations in Worksheets.
Generate default values and selection lists for Worksheets.
Pull values from one Protocol’s Worksheet and populate cells in another Worksheet.
Parameterize Tasks in Pipelines.
Define patterns for filenames when automatically registering Files.
Determine whether an Entity should transition to the next Workflow(s) in a Workflow Chain.
The L7|ESP Expression Language is based on the Python programming language, but limited to single-line statements. Most valid Python "one-liners" can be used as L7|ESP Expressions. The only exceptions are Expressions with syntax errors or Expressions that fail the Expression Language's security check.
Note
See Section 6.1 of the User Documentation for an explanation of this security check.
To provide access to information and support complex operations, such as "one-liners", L7|ESP supports an expanding collection of API calls that are available from the L7|ESP Expression Language.
Note
Section 6.2 of the User Documentation organizes the full list of Expressions by API endpoint.
cell
(column: str, protocol: Optional[str] = None, generation: int = 0) → str
Retrieve a value from a LIMS cell.
Parameters:
column - the column containing the desired values.
protocol - name of the Protocol containing the column. If
protocol
isNone
, the current Protocol is used.generation - where in the Entity-lineage to look for a value.
0
is "the uuid of the Entity in the current Protocol"-1
is the parent,-2
the grandparent, etc.Values > 0 are not supported at this time.
generation
should only be used when pulling data from a Protocol that is not present in the current Workflow.
Returns:
The associated cell value, as a string.
Note
Using the returned value in non-string context requires explicit type-casting, such as:
{{ int(cell('Concentration'))/35 }}
Examples:
# Returned from the same Protocol. {{ cell('Concentration') }} --> '35' # Returned from the "QC" Protocol, either in the same Workflow, or from another # Workflow run on the same Entity. {{ cell('Concentration', 'QC') }} --> '35' # Returned from the "QC" Protocol from a Workflow run on the parent of the # current Entity. {{ cell('Concentration', 'QC', -1) }} --> '35'
Note
Use chain_cell if strict Workflow Chain provenance is required.
tagged_value
(tags: list, generation: Union[str, int] = 0, entity_uuid: Union[str, list[str]] = None) → typing.Union[str, list[str]]
Get values by tag.
Parameters:
tags - the list of tags. A column must match all tags to match.
generation - where in the Entity-lineage to look for a value.
0
is "the uuid in the current Protocol,"-1
is the parent,-2
the grandparent, etc.Any value supported by
entity_generation
may be used here.
entity_uuid - Entity UUID(s) to use. If
None
, assumed to beself.ctx['entity']['uuid']
. If a list of UUIDs is provided, the result will be a list with corresponding results for each UUID.
Returns:
Corresponding column value, as a string.
Example:
# Returned from an Entity or LIMS field tagged with "esp:concentration". {{ tagged_value(['esp:concentration']) }} --> '35'
Note
tagged_value will look at LIMS values and Entity custom fields. It should be used when a value can come from more than one (1) upstream source.
group_values
(protocol: str, column: str) → list
Get the value of a column for all Entities in a single group of a grouped Protocol.
Parameters:
protocol - the name of the Protocol to get values from, relative to the current Workflow. If
protocol
isNone
, the current Protocol is used.column - the column containing the desired values.
Returns:
Column values for all the Entities in the current row's group.
Example:
{{ group_values('Plate Prep', 'Wells') }} --> ['A1', 'B12', 'C9']
Note
grouped_value is used to get the individual values for each Entity in an Entity Group from a column in the current Protocol (or another Protocol in the same Workflow).
entity_value
(varname: str, entity_uuid: Union[list[str], str] = None, generation: Union[str, int] = 0, index: int = - 1) → typing.Union[list[str], str]
Return a the value of an Entity field.
Parameters:
varname - the variable to return. See info panel below for details.
entity_uuids - the UUID(s) of the
generation=0
entity. Ifentity_uuids
is a list of UUID strings, a list of values will be returned in the same length and order as the input.generation - any value that can be passed to
entity_generation
can be used here.index - if multiple Entities are present at the specified generation, which of the Entities (by index) to use. When the generation is fetched, the Entities are ordered by creation date, so
0
would be the earliest-created Entity and-1
would be the most recently created Entity at the given generation.
Returns:
A value or list of values, depending on the shape of entity_uuids
.
Examples:
# Returned from the Entity field "I7 Index" for the current Entity (LIMS context). {{ entity_value('I7 Index') }} --> "ACGTACAT" # Returned from the Entity field "I7 Index" for the nearest Illumina Library ancestor # (LIMS context). {{ entity_value('I7 Index', generation='closestup:Illumina Library') }} --> "ACGTACAT"
In addition to custom field name, varname
can also be one of the following:
Varname | Description |
| Entity name. |
| Entity description. |
| (API) URL for the Entity. |
| Meta dict for the Entity. |
| Entity UUID. |
| Entity Class. |
| True if the Entity is archived, otherwise false. |
| Created timestamp. |
| Last modified timestamp. |
| Name of the current Entity owner (normally the Entity creator). |
| UUID of the Entity's Entity Type. |
| Name of the Entity's Entity Type. |
| Whether this Entity has ever been submitted to a Workflow. |
| Entity's barcode value. |