arrow-left

All pages
gitbookPowered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

CWL Graphical Pipeline

This tutorial aims to guide you through the process of creating CWL tools and pipelines from the very beginning. By following the steps and techniques presented here, you will gain the necessary knowledge and skills to develop your own pipelines or transition existing ones to ICA.

hashtag
Build and push to ICA your own Docker image

The foundation for every tool in ICA is a Docker image (externally published or created by the user). Here we present how to create your own Docker image for the popular tool (FASTQC).

Copy the contents displayed below to a text editor and save it as a Dockerfile. Make sure you use an editor which does not add formatting to the file.

Open a terminal window, place this file in a dedicated folder and navigate to this folder location. Then use the following command:

Check the image has been successfully built:

Check that the container is functional:

Once inside the container check that the fastqc command is responsive and prints the expected help message. Remember to exit the container.

Save a tar of the previously built image locally:

Upload your docker image .tar to an ICA project (browser upload, Connector, or CLI).

circle-exclamation

In Projects > your_project > Data, select the uploaded .tar file, then click Manage > Change Format , select DOCKER and Save.

Now go outside of the Project and go to System Settings > Docker Repository, Select Create > Image. Select your docker file and fill out a name and version and set your type to tool and Press Select.

hashtag
Create a CWL tool

While outside of any Project go to System Settings > Tool Repository and Select +Create. Fill the mandatory fields (Name and Version) and look for a Docker image to link to the tool.

Tool creation in ICA adheres to the .

You can create a tool by either pasting the tool definition in the code syntax field on the right or you can use the different tabs to manually define inputs, outputs, arguments, settings, etc …

In this tutorial we will use the CWL tool syntax method. Paste the following content in the General tab.

circle-info

Other tabs, except for the Details tab can also be used.

Since the user needs to specify the output folder for FASTQC application (-o prefix), we are using the $(runtime.outdir) runtime parameter to point to the designated output folder.

hashtag
Create the pipeline

Navigate to Projects > your_project > Flow > Pipelines > +Create > CWL Graphical.

Fill the mandatory fields and click on the Definition tab to open the Graphical Editor.

Expand the Tool Repository menu (lower right) and drag your FastQC tool into the Editor field (center).

Now drag one Input and one Output file icon (on top) into the Editor field as well. Both may be given a Name (editable fields on the right when icon is selected) and need a Format attribute. Set the Input Format to fastq and Output Format to html. Connect both Input and Output files to the matching nodes on the tool itself (mouse over the node, then hold-click and drag to connect).

Press Save, you just created your first FastQC pipeline on ICA!

hashtag
Run a pipeline

First make sure you have at least one Fastq file uploaded and/or linked to your Project. You may use Fastq files available in the Bundle.

Navigate to Pipelines and select the pipeline you just created, then press Start analysis

Fill the mandatory fields and click on the + button to open the File Selection dialog box. Select one of the Fastq files available to you.

Press Start analysis on the top right, the platform is now orchestrating the pipeline execution.

hashtag
View Results

Navigate to Projects > your_project > Flow > Analyses and observe that the pipeline execution is now listed and will first be in Status Requested. After a few minutes the Status should change to In Progress and then to Succeeded.

Once this Analysis succeeds click it to enter the Analysis details view. You will see the FastQC HTML output file listed on the Output files tab. Click on the file to open Data Details view. Since it is an HTML file Format there is a View tab that allows visualizing the HTML within the browser.

FROM centos:7
WORKDIR /usr/local

# DEPENDENCIES
RUN yum -y install java-1.8.0-openjdk wget unzip perl && \
    yum clean all && \
    rm -rf /var/cache/yum

# INSTALLATION fastqc
RUN wget http://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.9.zip --no-check-certificate && \
    unzip fastqc_v0.11.9.zip && \
    chmod a+rx /usr/local/FastQC/fastqc && rm -rf fastqc_v0.11.9.zip

# Adding FastQC to the PATH
ENV PATH $PATH:/usr/local/FastQC

# DEFAULTS
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENTRYPOINT []

## how to build the docker image
## docker build --file fastqc-0.11.9.Dockerfile --tag fastqc-0.11.9:0 .
## docker run --rm -i -t --entrypoint /bin/bash fastqc-0.11.9:0
cwl standardarrow-up-right
FastQC
docker build --file fastqc-0.11.9.Dockerfile --tag fastqc-0.11.9:1 .
docker images
docker run --rm -i -t --entrypoint /bin/bash fastqc-0.11.9:1
docker save fastqc-0.11.9:1 -o fastqc-0.11.9:1.tar.gz
#!/usr/bin/env cwl-runner

# (Re)generated by BlueBee Platform

$namespaces:
  ilmn-tes: http://platform.illumina.com/rdf/iap/
cwlVersion: cwl:v1.0
class: CommandLineTool
label: FastQC
doc: FastQC aims to provide a simple way to do some quality control checks on raw
  sequence data coming from high throughput sequencing pipelines.
inputs:
  Fastq1:
    type: File
    inputBinding:
      position: 1
  Fastq2:
    type:
    - File
    - 'null'
    inputBinding:
      position: 3
outputs:
  HTML:
    type:
      type: array
      items: File
    outputBinding:
      glob:
      - '*.html'
  Zip:
    type:
      type: array
      items: File
    outputBinding:
      glob:
      - '*.zip'
arguments:
- position: 4
  prefix: -o
  valueFrom: $(runtime.outdir)
- position: 1
  prefix: -t
  valueFrom: '2'
baseCommand:
- fastqc

CWL DRAGEN Pipeline

In this tutorial, we will demonstrate how to create and launch a DRAGEN pipeline using the CWL language.

In ICA, CWL pipelines are built using tools developed in CWL. For this tutorial, we will use the "DRAGEN Demo Tool" included with DRAGEN Demo Bundle 3.9.5.

hashtag
Linking bundle to Project

1.) Start by selecting a project at the Projects inventory.

2.) In the details page, select Edit.

3.) In the edit mode of the details page, click the + button in the LINKED BUNDLES section.

4.) In the Add Bundle to Project window: Select the DRAGEN demo tool bundle from the list. Once you have selected the bundle, the Link Bundles button becomes available. Select it to continue.

Tip: You can select multiple bundles using Ctrl + Left mouse button or Shift + Left mouse button.

5.) In the project details page, the selected bundle will appear under the LINKED BUNDLES section. If you need to remove a bundle, click on the - button. Click Save to save the project with linked bundles.

hashtag
Create Pipeline

1.) From the project details page, select Pipelines > CWL

2.) You will be given options to create pipelines using a graphical interface or code. For this tutorial, we will select Graphical.

3.) Once you have selected the Graphical option, you will see a page with multiple tabs. The first tab is the Information page where you enter pipeline information. You can find the details for different fields in the tab in the . The following three fields are required for the INFORMATION page.

  • Code: Provide pipeline name here.

  • Description: Provide pipeline description here.

  • Storage size: Select the storage size from the drop-down menu.

4.) The Documentation tab provides options for configuring the HTML description for the tool. The description appears in the tool repository but is excluded from exported CWL definitions.

5.) The Definition tab is used to define the pipeline. When using graphical mode for the pipeline definition, the Definition tab provides options for configuring the pipeline using a visualization panel (A) and a list of component menus (B). You can find details on each section in the component menu

6.) To build a pipeline, start by selecting Machine PROFILE from the component menu section on the right. All fields are required and are pre-filled with default values. Change them as needed.

  • The profile Name field will be updated based on the selected Resource. You can change it as needed.

  • Color assigns the selected color to the tool in the design view to easily identify the machine profile when more than one tool is used in the pipeline.

  • Tier lets you select Standard or Economy tier for AWS instances. Standard is on-demand ec2 instance and Economy is spot ec2 instance. You can find the difference between the two AWS instances . You can find the price difference between the two Tiers

7.) Once you have selected the Machine Profile for the tool, find your tool from the Tool Repository at the bottom section of the component menu on the right. In this case, we are using the DRAGEN Demo Tool. Drag and drop the tool from the Tool Repository section to the visualization panel.

8.) The dropped tool will show the machine profile color, number of outputs and inputs, and warning to indicate missing parameters, mandatory values, and connections. Selecting the tool in the visualization panel activates the tool (DRAGEN Demo Tool) component menu. On the component menu section, you will find the details of the tool under Tool - DRAGEN Demo Tool. This section lists the inputs, outputs, additional parameters, and the machine profile required for the tool. In this case, the DRAGEN Demo Tool requires three inputs (FASTQ read 1, FASTQ read 2, and a Reference genome). The tool has two outputs (a VCF file and an output folder). The tool also has a mandatory parameter (Output File Prefix). Enter the value for the input parameter (Output File Prefix) in the text box.

9.) The top right corner of the visualization panel has icons to zoom in and out in the visualization panel followed by three icons: ref, in, and out. Based on the type of input/output needed, drag and drop the icons into the visualization area. In this case, we need three inputs (read 1, read 2, and Reference hash table.) and two outputs (VCF file and output folder). Start by dragging and dropping the first input (a). Connect the input to the tool by clicking on the blue dot at the bottom of the input icon and dragging it to the blue dot representing the first input on the tool (b). Select the input icon to activate the input component menu. The input section for the first input lets you enter the Name, Format, and other relevant information based on tool requirements. In this case, for the first input, enter the following information:

  • Name: FASTQ read 1

  • Format: FASTQ

  • Comments: any optional comments

10.) Repeat the step for other inputs. Note that the Reference hash table is treated as the input for the tool rather than Reference files. So, use the input icon instead of the reference icon.

11.) Repeat the process for two outputs by dragging and connecting them to the tool. Note that when connecting output to the tool, you will need to click on the blue dot at the bottom of the tool and drag it to the output.

12.) Select the tool and enter additional parameters. In this case, the tool requires Output File Prefix. Enter demo_ in the text box.

13.) Click on the Save button to save the pipeline. Once saved, you can run it from the Pipelines page under Flow from the left menus as any other pipeline.

.
  • Resource lets you choose from various compute resources available. In this case, we are building a DRAGEN pipeline and we will need to select a resource with FPGA in it. Choose from FPGA resources (FPGA Medium/Large) based on your needs.

  • GitBookarrow-up-right
    herearrow-up-right
    herearrow-up-right
    herearrow-up-right

    CWL CLI Pipeline Execution

    In this tutorial, we will demonstrate how to create and launch a pipeline using the CWL language using the ICA command line interface (CLI).

    hashtag
    Installation

    Please refer to these instructionsarrow-up-right for installing ICA CLI.

    hashtag
    Tutorial project

    In this project, we will create two simple tools and build a pipeline that we can run on ICA using CLI. The first tool (tool-fqTOfa.cwl) will convert a FASTQ file to a FASTA file. The second tool(tool-countLines.cwl) will count the number of lines in an input FASTA file. The workflow.cwl will combine the two tools to convert an input FASTQ file to a FASTA file and count the number of lines in the resulting FASTA file.

    Following are the two CWL tools and scripts we will use in the project. If you are new to CWL, please refer to the cwl for a better understanding of CWL codes. You will also need the cwltool installed to create these tools and processes. You can find installation instructions on the CWL page.

    hashtag
    tool-fqTOfa.cwl

    hashtag
    tool-countLines.cwl

    hashtag
    workflow.cwl

    circle-exclamation

    we don't specify the Docker image used in both tools. In such a case, the default behaviour is to use public.ecr.aws/docker/library/bash:5 image. This image contains basic functionality (sufficient to execute wc and awk commands).

    If you want to use a different public image, you can specify it using requirements tag in cwl file. Assuming you want to use *ubuntu:latest' you need to add

    If you want to use a Docker image from the ICA Docker repository, you need the link to AWS ECR from ICA GUI. Double-click on the image name in the Docker repository and copy the URL to the clipboard. Add the URL to dockerPull key.

    To add a custom or public docker image to the ICA repository, refer to the .

    hashtag
    Authentication

    Before you can use ICA CLI, you need to authenticate using the Illumina API key. Follow to authenticate.

    hashtag
    Enter/Create a Project

    Either create a project or use an existing project to create a new pipeline. You can create a new project using the icav2 projects create command.

    If you do not provide the --region flag, the value defaults to the existing region when there is only one region available. When there is more than one region available, a selection must be made from the available regions at the command prompt. The region input can be determined by calling the icav2 regions list command first.

    You can select the project to work on by entering the project using the icav2 projects enter command. Thus, you won't need to specify the project as an argument.

    You can also use the icav2 projects list command to determine the names and ids of the project you have access to.

    hashtag
    Create a pipeline on ICA

    projectpipelines is the root command to perform actions on pipelines in a project. The create command creates a pipeline in the current project.

    The parameter file specifies the input with additional parameter settings for each step in the pipeline. In this tutorial, input is a FASTQ file shown inside <dataInput> tag in the parameter file. There aren't any specific settings for the pipeline steps resulting in a parameter file below with an empty <steps> tag. Create a parameter file (parameters.xml) with the following content using a text editor.

    The following command creates a pipeline called "cli-tutorial" using the workflow.cwl, tools "tool-fqTOfa.cwl" and "tool-countLines.cwl" and parameter file "parameter.xml" with small storage size.

    Once the pipeline is created, you can view it using the list command.

    hashtag
    Running the pipeline

    Upload data to the project using the icav2 projectdata upload command. Refer to the for advanced data upload features. For this test, we will use a small FASTQ file test.fastq containing the following reads.

    The "icav2 projectdata upload" command lets you upload data to ica.

    The list command lets you view the uploaded file. Note the ID of the file you want to use with the pipeline.

    The icav2 projectpipelines start command initiates the pipeline run. The following command runs the pipeline. Write down the id for exploring the analysis later.

    If for some reason your create command fails and needs to rerun, you might get an error (ConstraintViolationException). If so, try your command with a different name.

    You can check the status of the run using the icav2 projectanalyses get command.

    The pipelines can be run using JSON input type as well. The following is an example of running pipelines using JSON input type. Note that JSON input works only with file-based CWL pipelines (built using code, not a graphical editor in ICA).

    hashtag
    Notes

    hashtag
    runtime.ram and runtime.cpu

    runtime.ram and runtime.cpu values are by default evaluated using the compute environment running the host CWL runner. CommandLineTool Steps within a CWL pipeline run on different compute environments than the host CWL runner, so the valuations of the runtime.ram and runtime.cpu for within the CommandLineTool will not match the runtime environment the tool is running in. The valuation of runtime.ram and runtime.cpu can be overridden by specifying cpuMin and ramMin in the ResourceRequirements for the CommandLineTool.

    user guidearrow-up-right
    githubarrow-up-right
    Docker Repositoryarrow-up-right
    these instructionsarrow-up-right
    Data pagearrow-up-right
    #!/usr/bin/env cwltool
    
    cwlVersion: v1.0
    class: CommandLineTool
    inputs:
      inputFastq:
        type: File
        inputBinding:
            position: 1
    stdout: test.fasta
    outputs:
      outputFasta:
        type: File
        streamable: true
        outputBinding:
            glob: test.fasta
    
    arguments:
    - 'NR%4 == 1 {print ">" substr($0, 2)}NR%4 == 2 {print}'
    baseCommand:
    - awk
    #!/usr/bin/env cwltool
    
    cwlVersion: v1.0
    class: CommandLineTool
    baseCommand: [wc, -l]
    inputs:
      inputFasta:
        type: File
        inputBinding:
            position: 1
    stdout: lineCount.tsv
    outputs:
      outputCount:
        type: File
        streamable: true
        outputBinding:
            glob: lineCount.tsv
    cwlVersion: v1.0
    class: Workflow
    inputs:
      ipFQ: File
    
    outputs:
      count_out:
        type: File
        outputSource: count/outputCount
      fqTOfaOut:
        type: File
        outputSource: convert/outputFasta
       
    steps:
      convert:
        run: tool-fqTOfa.cwl
        in:
          inputFastq: ipFQ
        out: [outputFasta]
    
      count:
        run: tool-countLines.cwl
        in:
          inputFasta: convert/outputFasta
        out: [outputCount]
    requirements:
      - class: DockerRequirement
        dockerPull: ubuntu:latest
    requirements:
      - class: DockerRequirement
        dockerPull: 079623148045.dkr.ecr.eu-central-1.amazonaws.com/cp-prod/XXXXXXXXXX:latest
    % icav2 projects create basic-cli-tutorial --region c39b1feb-3e94-4440-805e-45e0c76462bf
    % icav2 projects enter basic-cli-tutorial
    % icav2 projects list
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <pd:pipeline xmlns:pd="xsd://www.illumina.com/ica/cp/pipelinedefinition" code="" version="1.0">
        <pd:dataInputs>
            <pd:dataInput code="ipFQ" format="FASTQ" type="FILE" required="true" multiValue="false">
                <pd:label>ipFQ</pd:label>
                <pd:description></pd:description>
            </pd:dataInput>
        </pd:dataInputs>
        <pd:steps/>
    </pd:pipeline>
    % icav2 projectpipelines create cwl cli-tutorial --workflow workflow.cwl --tool tool-fqTOfa.cwl --tool tool-countLines.cwl --parameter parameters.xml --storage-size small --description "cli tutorial pipeline"
    % icav2 projectpipelines list
    ID                                   	CODE                      	DESCRIPTION                                      
    6779fa3b-e2bc-42cb-8396-32acee8b6338	cli-tutorial             	cli tutorial pipeline 
    @SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA
    +SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/
    @SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT
    +SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I
    @SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA
    +SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/
    @SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT
    +SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I
    @SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA
    +SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36
    IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/
    @SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT
    +SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36
    IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I
    % icav2 projectdata upload test.fastq /
    oldFilename= test.fastq en newFilename= test.fastq
    bucket= stratus-gds-use1  prefix= 0a488bb2-578b-404a-e09d-08d9e3343b2b/test.fastq
    Using: 1 workers to upload 1 files
    15:23:32: [0]  Uploading /Users/user1/Documents/icav2_validation/for_tutorial/working/test.fastq
    15:23:33: [0]  Uploaded /Users/user1/Documents/icav2_validation/for_tutorial/working/test.fastq to /test.fastq in 794.511591ms
    Finished uploading 1 files in 795.244677ms
    
    % icav2 projectdata list                
    PATH          NAME        TYPE  STATUS    ID                                    OWNER                                 
    /test.fastq  test.fastq FILE  AVAILABLE fil.c23246bd7692499724fe08da020b1014  4b197387-e692-4a78-9304-c7f73ad75e44
    % icav2 projectpipelines start cwl cli-tutorial --type-input STRUCTURED --input ipFQ:fil.c23246bd7692499724fe08da020b1014 --user-reference tut-test
    analysisStorage.description           1.2 TB
    analysisStorage.id                    6e1b6c8f-f913-48b2-9bd0-7fc13eda0fd0
    analysisStorage.name                  Small
    analysisStorage.ownerId               8ec463f6-1acb-341b-b321-043c39d8716a
    analysisStorage.tenantId              f91bb1a0-c55f-4bce-8014-b2e60c0ec7d3
    analysisStorage.tenantName            ica-cp-admin
    analysisStorage.timeCreated           2021-11-05T10:28:20Z
    analysisStorage.timeModified          2021-11-05T10:28:20Z
    id                                    461d3924-52a8-45ef-ab62-8b2a29621021
    ownerId                               7fa2b641-1db4-3f81-866a-8003aa9e0818
    pipeline.analysisStorage.description  1.2 TB
    pipeline.analysisStorage.id           6e1b6c8f-f913-48b2-9bd0-7fc13eda0fd0
    pipeline.analysisStorage.name         Small
    pipeline.analysisStorage.ownerId      8ec463f6-1acb-341b-b321-043c39d8716a
    pipeline.analysisStorage.tenantId     f91bb1a0-c55f-4bce-8014-b2e60c0ec7d3
    pipeline.analysisStorage.tenantName   ica-cp-admin
    pipeline.analysisStorage.timeCreated  2021-11-05T10:28:20Z
    pipeline.analysisStorage.timeModified 2021-11-05T10:28:20Z
    pipeline.code                         cli-tutorial
    pipeline.description                  Test, prepared parameters file from working GUI
    pipeline.id                           6779fa3b-e2bc-42cb-8396-32acee8b6338
    pipeline.language                     CWL
    pipeline.ownerId                      7fa2b641-1db4-3f81-866a-8003aa9e0818
    pipeline.tenantId                     d0696494-6a7b-4c81-804d-87bda2d47279
    pipeline.tenantName                   icav2-entprod
    pipeline.timeCreated                  2022-03-10T13:13:05Z
    pipeline.timeModified                 2022-03-10T13:13:05Z
    reference                             tut-test-cli-tutorial-eda7ee7a-8c65-4c0f-bed4-f6c2d21119e6
    status                                REQUESTED
    summary                               
    tenantId                              d0696494-6a7b-4c81-804d-87bda2d47279
    tenantName                            icav2-entprod
    timeCreated                           2022-03-10T20:42:42Z
    timeModified                          2022-03-10T20:42:43Z
    userReference                         tut-test
    %   icav2 projectanalyses get 461d3924-52a8-45ef-ab62-8b2a29621021
    analysisStorage.description           1.2 TB
    analysisStorage.id                    6e1b6c8f-f913-48b2-9bd0-7fc13eda0fd0
    analysisStorage.name                  Small
    analysisStorage.ownerId               8ec463f6-1acb-341b-b321-043c39d8716a
    analysisStorage.tenantId              f91bb1a0-c55f-4bce-8014-b2e60c0ec7d3
    analysisStorage.tenantName            ica-cp-admin
    analysisStorage.timeCreated           2021-11-05T10:28:20Z
    analysisStorage.timeModified          2021-11-05T10:28:20Z
    endDate                               2022-03-10T21:00:33Z
    id                                    461d3924-52a8-45ef-ab62-8b2a29621021
    ownerId                               7fa2b641-1db4-3f81-866a-8003aa9e0818
    pipeline.analysisStorage.description  1.2 TB
    pipeline.analysisStorage.id           6e1b6c8f-f913-48b2-9bd0-7fc13eda0fd0
    pipeline.analysisStorage.name         Small
    pipeline.analysisStorage.ownerId      8ec463f6-1acb-341b-b321-043c39d8716a
    pipeline.analysisStorage.tenantId     f91bb1a0-c55f-4bce-8014-b2e60c0ec7d3
    pipeline.analysisStorage.tenantName   ica-cp-admin
    pipeline.analysisStorage.timeCreated  2021-11-05T10:28:20Z
    pipeline.analysisStorage.timeModified 2021-11-05T10:28:20Z
    pipeline.code                         cli-tutorial
    pipeline.description                  Test, prepared parameters file from working GUI
    pipeline.id                           6779fa3b-e2bc-42cb-8396-32acee8b6338
    pipeline.language                     CWL
    pipeline.ownerId                      7fa2b641-1db4-3f81-866a-8003aa9e0818
    pipeline.tenantId                     d0696494-6a7b-4c81-804d-87bda2d47279
    pipeline.tenantName                   icav2-entprod
    pipeline.timeCreated                  2022-03-10T13:13:05Z
    pipeline.timeModified                 2022-03-10T13:13:05Z
    reference                             tut-test-cli-tutorial-eda7ee7a-8c65-4c0f-bed4-f6c2d21119e6
    startDate                             2022-03-10T20:42:42Z
    status                                SUCCEEDED
    summary                               
    tenantId                              d0696494-6a7b-4c81-804d-87bda2d47279
    tenantName                            icav2-entprod
    timeCreated                           2022-03-10T20:42:42Z
    timeModified                          2022-03-10T21:00:33Z
    userReference                         tut-test
     % icav2 projectpipelines start cwl cli-tutorial --data-id fil.c23246bd7692499724fe08da020b1014 --input-json '{
      "ipFQ": {
        "class": "File",
        "path": "test.fastq"
      }
    }' --type-input JSON --user-reference tut-test-json

    CWL: Scatter-gather Method

    In bioinformatics and computational biology, the vast and growing amount of data necessitates methods and tools that can process and analyze data in parallel. This demand gave birth to the scatter-gather approach, an essential pattern in creating pipelines that offers efficient data handling and parallel processing capabilities. In this tutorial, we will demonstrate how to create a CWL pipeline utilizing the scatter-gather approach. To this purpose, we will use two widely known tools: fastparrow-up-right and multiqcarrow-up-right. Given the functionalities of both fastp and multiqc, their combination in a scatter-gather pipeline is incredibly useful. Individual datasets can be scattered across resources for parallel preprocessing with fastp. Subsequently, the outputs from each of these parallel tasks can be gathered and fed into multiqc, generating a consolidated quality report. This method not only accelerates the preprocessing of large datasets but also offers an aggregated perspective on data quality, ensuring that subsequent analyses are built upon a robust foundation.

    hashtag
    Creating the tools

    First, we create the two tools: fastp and multiqc. For this, we need the corresponding Docker images and CWL tool definitions. Please, look up this of our help sites to learn more how to import a tool into ICA. In a nutshell, once the CWL tool definition is pasted into the editor, the other tabs for editing the tool will be populated. To complete the tool, the user needs to select the corresponding Docker image and to provide a tool version (could be any string).

    For this demo, we will use the publicly available Docker images: quay.io/biocontainers/fastp:0.20.0--hdbcaa40_0 for fastp and docker.io/ewels/multiqc:v1.15 for multiqc. In this one can find how to import publicly available Docker images into ICA.

    Furthermore, we will use the following CWL tool definitions:

    and

    hashtag
    Pipeline

    Once the tools are created, we will create the pipeline itself using these two tools at Projects > your_project > Flow > Pipelines > CWL > Graphical:

    • On the Definition tab, go to the tool repository and drag and drop the two tools which you just created on the pipeline editor.

    • Connect the JSON output of fastp to multiqc input by hovering over the middle of the round, blue connector of the output until the icon changes to a hand and then drag the connection to the first input of multiqc. You can use the magnification symbols to make it easier to connect these tools.

    • Above the diagram, drag and drop two input FASTQ files and an output HTML file on to the pipeline editor and connect the blue markers to match the diagram below.

    Relevant aspects of the pipeline:

    • Both inputs are multivalue (as can be seen on the screenshot)

    • Ensure that the step fastp has scattering configured: it scatters on both inputs using the scatter method 'dotproduct'. This means that as many instances of this step will be executed as there are pairs of FASTQ files. To indicate that this step is executed multiple times, the icons of both inputs have doubled borders.

    hashtag
    Important remark

    Both input arrays (Read1 and Read2) must be matched. Currently an automatic sorting of input arrays is not supported. You have to take care of matching the input arrays which can be done in either one of two ways (besides the manual specification in the GUI):

    • Invoke this pipeline in CLI using Bash functionality to sort the arrays

    • Add a tool to the pipeline which will intake array of all FASTQ files, spread them on R1 and R2 suffixes, and sort them.

    We will describe the second way in more detail. The tool will be based on public python Docker docker.io/python:3.10 and have the following definition. In this tool we are providing the Python script spread_script.py via Dirent .

    Now this tool can added to the pipeline before fastp step.

    partarrow-up-right
    tutorialarrow-up-right
    featurearrow-up-right
    fastp_multiqc
    #!/usr/bin/env cwl-runner
    
    cwlVersion: v1.0
    class: CommandLineTool
    requirements:
    - class: InlineJavascriptRequirement
    label: fastp
    doc: Modified from https://github.com/nigyta/bact_genome/blob/master/cwl/tool/fastp/fastp.cwl
    inputs:
      fastq1:
        type: File
        inputBinding:
          prefix: -i
      fastq2:
        type:
        - File
        - 'null'
        inputBinding:
          prefix: -I
      threads:
        type:
        - int
        - 'null'
        default: 1
        inputBinding:
          prefix: --thread
      qualified_phred_quality:
        type:
        - int
        - 'null'
        default: 20
        inputBinding:
          prefix: --qualified_quality_phred
      unqualified_phred_quality:
        type:
        - int
        - 'null'
        default: 20
        inputBinding:
          prefix: --unqualified_percent_limit
      min_length_required:
        type:
        - int
        - 'null'
        default: 50
        inputBinding:
          prefix: --length_required
      force_polyg_tail_trimming:
        type:
        - boolean
        - 'null'
        inputBinding:
          prefix: --trim_poly_g
      disable_trim_poly_g:
        type:
        - boolean
        - 'null'
        default: true
        inputBinding:
          prefix: --disable_trim_poly_g
      base_correction:
        type:
        - boolean
        - 'null'
        default: true
        inputBinding:
          prefix: --correction
    outputs:
      out_fastq1:
        type: File
        outputBinding:
          glob:
          - $(inputs.fastq1.nameroot).fastp.fastq
      out_fastq2:
        type:
        - File
        - 'null'
        outputBinding:
          glob:
          - $(inputs.fastq2.nameroot).fastp.fastq
      html_report:
        type: File
        outputBinding:
          glob:
          - fastp.html
      json_report:
        type: File
        outputBinding:
          glob:
          - fastp.json
    arguments:
    - prefix: -o
      valueFrom: $(inputs.fastq1.nameroot).fastp.fastq
    - |
      ${
        if (inputs.fastq2){
          return '-O';
        } else {
          return '';
        }
      }
    - |
      ${
        if (inputs.fastq2){
          return inputs.fastq2.nameroot + ".fastp.fastq";
        } else {
          return '';
        }
      }
    baseCommand:
    - fastp
    #!/usr/bin/env cwl-runner
    
    cwlVersion: cwl:v1.0
    class: CommandLineTool
    label: MultiQC
    doc: MultiQC is a tool to create a single report with interactive plots for multiple
      bioinformatics analyses across many samples.
    inputs:
      files:
        type:
        - type: array
          items: File
        - 'null'
        doc: Files containing the result of quality analysis.
        inputBinding:
          position: 2
      directories:
        type:
        - type: array
          items: Directory
        - 'null'
        doc: Directories containing the result of quality analysis.
        inputBinding:
          position: 3
      report_name:
        type: string
        doc: Name of output report, without path but with full file name (e.g. report.html).
        default: multiqc_report.html
        inputBinding:
          position: 1
          prefix: -n
    outputs:
      report:
        type: File
        outputBinding:
          glob:
          - '*.html'
    baseCommand:
    - multiqc
    #!/usr/bin/env cwl-runner
    
    cwlVersion: v1.0
    class: CommandLineTool
    requirements:
    - class: InlineJavascriptRequirement
    - class: InitialWorkDirRequirement
      listing:
      - entry: "import argparse\nimport os\nimport json\n\n# Create argument parser\n\
          parser = argparse.ArgumentParser()\nparser.add_argument(\"-i\", \"--inputFiles\"\
          , type=str, required=True, help=\"Input files\")\n\n# Parse the arguments\n\
          args = parser.parse_args()\n\n# Split the inputFiles string into a list of file\
          \ paths\ninput_files = args.inputFiles.split(',')\n\n# Sort the input files\
          \ by the base filename\ninput_files = sorted(input_files, key=lambda x: os.path.basename(x))\n\
          \n\n# Separate the files into left and right arrays, preserving the order\n\
          left_files = [file for file in input_files if '_R1_' in os.path.basename(file)]\n\
          right_files = [file for file in input_files if '_R2_' in os.path.basename(file)]\n\
          \n# Print the left files for debugging\nprint(\"Left files:\", left_files)\n\
          \n# Print the left files for debugging\nprint(\"Right files:\", right_files)\n\
          \n# Ensure left and right files are matched\nassert len(left_files) == len(right_files),\
          \ \"Mismatch in number of left and right files\"\n\n    \n# Write the left files\
          \ to a JSON file\nwith open('left_files.json', 'w') as outfile:\n    left_files_objects\
          \ = [{\"class\": \"File\", \"path\": file} for file in left_files]\n    json.dump(left_files_objects,\
          \ outfile)\n\n# Write the right files to a JSON file\nwith open('right_files.json',\
          \ 'w') as outfile:\n    right_files_objects = [{\"class\": \"File\", \"path\"\
          : file} for file in right_files]\n    json.dump(right_files_objects, outfile)\n\
          \n"
        entryname: spread_script.py
        writable: false
    label: spread_items
    inputs:
      inputFiles:
        type:
          type: array
          items: File
        inputBinding:
          separate: false
          prefix: -i
          itemSeparator: ','
    outputs:
      leftFiles:
        type:
          type: array
          items: File
        outputBinding:
          glob:
          - left_files.json
          loadContents: true
          outputEval: $(JSON.parse(self[0].contents))
      rightFiles:
        type:
          type: array
          items: File
        outputBinding:
          glob:
          - right_files.json
          loadContents: true
          outputEval: $(JSON.parse(self[0].contents))
    baseCommand:
    - python3
    - spread_script.py