Lab Logic Toolkit Script Examples
BaseSpace Clarity LIMS Lab Logic Toolkit (LLTK) provides the evaluateDynamicExpression script, which allows for the evaluation of simple dynamic expressions.
This article provides examples that you can modify to suit the needs of your lab.
For details on script parameters and usage, and additional examples, see the Working with Lab Logic Toolkit article.
Setting QC flags
See the Setting QC Flags article.
Setting next actions
See the Setting Next Actions article.
Create string from multiple UDFs and add additional characters
Determine total number of samples
This example assumes that the step UDF / custom field Total samples has a default numeric value of 0:
Without a default value, the expression must set the initial value before continuing to sum:
Calculate concentration from a dilution factor
Calculate volume of buffer and source sample to dilute
Calculate the remaining amount of submitted sample left after the step
Calculate volumes of all components to add to master mix (e.g., PCR reaction)
Calculate nM from concentration and size
Determine dilution to populate robot file
Calculate average concentration
This example demonstrates the use of step UDFs / custom fields to store temporary values in order to enable calculations between iteration.
Check container name changed from default value
This example checks that the container name has been changed from the default value (container LIMSID)
Calculate yield of sequenced samples using the submittedSamples entity
This example includes Groovy Closures, using both implicit variables (it) and explicit variable names (for example, currentSample).
Concatenate strings
Regex example: Validate output container barcode mask
Regex example: Verify format of flow cell / reagent cartridge barcode
Check the flow cell/reagent cartridge format (Illumina’s flow cell check) as follows:
Regex example: Validate a scanned / manually entered container barcode
Populate a Timestamp (Single-line Text and Text) UDF / custom field
The following expression results in the format: Wed Apr 03 21:28:38 EDT 2015
Populate a Timestamp (Date) UDF / custom field
The following expression results in the format: 2015-04-03
Add values within a pool
This example assumes that the analyte / derived sample UDF Pool Volume (uL) has a default numeric value of 0.
This can also be done without setting a default value for the UDF:
Convert placement information to a numeric position
The example below assumes the following:
The placement is alphanumeric (e.g., A:1)
The offset for the alphabetical row is 0, and the offset for the numeric column is 1
The placement order desired is horizontal: A:1 maps to 1, A:2 maps to 2, etc.
The placement of interest is the output placement
Placement is configured for a specific, known container type, and the dimensions of this container type are also known. This example uses a 96 well container configuration (12 columns are available and this value is used directly in the expression below). This value can be replaced for other container types.
Note the following:
The call to split() here will return a list of row:column, so we use [0] and [1] to access these values, respectively.
:: : ::.trim() is used to obtain the result ':' - because :: is used as a reserved character, and thus ::::: directly results in '': and errors.
Set the error status bar message
See the Failing a Script article.
Check for special characters
In some cases, special characters are not permitted in a field in the LIMS. To prevent users from entering special characters, the best practice is to include validation to check that the field contains only letters and/or numbers. Wherever possible, we recommend that you use this 'positive checking' method as it is much less error-prone. However, if this preferred method is not possible, you can use the Lab Logic Toolkit to check for the presence of special characters, and display an error message if one is found.
The following example use the Groovy matches command to check step output container names for the characters ? ( ) [ ] / \ and quotes or spaces.
The matches command
The matches command takes a regular expression (regex) as its input. Call this command on the field you want to check.
In our example, the matches command is:
If we isolate the regex, we have:
Here, we're checking for any text that contains any one of the special characters listed. It's important to note that the way regex is supported in Java (and therefore Groovy) leads to some quirks, noted in the following table.
Entry
Standard regex representation
Character being checked for
\u0022 and \u0027
' and "
Single and double quotes
?
\?
Question mark
( and )
\( and \)
Brackets
[ and ]
\[ and \]
Square brackets
/
\/
Forward slash
\
\\
Backslash
(space)
\s
Spaces
Escaping characters Normally, in regex we would need to escape the following characters using a single backslash:
However, because of how matches works, not all of these characters need to be escaped - for example the '?' character. Characters that do still need to be escaped, need to be escaped with an additional backslash (e.g., \\).
Checking for quotes Because the command is run via Automated Informatics / Automation Worker, we also need to use a different approach for checking for quotes.
We cannot use them as we typically would when writing a regex expression (e.g., "), or escape them as we would in a call to matches (e.g., \"). Instead, we need to provide them as their unicode number, shown in our example as \u0022 and \u00.
Resources
Last updated