arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

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.

hashtag
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.

hashtag
Parameters

The script is invoked with just three parameters:

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

hashtag
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:

hashtag
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.

hashtag
Attachments

renameSamples.py:

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.

  • -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)

    file-download
    2KB
    renameSamples.py
    arrow-up-right-from-squareOpen
    /usr/bin/python /opt/gls/clarity/customextensions/renameSamples.py -l 2-1234 -u admin -p securepassword
    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