When working with controls, you can automate their removal from a workflow. For more information, see Automated Removal of Controls from a Workflow.
At times, control samples in the lab need only be used in a portion of a workflow. For example, E. coli genomic DNA is often prepared alongside samples in Library Preparation protocols and then validated during a Library Validation QC protocol to confirm that nothing went wrong during Library Preparation.
Because the utility of such a control sample is short-lived, there is no need to spend sequencing effort on it. In this scenario, it is advantageous to prevent control samples from advancing in the workflow automatically.
This can be accomplished through the API by implementing an EPP/automation script that removes the control at the end of a step. This example shows how to automate the removal of control samples at the end of a step and remove them from workflows. You can use this method on any step configured to generate individual derived sample (analyte) or ResultFile (measurement) outputs. The step can have any number of per-all-input result file (shared file) outputs, as they will be ignored by the script.
In the API, an artifact is an item generated by an earlier step. There are two types of artifacts: analyte (derived sample) and resultfile (measurement). In the Clarity LIMS web interface, the terms artifact, analyte, and resultfile have been replaced with derived sample or measurement.
Before you follow the example, make sure that you have done the following actions:
GLSRestApiUtils.groovy is located in your Groovy lib folder
You have downloaded the ControlSampleRemoval.groovy file and have placed it in /opt/gls/clarity/customextensions/
You have completed the required configuration steps, as described below
Before you can use this example script, you will need to complete the following configuration steps.
Complete the following steps in the LIMS Configuration area.
On the Lab Work tab, create a new master step named Cookbook Control Removal.
The master step may be of any type that generates derived samples or measurements.
The master step may generate any number of derived sample or measurement outputs.
On the Lab Work tab, create a new protocol named Cookbook Control Removal Protocol.
Add a new Cookbook Control Removal step to the protocol, basing it on the Cookbook Control Removal master step.
On the Automation tab, configure a step automation and name the automation Remove Controls.
In the Command Line text box, enter the following code example. Modifying the file paths for the Groovy installation on your server.
Enable the automation on the Cookbook Control Removal master step.
You can now configure the automation trigger on the step or the master step. If you configure the trigger on the master step, the settings are locked on all steps derived from the master step.
On the Lab Work tab, select the master step or step.
On the Master Step Settings or Step Settings form, in the Automation section, configure the automation trigger so that the script is initiated automatically at the end of the step.
Trigger Location: Step
Trigger Style: Automatic upon exit
From Consumables, select Control Samples tab.
In the Control Samples tab, enable one or more control samples on the Cookbook Control Removal step.
On the Lab Work tab, create a workflow named Cookbook Control Removal Workflow.
This workflow should contain the Cookbook Control Removal Protocol. You can add the script to any step in any workflow, and you do not need to create a separate step to run it.
For this example, it can also be beneficial to add a second step (any type) after this removal step to make sure that the controls were removed.
The following table defines the three parameters/tokens used by the script. As of Clarity LIMS v5.0, the term command-line parameter has been replaced with token.
After the script has processed the parameters / tokens and ensured that all the required information is available, it can begin to process the samples to determine if they should be removed.
To begin, retrieve the list of permitted actions for the step from the API. This contains a list of the URIs for the input analytes and their next steps.
You can use this information to get the URI of the current step, which allows you to obtain the information for the step itself.
Next, look at the possible next steps that can be used in this step. In doing so, you are able to collect the next-step-uri values that are associated with the 'next step' names within the NEXT_STEPS map.
In this case you are looking for the URI associated with the Remove from workflow option.
After you have retrieved the URIs for the desired next steps, you can iterate through the actions list checking artifacts to see if they are controls. If the artifact associated with any next action is a control, change the next action of the artifact to be the removal next step URI you retrieved previously.
Finally, send the change for the next step information to the desired endpoint and then define our success message to the user. The message allows you to inform the user of the results of the script.
Assuming samples and a control sample have been placed in the Cookbook Control Removal Workflow Ice Bucket, you can proceed as normal through the step.
On the Assign Next Steps screen, provide a variety of Next Step values, if desired.
Proceed with the completion of the step. A message box will display, alerting you to the execution of a custom script.
When the script completes, a success message displays and the controls will have been removed from the workflow.
ControlSampleRemoval.groovy:
-s {stepURI}
The protocol step URI, in the following form: http://<YourIP>/api/v2/steps/<ProtocolStepLimsid>
-u {username}
The LIMS username (Required)
-p {password}
The LIMS password (Required)