Find the Contents of a Well Location in a Container

As samples are processed in the lab, they are kept in a container. Some of these containers hold multiple samples, and lab scientists often must switch between container tracking and sample tracking.

If you process several containers each day and track them in a list, you would need to find which samples are in those containers. This way, you can record specifics from these container-based activities in relation to the samples from Clarity LIMS.

The example finds which sample is in a given well of a multi-well container using Clarity LIMS and API (v2 r21 or later).

Prerequisites

Before you follow the example, make sure that you have the following items:

  • Several samples exist in the Clarity LIMS.

  • A step has been run on the samples.

  • The outputs of the step have been placed in a 96-well plate.

Code example

Clarity LIMS captures detailed information for a container (eg, its name, LIMS ID, and the names of the sample in each of its wells). Information about the container and what it currently contains is available in the individual XML resource for the container.

The individual container resource contains a placement element for each sample placed on the container. Each placement element has a child element named value that describes one position on the container (eg, the placement elements for a 96-well plate include A:1, B:5, E:2).

Step 1. Retrieve the Container Information

In the script, the GET request retrieves the container specified by the container LIMS ID provided as input to the {containerLIMSID} parameter. The XML representation returned from the API is stored as the value of the container variable:

// Determine the specified container's URI and retrieve it
containerURI = "http://${hostname}/api/v2/containers/${containerLIMSID}"
container = GLSRestApiUtils.httpGET(containerURI, username, password)

The following example shows the XML format returned for a container. The XML includes a placement element for each artifact that is placed in a well location in the container.

<con:container uri="http://yourIPaddress/api/v2/containers/27-1259" limsid="27-1259">
    <name>PC0006</name>
    <type uri="http://yourIPaddress/api/v2/containertypes/1" name="96 well plate"/>
    <occupied-wells>96</occupied-wells>
    <placement uri="http://yourIPaddress/api/v2/artifacts/HAM751A495PA1" limsid="HAM751A495PA1">
        <value>B:3</value>
    </placement>
    <placement uri="http://yourIPaddress/api/v2/artifacts/HAM751A496PA1" limsid="HAM751A496PA1">
        <value>B:4</value>
    </placement>
    <placement uri="http://yourIPaddress/api/v2/artifacts/HAM751A493PA1" limsid="HAM751A493PA1">
        <value>B:1</value>
    </placement>
    <placement uri="http://yourIPaddress/api/v2/artifacts/HAM751A497PA1" limsid="HAM751A497PA1">
        <value>B:5</value>
    </placement>
</con:container> 

Step 2. Find the Artifact URI

When you look for the artifact at the target location, the script searches through the placement elements for one with a value element that matches the target. If a match is found, it is stored as the value of the contents variable.

The >uri attribute of the matching placement element is the URI of the artifact that is in the target well location. This is stored as the value of the artifactURI variable, and printed as the output of the script:

// Print the artifact that is located at the specified placement
contents = container.placement.find { it.value.text() == targetPlacement }
artifactURI = contents?.@uri
println artifactURI 

Expected Output and Results

Running the script in a console produces the artifact at

http://yourIPaddress/api/v2/artifacts/HAM751A496PA1

Attachments

GetContentsOfWellLocation.groovy:

Last updated