Rearray Samples
In high throughput labs, samples are worked on in batches and some work is executed by a robot. Sometimes, a set of plates must be rearrayed to one larger plate before the robot can begin the lab step.
This example accomplishes this using two scripts. One script is configured on a derived sample automation, while the second script is included in a command line configured on a step automation.
Prerequisites
Before you follow the example, make sure that you have the following items:
A project containing samples assigned to a workflow in Clarity LIMS.
The workflow name.
Given samples are assigned to the same workflow stage.
Code Example
This example demonstrates the following scripts:
AssignToRearrayWf.groovy—Executed as a derived sample automation, this script assigns selected samples to the rearray step.
AssignToLastRemoved.groovy—Executed after the rearray step, this script assigns the samples to the stage to which they were originally assigned. The script is included in a command line configured on a step automation.
Configure the Assign To Rearray Automation
In Clarity LIMS, under Configuration, select the Automation tab.
Select the Derived Sample Automation tab.
Select New Automation and create an automation that prompts the user for the workflow stage name to be used.
In the example, note the following:
The {groovy_bin_location} and {script_location} parameters must be customized to reflect the locations on your computer.
The –w option allows for user input to be passed to the script as a command-line variable.
AssignToRearrayWf Script Methods
Step 1. Retrieve the Artifact Nodes Using the Artifact LIMS IDs
The AssignToRearrayWf script has a list of artifact (sample) LIMS IDs given on the command line. To begin, use this script to build a list of artifact nodes.
The following code example builds a list of artifact URIs using the artifact LIMS ID list and the getArtifactNodes function. The resulting artifact URI list can then be used for a batchGET call to return the artifact nodes.
Step 2. Retrieve Workflow Name and URI
In this example, you can assume that the workflow name is known by the user and is passed to the script by user input when the automation is initiated.
The workflow can then be queried for using the passed workflow name. The workflow name is first encoded, and from this, you can retrieve the workflow URI.
Step 3. Make Sure that the Samples Belong to the Same Workflow Stage
For the samples to be placed in the same container, they must all belong to the same workflow and be currently queued to the same stage in that workflow.
Using the workflow name passed in by the user, do the following:
Search the workflow stage list of the first artifact and store the URI of the most recent stage that is part of the workflow, if it is queued. Otherwise, the script exits with an error message.
After storing the workflow stage URI of the first artifact, use the checkMatch function check against the remaining artifacts in the list to verify they are all currently queued to the same stage.
If all artifacts are queued for the stage, they are removed from the queue of the stage under the lastWfStageURI function.
Step 4. Build the XML for stage assignment using Streaming Markup Builder
In this example, all the artifacts are unassigned from the previous workflow stage returned and assigned to the rearray stage using the queuePlacementStep function. The previous methods have verified that the artifacts in the list can be rearrayed together.
The returned XML node is then posted using httpPOST.
Step 2. Configuring Placement Workflow, Protocol, and Step
In Clarity LIMS, under Configuration, select the Lab Work tab.
Create a master step of Standard step type.
From Configuration, select the Automation tab.
Select the Step Automation tab.
Create an automation for the AssignToLastRemoved.groovy script.
The {groovy_bin_location} and {script_location} parameters must be customized to reflect the locations on your computer.
Enable the automation on the master step you created in step 2.
Configure a new protocol and step as follows.
On the Lab Work tab, create a non-QC protocol.
In the Protocols list, select the new protocol and then add a new step to it. Base the new step on the master step you created in step 2.
On the Step Settings form, in the Automation section, you see the step automation you configured. Configure the automation triggers as follows.
Trigger Location—Step
Trigger Style—Automatic upon exit
On the Placement milestone, Add 96 well plate and 384 well plate as the permitted destination container types for the step.
Remove the default Tube container type.
Save the step.
Configure a new workflow as follows:
On the Lab Work tab, create a workflow.
Add the protocol you created to the workflow.
AssignToLastRemovedStage Script Methods
Step 1. Build List of Artifact Nodes from the Step Input-Output Map
The first step of AssignToLastRemovedStage script is the same as for the AssignToRearrayWf script: return the artifact node list.
However, in this script, you are not directly given the artifact LIMS IDs. Instead, because you receive the step URI from the process parameter command line, you can collect the artifact URIs from the inputs of the step details input-output map using the getArtifactNodes function.
An example step details URI might be {hostname}/api/v2/steps/{stepLIMSID}/details.
Step 2. Assign Artifacts Back to the Original Stage
Each artifact in the list was removed from this stage before going through the rearray step.
With this in mind, and because the Clarity LIMS API stores artifact history by time (including stage history), the stage to which you now want to assign the samples to be the second-to-last stage in the workflow-stage list.
The following method finds the stage from which the artifacts were removed using the getLastRemoved function:
Step 3. Make Sure that Artifacts are Assigned to the Same Stage
You can then check to make sure all artifacts originated in this stage. This helps you avoid the scenario where the AssignToRearrayStage.groovy script was run on two groups of artifacts queried while in different workflow stages.
Step 4. Build the XML to Assign the Samples Back to the Returned Stage
Function: assignStage
This returned stage URI is then used to build the assignment XML to assign all the samples back to this stage with the assignStage function.
After posting this XML node, the samples are assigned back to the stage in which they began.
Step 3. Running the Assign to Rearray Automation
In the Projects Dashboard, select the samples to be rearrayed and run the 'Assign to Rearray' automation.
On automation trigger, the {userinput} phrase will invoke a dialog that prompts for the full name of the workflow.
Step 4. Placing the Samples and Running the Rearray Step
In Clarity LIMS, under Lab View, select the protocol you created in Step 2. Configuring Placement Workflow, Protocol, and Step.
The samples assigned by the Assign to Rearray automation is available to assign to a new container.
Add the samples to the Ice Bucket and begin work.
The placement screen opens, allowing you to place the samples into the new container, in your desired placement pattern.
Proceed to the Record Details screen, then on to Next Steps. Do not perform any actions on these screens.
In the next step drop-down list, select Mark Protocol as Complete and select Apply.
Selec Next. This initiates the 'Assign to last removed' trigger, which assigns the samples back to the step from which they were removed.
Attachments
AssignToRearrayWf.groovy:
AssignToLastRemoved.groovy:
Last updated