# Publishing Files to LabLink

Some steps produce data that you would like your collaborators to have access to.

This example provides an alternative method and uses a script to publish the files programmatically via the API.

### Solution <a href="#h_fe2859dd-abcd-43aa-b9d9-215ad6adda88" id="h_fe2859dd-abcd-43aa-b9d9-215ad6adda88"></a>

In this example, suppose we have a protocol step, based upon a Sanger/capillary sequencing workflow, that produces up to two files per sample (a **.seq** and a **.ab1** file).

Our example script runs at the end of the protocol step. The script publishes the output files so that they are available to collaborators in the LabLink **Collaborations Interface**.

#### Parameters <a href="#h_ba091a88-b9a4-464f-bcd9-3176378b45ec" id="h_ba091a88-b9a4-464f-bcd9-3176378b45ec"></a>

The EPP / automation command is configured to pass the following parameters:

<table data-header-hidden><thead><tr><th width="95"></th><th></th></tr></thead><tbody><tr><td><strong>-u</strong></td><td><strong>The username of the current user (Required)</strong></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 protocol step that launches the script - the {stepURI:v2:http} token (Required)</td></tr></tbody></table>

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

{% code overflow="wrap" %}

```
bash -l -c "/usr/bin/python /opt/gls/clarity/customextensions/publishFilesToLabLink.py -u admin -p securepassword -s https://demo-5-1.claritylims.com/api/v2/steps/24-7953"
```

{% endcode %}

### User Interaction <a href="#h_8d362984-f067-4b0e-b522-06c569628540" id="h_8d362984-f067-4b0e-b522-06c569628540"></a>

After the script has completed its execution, collaborators are able to view and download the files from the LabLink **Collaborations Interface**.

![Publishing\_files\_to\_Lablink1.png](https://genologics.zendesk.com/attachments/token/L1hEH3m4IrK9FZ5IAu3EotAxb/?name=Publishing_files_to_Lablink1.png)

### About the code <a href="#h_3570cae4-f29f-4362-8dbc-b9c3d80b314c" id="h_3570cae4-f29f-4362-8dbc-b9c3d80b314c"></a>

The main method used in the script is **publishFiles()**. The method in turn carries out several operations:

1. The limsids of the steps' artifacts are gathered, and the artifacts are retrieved, in a single transaction using the 'batch' method.
2. Each artifact is investigated. If there is an associated file resource, its limsid is stored.
3. The files resources are retrieved in a single transaction using the 'batch' method.
4. For each file resource, the value of the \<is-published> node is set to 'true'.
5. The files resources are saved back to Clarity LIMS in a single transaction using the 'batch' method.

### Assumptions & notes <a href="#h_861538b2-916f-4603-92f4-367491910571" id="h_861538b2-916f-4603-92f4-367491910571"></a>

* The attached file is placed on the Clarity 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 our [GitHub page](https://github.com/Illumina/BaseSpace_Clarity_LIMS).
* 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 <a href="#h_3d860426-2586-43b0-94b5-45280ac7f698" id="h_3d860426-2586-43b0-94b5-45280ac7f698"></a>

publishFilesToLabLink.py:

{% file src="<https://2084401275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfjuebS41N49G1Eh55hP7%2Fuploads%2Fgit-blob-fad5b9f103184e6d0817af999c363479e5c5125d%2FpublishFilesToLabLink.py?alt=media&token=19152bce-23ef-45a5-8a0d-8467ca664f54>" %}

publishFilesToLabLink\_v2.py:

{% file src="<https://2084401275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfjuebS41N49G1Eh55hP7%2Fuploads%2Fgit-blob-cff58aaf1bef8cc938ba9ae1b681b11b8e1e1aa7%2FpublishFilesToLabLink_v2.py?alt=media&token=7dd83099-5a02-4c6e-b88d-63a7dee968d9>" %}


---

# 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/publishing-files-to-lablink.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.
