Renaming Samples to Add an Internal ID

When a lab takes in samples, they are named by the lab scientist who supplies them. As such, samples may be named in any way imaginable. Conversely, the research facilities processing the samples often have strict naming conventions.

When these two situations occur, there is a need for the sample to renamed with the strict nomenclature of the processing lab. However, in order for the final data to be meaningful for the scientist who supplied the samples, the original name must also be retained.

Solution

In this example, the attached script may be used to rename samples, while retaining their original names in a separate field.

  • The original name of the sample is saved in a user-defined field (UDF) called Customer's Sample Name, .

  • The Sample Name for the submitted sample is overwritten, using the specific naming convention of the customer.

It is recommended that the script be launched by a process/protocol step as early as possible in the sample lifecycle.

Parameters

The script is invoked with just three parameters:

-l

The limsid of the process invoking the script (Required)

-u

The username of the current user (Required)

-p

The password of the current user (Required)

An example of the full syntax to invoke the script is as follows:

/usr/bin/python /opt/gls/clarity/customextensions/renameSamples.py -l 2-1234 -u admin -p securepassword

About the Code

Once the command-line parameters have been harvested, and the API object set up ready to handle API requests, the renameSamples() method is called.

This method implements the following pseudo code:

step 1: get the inputs to this process

for each input:

   step 2: get the URI of the submitted sample associated with the inputs

   step 3: get the sample

   step 4: update the sample

   step 5: save the sample

Assumptions and Notes

  • Both of the attached files are placed on the Clarity LIMS server, in the /opt/gls/clarity/customextensions folder.

  • A user defined field, named Customer's Sample Name has been created at the analyte (sample) level.

  • The Customer's Sample Name field is visible within the LabLink Collaborations Interface.

  • You will need to update the HOSTNAME global variable such that it points to your Clarity LIMS server.

  • You will need to implement your own logic to apply the new sample name in Step 4 of the script.

  • The example code is provided for illustrative purposes only. It does not contain sufficient exception handling for use 'as is' in a production environment.

Attachments

renameSamples.py:

Last updated