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.
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.
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.
-exp 'output.::Position:: = (((output.well.split(:: : ::.trim())[0].toString().toUpperCase() as char)
- (::A:: as char)) * (int) Math.pow(26, 0)*12) + output.well.split(:: : ::.trim())[1].toInteger()'
-exp 'if (output.container.name.matches(::.*[\u0022\u0027?()\\[\\]/\\\\ ].*::))
{ fail(::The following characters are not allowed in the Container Name: ? ( ) [ ] / \ and quotes or spaces.::) }'