# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: fastq_align_bwa
description: Align reads to a reference genome using bwa then sort with samtools
keywords:
  - align
  - fasta
  - genome
  - reference
modules:
  - bwa/align
  - samtools/sort
  - samtools/index
  - samtools/stats
  - samtools/idxstats
  - samtools/flagstat
input:
  - ch_reads:
      description: |
        List of input FastQ files of size 1 and 2 for single-end and paired-end data,
        respectively.
        Structure: [ val(meta), [ path(reads) ] ]
  - ch_index:
      description: |
        BWA genome index files
        Structure: [ val(meta2), path(index) ]
  - val_sort_bam:
      type: boolean
      description: If true bwa modules sort resulting bam files
      pattern: "true|false"
  - ch_fasta:
      type: file
      description: |
        Optional reference fasta file. This only needs to be given if val_sort_bam = true
        Structure: [ path(fasta) ]

output:
  - bam_orig:
      description: |
        BAM file produced by bwa
        Structure: [ val(meta), path(bam) ]
  - bam:
      description: |
        BAM file ordered by samtools
        Structure: [ val(meta), path(bam) ]
  - bai:
      description: |
        BAI index of the ordered BAM file
        Structure: [ val(meta), path(bai) ]
  - csi:
      description: |
        CSI index of the ordered BAM file
        Structure: [ val(meta), path(csi) ]
  - stats:
      description: |
        File containing samtools stats output
        Structure: [ val(meta), path(stats) ]
  - flagstat:
      description: |
        File containing samtools flagstat output
        Structure: [ val(meta), path(flagstat) ]
  - idxstats:
      description: |
        File containing samtools idxstats output
        Structure: [ val(meta), path(idxstats) ]
  - versions:
      description: |
        Files containing software versions
        Structure: [ path(versions.yml) ]
authors:
  - "@JoseEspinosa"
