# Validate Sample Count

The Clarity LIMS NGS Extensions Package includes the *validateSampleCount* script, which checks the number of samples being input to or output by the step.

This article provides details on the script and its parameters, and LIMS configuration requirements.

## Script Overview

The script validates the number of step inputs or outputs, comparing it against configurable minimum and maximum values - determined by *-min* and *-max* parameters.

By default, the script runs in count inputs mode and validates the step inputs. If you supply the optional *-o* parameter with value set to true, the script runs in count outputs mode and validates the step outputs.

<details>

<summary>Count inputs mode</summary>

The typical use case for count inputs mode is to ensure that the correct number of samples is being input to the step.

The *validateSampleCount* script is triggered when the user clicks the Begin Work button to exit the Ice Bucket screen and start the step.

1. The script compares the number of analyte / derived sample step inputs to the *-min* and *-max* parameter values.
2. If the number of inputs:
   * Lies within the *-min* and *-max* value range, the user proceeds to the next screen.
   * Is less than the *-min* value or more than the *-max* value, user is returned to the Ice Bucket screen.

</details>

<details>

<summary>Count outputs mode</summary>

The typical use case for count outputs mode is to ensure that enough replicates (derivatives) are created to fill a flow cell:

1. The *validateSampleCount* script is triggered when the user clicks the Begin Work button to exit the Ice Bucket screen and start the step.
2. The script compares the number of step outputs to the *-min* and *-max* parameter values.
   * The script counts all per-input outputs, both analyte / derived sample and result file / measurement types.
   * The script ignores Shared ResultFiles / step file placeholders and pool outputs.
3. If the number of outputs:
   * Lies within the *-min* and *-max* value range, the user proceeds to the next screen.
   * Is less than the *-min* value or more than the *-max* value, user is returned to the Ice Bucket screen.

</details>

## Script Parameters

| **Parameter**    | **Description**                                                                                                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| -u {username}    | (Required) LIMS login username                                                                                                                                                       |
| -p {password}    | (Required) LIMS login password                                                                                                                                                       |
| -i {stepURI:v2}  | (Required) LIMS step URI                                                                                                                                                             |
| -o \<true/false> | (Optional) Set this parameter to true to run the script in count outputs mode. If the parameter is omitted or has a value other than true, the script will run in count inputs mode. |
| -min <#>         | (Optional) Specifies the minimum number of inputs / outputs required. If not provided, default minimum is 0.                                                                         |
| -max <#>         | (Optional) Specifies the maximum number of inputs / outputs required. If not provided, default maximum is 2147483647.                                                                |

## Command Line Examples

<details>

<summary>Count inputs mode</summary>

Two examples are provided below; both set the script to count inputs mode. In the first example, the *-o* parameter is provided and set to false. In the second example, the *-o* parameter is omitted.

{% code overflow="wrap" %}

```markup
bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar
-i {stepURI:v2} -u {username} -p {password} -min 7 -max 8 -o false script:validateSampleCount"
```

{% endcode %}

{% code overflow="wrap" %}

```markup
bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar
-i {stepURI:v2} -u {username} -p {password} -min 7 -max 8 script:validateSampleCount"
```

{% endcode %}

</details>

<details>

<summary>Count outputs mode</summary>

{% code overflow="wrap" %}

```markup
bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar
-i {stepURI:v2} -u {username} -p {password} -min 7 -max 8 -o true script:validateSample
```

{% endcode %}

</details>

## Configuration

The *validateSampleCount* script is intended to run when the user clicks the Begin Work button on the Ice Bucket screen and starts the step.

To achieve this, configure the automation trigger as follows:

* Trigger Location: Step
* Trigger Style: Automatic upon entry
