# Invoking bcl2fastq from BCL Conversion and Demultiplexing Step

Illumina sequencing protocols include a **BCL Conversion and Demultiplexing** step. This stage allows you to select the command options for running bcl2fastq2. The bcl2fastq must be initiated through a command-line call on the BCL server.

This example allows you to initiate the bcl2fastq2 conversion software by the selection of a button in BaseSpace Clarity LIMS.

**Step Configuration**

The "out of the box" step is configured to include the following UDFs / custom fields. You can select these options on the **Record Details** screen. You can also configure additional custom options.

### About the Code

**The main method in the script is convertData(). This method performs several operations:**

1. The script determines the run folder. The link to the run folder is attached as a result file to the sequencing step.
   * The script searches for the appropriate sequencing step and downloads the result file containing the link.
   * The script changes directories into the run folder.
2. The script gathers all the step level UDFs / custom fields from the **BCL Conversion and Demultiplexing** step.
3. Using the information gathered, the script builds the command that is executed on the BCL server. The command consists of two parts: cd (changing directory) into the run folder.
   * Executing the bcl2fastq command with the selected options.

#### Script Configuration

This script must be copied to the BCL server because the script is executed on the BCL server remote Automated Informatics (AI) / Automation Worker (AW) node.

By default, the remote AI / AW node does not come with a custom extensions folder. Therefore, if this script is the first script on the server you can create a **customextensions** folder in **/opt/gls/**.

{% hint style="info" %}
It is not recommended to have the **customextensions** folder in the **remoteai** folder as the **remoteaifolder** can get overwritten.
{% endhint %}

**When uploading the script, ensure the following:**

* The path to the bcl2fastq application is correct (line 17)
* The sequencing process type matches exactly the name of the process type / master step the artifact went through (the **-d** parameter)
* The customextensions folder contains both glsapiutil.py and glsfileutil.py modules. See [#assumptions-and-notes](#assumptions-and-notes "mention").

**Parameters**

The script accepts the following parameters:

<table data-header-hidden><thead><tr><th width="114"></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>-s</td><td>The URI of the step that launches the script - the {stepURI:v2} token (Required)</td></tr><tr><td>-d</td><td>The display name of the sequencing step (Required)</td></tr></tbody></table>

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

{% code overflow="wrap" %}

```
/usr/bin/python /opt/gls/customextensions/ kickoff_bcl2fastq2.py -u {username} -p {password} -s {stepURI:v2} -d 'Illumina Sequencing (Illumina SBS) 5.0'
```

{% endcode %}

### Assumptions and Notes

* You are running a version of Python supported by Clarity LIMS, as documented in the *Clarity LIMS Technical Requirements*.
* The attached files are placed on the LIMS server, in the **/opt/gls/clarity/customextensions** folder.
* The Python API Library (glsapiutil.py) is placed on the Clarity LIMS server, in the **/opt/gls/clarity/customextensions** folder. You can download the latest glsapiutil library from the [GitHub](https://github.com/Illumina/BaseSpace_Clarity_LIMS) page.
* 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

kickoff\_bcl2fastq2.py:

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

glsfileutil.py:

{% file src="/files/9S8pWDjvQPFomczu9AGr" %}


---

# 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.claritylims.illumina.com/api-and-database/api-docs/application-examples/page-15/invoking-bcl2fastq-from-bcl-conversion-and-demultiplexing-step.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.
