name: genome_alignment_and_quant
namespace: workflows
description: |
  A viash sub-workflow for genome alignment and quantification stage of nf-core/rnaseq pipeline.

argument_groups:
  - name: "Input"
    arguments:
    - name: "--id"
      required: true
      type: string
      description: ID of the sample.
      example: foo
    - name: "--fastq_1"
      alternatives: [-i]
      type: file
      description: Path to the sample (or read 1 of paired end sample).
      required: true
      example: input.fastq.gz
    - name: "--fastq_2"
      type: file
      required: false
      description: Path to read 2 of the sample.
    - name: "--strandedness"
      type: string 
      required: false
      description: Sample strand-specificity. Must be one of unstranded, forward, or reverse
      choices: [forward, reverse, unstranded]
    - name: "--gtf"
      type: file
      description: GTF file
    - name: "--transcript_fasta"
      type: file
      description: Fasta file of the reference transcriptome.
    - name: "--star_index"
      type: file
      description: STAR index directory.
    - name: "--star_ignore_sjdbgtf"
      type: boolean
      default: false
      description: When using pre-built STAR indices do not re-extract and use splice junctions from the GTF file 
    - name: --star_sjdb_gtf_feature_exon
      type: string
      description: Feature type in GTF file to be used as exons for building transcripts
    - name: "--bam_csi_index"
      type: boolean
      default: false
      description: Create a CSI index for BAM files instead of the traditional BAI index. This will be required for genomes with larger chromosome sizes.
    - name: "--umi_dedup_stats"
      type: boolean
      description: Generate output stats when running "umi_tools dedup".
      default: false
    - name: "--with_umi"
      type: boolean
      description: Enable UMI-based read deduplication.
      default: false
    - name: "--salmon_quant_libtype"
      type: string
      description: Override Salmon library type inferred based on strandedness defined in meta object.
    - name: "--extra_salmon_quant_args"
      type: string
      default: ''
      description: Extra arguments to pass to salmon quant command in addition to defaults defined by the pipeline.
    - name: "--gtf_group_features"
      type: string
      default: 'gene_id'
      description: Define the attribute type used to group features in the GTF file when running Salmon.
    - name: "--gtf_extra_attributes"
      type: string
      default: 'gene_name'
      description: By default, the pipeline uses the gene_name field to obtain additional gene identifiers from the input GTF file when running Salmon.
    - name: --extra_rsem_calculate_expression_args
      type: string
      description: Extra arguments to pass to rsem-calculate-expression command in addition to defaults defined by the pipeline.
    - name: "--aligner"
      type: string
      description: Specifies the alignment algorithm to use - available options are 'star_salmon', 'star_rsem' and 'hisat2'. 
      choices: [star_salmon, star_rsem, hisat2]
      default: "star_salmon"
    - name: "--rsem_index"
      type: file
      description: Path to directory for pre-built RSEM index.
    - name: "--salmon_index"
      type: file
      description: Path to directory for pre-built Salmon index.
      
  - name: "Output"
    arguments:
    - name: "--star_multiqc"
      type: file
      direction: output
      default: $id_star.log
    - name: "--genome_bam_sorted"
      type: file
      direction: output
      default: $id.genome.bam
    - name: "--genome_bam_index"
      type: file
      direction: output
      default: $id.genome.bam.bai
    - name: "--genome_bam_stats"
      type: file
      direction: output
      default: $id.genome.stats
    - name: "--genome_bam_flagstat"
      type: file
      direction: output
      default: $id.genome.flagstat
    - name: "--genome_bam_idxstats"
      type: file
      direction: output
      default: $id.genome.idxstats
    - name: "--transcriptome_bam"
      type: file
      direction: output
      default: $id.transcriptome.bam
    - name: "--transcriptome_bam_index"
      type: file
      direction: output
      default: $id.transcriptome.bam.bai
    - name: "--transcriptome_bam_stats"
      type: file
      direction: output
      default: $id.transcriptome.stats
    - name: "--transcriptome_bam_flagstat"
      type: file
      direction: output
      default: $id.transcriptome.flagstat
    - name: "--transcriptome_bam_idxstats"
      type: file
      direction: output
      default: $id.transcriptome.idxstats
    - name: "--quant_out_dir"
      type: file
      direction: output
      default: $id.salmon_quant
    - name: "--quant_results_file"
      type: file
      direction: output
      default: $id.quant.sf
    - name: "--salmon_multiqc"
      type: file
      direction: output
    - name: "--rsem_counts_gene"
      type: file
      description: Expression counts on gene level
      default: $id.genes.results
      direction: output
    - name: "--counts_transcripts"
      type: file
      description: Expression counts on transcript level
      default: $id.isoforms.results
      direction: output
    - name: "--rsem_multiqc"
      type: file
      description: RSEM statistics
      default: $id.stat
      direction: output
    - name: "--bam_star_rsem"
      type: file
      description: BAM file generated by STAR (optional)
      default: $id.STAR.genome.bam
      direction: output
    - name: "--bam_genome_rsem"
      type: file
      description: Genome BAM file (optional)
      default: $id.genome.bam
      direction: output
    - name: "--bam_transcript_rsem"
      type: file
      description: Transcript BAM file (optional)
      default: $id.transcript.bam
      direction: output
 
resources:
  - type: nextflow_script
    path: main.nf
    entrypoint: run_wf

dependencies:
  - name: star/star_align_reads
    repository: biobox
  - name: samtools/samtools_sort
    repository: biobox
  - name: samtools/samtools_index
    repository: biobox
  - name: samtools/samtools_stats
    repository: biobox
  - name: samtools/samtools_flagstat
    repository: biobox
  - name: samtools/samtools_idxstats
    repository: biobox
  - name: umi_tools/umi_tools_dedup
    repository: biobox
  - name: umi_tools/umi_tools_prepareforrsem
    repository: biobox
  - name: salmon/salmon_quant
    repository: biobox
  - name: rsem/rsem_calculate_expression
    repository: biobox

runners: 
- type: executable
- type: nextflow
