name: pre_processing
namespace: workflows
description: |
  A subworkflow for the pre-processing stage of the nf-core/rnaseq pipeline.
argument_groups:
  - name: Inputs
    arguments:
      - name: "--id"
        required: true
        type: string
        description: ID of the sample.
        example: foo
      - name: "--fastq_1"
        type: file
        description: Path to the sample (or read 1 of paired end sample).
        required: true
        must_exist: true
        example: input.fastq.gz
      - name: "--fastq_2"
        type: file
        required: false
        must_exist: false
        description: Path to read 2 of the sample.
      - name: "--strandedness"
        type: string 
        required: false
        default: auto
        description: Sample strand-specificity. Must be one of unstranded, forward, reverse or auto
      - name: "--bbsplit_index"
        type: file 
        description: BBsplit index 
      - name: "--ribo_database_manifest"
        type: file
        description: Text file containing paths to fasta files (one per line) that will be used to create the database for SortMeRNA.
      - name: "--transcript_fasta"
        type: file
        description: Path to FASTA transcriptome file.
      - name: "--gtf"
        type: file
        description: Path to GTF annotation file. 
      - name: "--salmon_index"
        type: file
        description: Path to directory containing the Salmon index
      - name: "--num_trimmed_reads"
        type: integer
        description: Number of reads after trimming
      
  - name: "Extra pipeline options"
    arguments:
      - name: "--skip_qc"
        type: boolean
        description: Skip QC steps of the workflow.

  - name: "FastQC options"
    arguments:
    - name: "--skip_fastqc"
      type: boolean
      description: Skip FatQC step.
      default: false

  - name: "UMI-tools options"
    arguments:
      - name: "--with_umi"
        type: boolean
        description: Enable UMI-based read deduplication.
        default: false
      - name: "--skip_umi_extract"
        type: boolean
        description: Skip umi_tools extract step.
        default: false
      - name: "--umitools_extract_method"
        type: string
        description: UMI pattern to use.
        default: string
        choices: [string, regex]
      - name: "--umitools_bc_pattern"
        type: string
        description: The UMI barcode pattern to use e.g. 'NNNNNN' indicates that the first 6 nucleotides of the read are from the UMI.
        default: ""
      - name: "--umitools_bc_pattern2"
        type: string
        description: The UMI barcode pattern to use if the UMI is located in read 2.
        default: ""
      - name: "--umi_discard_read"
        type: integer
        description: After UMI barcode extraction discard either R1 or R2 by setting this parameter to 1 or 2, respectively.
        choices: [0, 1, 2]
        default: 0
      - name: "--umitools_umi_separator"
        type: string
        description: The character that separates the UMI in the read name. Most likely a colon if you skipped the extraction with UMI-tools and used other software.
        default: "_"
      - name: "--umitools_grouping_method"
        type: string
        description: Method to use to determine read groups by subsuming those with similar UMIs. All methods start by identifying the reads with the same mapping position, but treat similar yet nonidentical UMIs differently.
        choices: [ "unique", "percentile", "cluster", "adjacency", "directional" ]
        default: "directional"
      - name: "--save_umi_intermeds"
        type: boolean
        description: If this option is specified, intermediate FastQ and BAM files produced by UMI-tools are also saved in the results directory.
        default: false

  - name: "Read trimming options"
    arguments:
      - name: "--trimmer"
        type: string
        description: Specify the trimming tool to use.
        choices: [ "trimgalore", "fastp"]
        default: "trimgalore"
      - name: "--min_trimmed_reads"
        type: integer
        description: Minimum number of trimmed reads below which samples are removed from further processing. Some downstream steps in the pipeline will fail if this threshold is too low.
        default: 10000
      - name: "--skip_trimming"
        type: boolean
        description: Skip the adapter trimming step.
        default: false
      - name: "--save_trimmed"
        type: boolean
        description: Save the trimmed FastQ files in the results directory.
        default: false
  
  - name: "Read filtering options"
    arguments: 
      - name: "--skip_bbsplit"
        type: boolean_true
        description: Skip BBSplit for removal of non-reference genome reads.
      - name: "--remove_ribo_rna"
        type: boolean_true
        description: Enable the removal of reads derived from ribosomal RNA using SortMeRNA.
  
  - name: "Output"
    arguments:
      - name: "--qc_output1"
        type: file
        direction: output
        required: false
        must_exist: false
        description: Path to output directory
        default: ${id}_r1.fastq.gz
      - name: "--qc_output2"
        type: file
        direction: output
        required: false
        must_exist: false
        description: Path to output directory
        default: ${id}_r2.fastq.gz
      - name: "--fastqc_html_1"
        type: file
        direction: output
        description: FastQC HTML report for read 1.
        required: false
        must_exist: false
        default: ${id}_r1.fastqc.html
      - name: "--fastqc_html_2"
        type: file
        direction: output
        description: FastQC HTML report for read 2.
        required: false
        must_exist: false
        default: ${id}_r2.fastqc.html
      - name: "--fastqc_zip_1"
        type: file
        direction: output
        description: FastQC report archive for read 1.
        required: false
        must_exist: false
        default: ${id}_r1.fastqc.zip
      - name: "--fastqc_zip_2"
        type: file
        direction: output
        description: FastQC report archive for read 2.
        required: false
        must_exist: false
        default: ${id}_r2.fastqc.zip
      - name: "--trim_log_1"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r1.trimming_report.txt
      - name: "--trim_log_2"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r2.trimming_report.txt
      - name: "--trim_html_1"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r1.trimmed_fastqc.html
      - name: "--trim_html_2"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r2.trimmed_fastqc.html
      - name: "--trim_zip_1"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r1.trimmed_fastqc.zip
      - name: "--trim_zip_2"
        type: file
        direction: output
        required: false
        must_exist: false
        default: ${id}_r2.trimmed_fastqc.zip
      - name: "--sortmerna_log"
        type: file
        direction: output
        default: $id.sortmerna.log
        required: false
        must_exist: false
        description: Sortmerna log file.
      - name: "--salmon_quant_output"
        type: file
        direction: output
        description: Results from Salmon quant
        default: $id.salmon_quant_output
      - name: --trim_json
        type: file
        description: The fastp json format report file name
        default: $id.fastp_out.json
        direction: output
      - name: --trim_html
        type: file
        description: The fastp html format report file name
        default: $id.fastp_out.html
        direction: output
      - name: --merged_out
        type: file
        description: File name to store merged fastp output.
        direction: output
resources:
  - type: nextflow_script
    path: main.nf
    entrypoint: run_wf

dependencies:
  - name: fastqc
    repository: biobox
  - name: umi_tools/umi_tools_extract
    repository: biobox
  - name: trimgalore
    repository: biobox
  - name: bbmap/bbmap_bbsplit
    repository: biobox
  - name: sortmerna
    repository: biobox
  - name: fastp
    repository: biobox
  - name: fq_subsample
    repository: biobox
  - name: salmon/salmon_quant
    repository: biobox
   
runners: 
- type: executable
- type: nextflow
