# Parsing Metadata into UDFs (BCL Conversion and Demultiplexing)

This example provides a script that can be used to parse lanebarcode.html files from demultiplexing. This script is written to be easily used with the out of the box **Bcl Conversion & Demultiplexing (HiSeq 3000/4000)** protocol.

* Result values are associated with a barcode sequence as well as lane.
* Values are attached to the result file output in Clarity LIMS, with matching barcode sequence (index on derived sample input) and lane (container placement of derived sample input).
* Script modifications may be needed to match the format of index in Clarity LIMS to the index in the HTML result file.

### Parameters <a href="#h_50282625-825b-4334-91e3-87216559c69b" id="h_50282625-825b-4334-91e3-87216559c69b"></a>

The script accepts the following parameters:

<table data-header-hidden><thead><tr><th width="158"></th><th></th></tr></thead><tbody><tr><td>-u</td><td>The username of the current user (Required)</td></tr><tr><td>-p</td><td>The password of the current user (Required)</td></tr><tr><td>-o</td><td>The limsid of the result file artifact with attached lanebarecode.html file (Required)</td></tr><tr><td>-s</td><td>The LIMS IDs of the individual result files. (Required)</td></tr></tbody></table>

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

{% code overflow="wrap" %}

```
bash -l -c "/usr/bin/python /opt/gls/clarity/customextensions/demux_stats_parser.py -s {stepURI:v2} -o {compoundOutputFileLuid0} -u {username} -p {password}" 
```

{% endcode %}

### Configuration <a href="#h_7eb163bd-b6fc-48e3-aff6-a2592921a325" id="h_7eb163bd-b6fc-48e3-aff6-a2592921a325"></a>

#### Defining the UDFs / Custom Fields <a href="#h_3ba73190-ec30-4924-ae1d-e43aa0a47fbb" id="h_3ba73190-ec30-4924-ae1d-e43aa0a47fbb"></a>

All user defined fields (UDFs) / custom fields must first be defined in the script. Within the UDF / custom field dictionary, the name of the field as it appears in Clarity LIMS (the key) must be associated with the field from the result file (the value).

The fields should be preconfigured in Clarity LIMS for result file outputs.

```
udfs_in_clarity = {"Yield PF (Gb)":"Yield (Mbases)"
    "%PF":"% PF Clusters",
    "% One Mismatch Reads (Index)":"% One mismatch barcode", 
    "% Bases >=Q30":"% &gt;= Q30 bases",
    "Ave Q Score":"Mean Quality Score",
    "% Perfect Index Read":"% Perfect barcode",
    "# Reads":"PF Clusters",
    "% of Raw Clusters Per Lane":"% of the lane"}
```

#### Modifying individual UDFs / Custom Fields <a href="#h_7589734f-152d-48ea-930d-acdc14d39ff5" id="h_7589734f-152d-48ea-930d-acdc14d39ff5"></a>

The UDF / custom field values can be modified before being brought into Clarity LIMS. In the following example, the value in megabases is modified to gigabases.

```
if clarity_udf == 'Yield PF (Gb)':
    yieldmb = udf_value
    yieldmb = yieldmb.replace(",","")
    yieldgb = float(yieldmb)*.001
    udf_value = yieldgb
```

#### Checking for matching flow cell ID <a href="#h_6f338402-a119-40cc-a87c-78b102d0df46" id="h_6f338402-a119-40cc-a87c-78b102d0df46"></a>

The script currently checks the flow cell ID for the projects in Clarity LIMS against the flow cell IS in the result file.

**NOTE**: The script will still complete and attach UDF / custom field values. You may wish to modify the script to not attach the field values if the flow cell ID does not match.

### Assumptions and Notes <a href="#h_3bbe560f-71fb-4ec1-bf96-34827417e161" id="h_3bbe560f-71fb-4ec1-bf96-34827417e161"></a>

* Your configuration conforms with the script's requirements, as documented in the Configuration section of this document.
* You are running a version of Python that is supported by Clarity LIMS, as documented in the Clarity LIMS Technical Requirements.
* The attached Python file is placed on the LIMS server, in the **/opt/gls/clarity/customextensions** folder.
* The glsapiutil file is placed on the Clarity LIMS server, in the **/opt/gls/clarity/customextensions** folder.
* 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

demux\_stats\_parser.py:

{% file src="/files/uyoBazMVOB03cxvOZHNd" %}

demux\_stats\_parser\_4.py:

{% file src="/files/zXqeMZKdRRKgYvfgbNdg" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/application-examples/page-15/parsing-metadata-into-udfs-bcl-conversion-and-demultiplexing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
