/*
========================================================================================
    Config file for defining DSL2 per module options
========================================================================================
    Available keys to override module options:
        args            = Additional arguments appended to command in module.
        args2           = Second set of arguments appended to command in module (multi-tool modules).
        args3           = Third set of arguments appended to command in module (multi-tool modules).
        publish_dir     = Directory to publish results.
        publish_by_meta = Groovy list of keys available in meta map to append as directories to "publish_dir" path
                            If publish_by_meta = true                 - Value of ${meta['id']} is appended as a directory to "publish_dir" path
                            If publish_by_meta = ['id', 'custompath'] - If "id" is in meta map and "custompath" isn't then "${meta['id']}/custompath/"
                                                                        is appended as a directory to "publish_dir" path
                            If publish_by_meta = false / null         - No directories are appended to "publish_dir" path
        publish_files   = Groovy map where key = "file_ext" and value = "directory" to publish results for that file extension
                            The value of "directory" is appended to the standard "publish_dir" path as defined above.
                            If publish_files = null (unspecified)     - All files are published.
                            If publish_files = false                  - No files are published.
        suffix          = File name suffix for output files.
----------------------------------------------------------------------------------------
*/

params {
    modules {
        'gffread' {
            args            = '--keep-exon-attrs -F -T'
            publish_dir     = 'genome'
        }
        'cat_fastq' {
            publish_dir     = 'fastq'
        }
        'fastqc' {
            args            = '--quiet'
        }
        'trimgalore' {
            args            = '--fastqc'
            publish_files   = ['txt':'', 'html':'fastqc', 'zip':'fastqc']
        }
        'umitools_extract' {
            args            = ''
            publish_files   = ['log':'']
        }
        'bbsplit_untar' {
            publish_dir     = 'genome/index'
        }
        'bbsplit_index' {
            args            = 'build=1'
            publish_dir     = 'genome/index'
        }
        'bbmap_bbsplit' {
            args            = 'build=1 ambiguous2=all maxindel=150000'
            publish_dir     = 'bbsplit'
            publish_files   = ['txt':'']
        }
        'sortmerna' {
            args            = '--num_alignments 1 --fastx -v'
            publish_files   = ['log':'']
        }
        'star_genomegenerate' {
            publish_dir     = 'genome/index'
        }
        'star_align' {
            args            = '--quantMode TranscriptomeSAM --twopassMode Basic --outSAMtype BAM Unsorted --readFilesCommand zcat --runRNGseed 0 --outFilterMultimapNmax 20 --alignSJDBoverhangMin 1 --outSAMattributes NH HI AS NM MD --quantTranscriptomeBan Singleend'
            publish_dir     = "${params.aligner}"
            publish_files   = ['out':'log', 'tab':'log']
        }
        'star_salmon_quant' {
            publish_dir     = "${params.aligner}"
        }
        'star_salmon_tx2gene' {
            publish_dir     = "${params.aligner}"
        }
        'star_salmon_tximport' {
            publish_dir     = "${params.aligner}"
            publish_by_meta = true
        }
        'star_salmon_merge_counts' {
            publish_dir     = "${params.aligner}"
        }
        'hisat2_build' {
            publish_dir     = 'genome/index'
        }
        'hisat2_align' {
            args            = '--met-stderr --new-summary --dta'
            publish_files   = ['log':'log']
        }
        'rsem_preparereference' {
            args            = '--star'
            publish_dir     = 'genome/index'
        }
        'rsem_calculateexpression' {
            args            = '--star --star-output-genome-bam --star-gzipped-read-file --estimate-rspd --seed 1'
            publish_files   = ['log':'log', 'stat':'', 'results':'']
            publish_dir     = "${params.aligner}"
        }
        'rsem_merge_counts' {
            publish_dir     = "${params.aligner}"
        }
        'samtools_sort_genome' {
            suffix          = '.sorted'
            publish_files   = [:]
            publish_dir     = "${params.aligner}"
        }
        'samtools_index_genome' {
            args            = ''
            suffix          = '.sorted'
            publish_files   = ['stats':'samtools_stats', 'flagstat':'samtools_stats', 'idxstats':'samtools_stats']
            publish_dir     = "${params.aligner}"
        }
        'samtools_sort_transcriptome' {
            suffix          = '.transcriptome.sorted'
            publish_files   = false
        }
        'samtools_index_transcriptome' {
            suffix          = '.transcriptome.sorted'
            publish_files   = false
        }
        'umitools_dedup_genome' {
            publish_files   = ['tsv':'umitools']
            suffix          = '.umi_dedup.sorted'
            publish_dir     = "${params.aligner}"
        }
        'umitools_dedup_genome_samtools' {
            args            = ''
            suffix          = '.umi_dedup.sorted'
            publish_files   = ['stats':'samtools_stats', 'flagstat':'samtools_stats', 'idxstats':'samtools_stats']
            publish_dir     = "${params.aligner}"
        }
        'umitools_dedup_transcriptome' {
            publish_files   = ['tsv':'umitools']
            suffix          = '.umi_dedup.transcriptome.sorted'
            publish_dir     = "${params.aligner}"
        }
        'umitools_dedup_transcriptome_samtools' {
            suffix          = '.umi_dedup.transcriptome.sorted'
            publish_files   = ['stats':'samtools_stats', 'flagstat':'samtools_stats', 'idxstats':'samtools_stats']
            publish_dir     = "${params.aligner}"
        }
        'umitools_dedup_transcriptome_samtools_sort_name' {
            args            = '-n'
            suffix          = '.umi_dedup.transcriptome'
            publish_files   = false
        }
        'salmon_index' {
            args            = ''
            publish_dir     = 'genome/index'
        }
        'salmon_quant' {
            args            = ''
        }
        'salmon_tx2gene' {
            args            = ''
        }
        'salmon_tximport' {
            publish_by_meta = true
        }
        'salmon_merge_counts' {
            args            = ''
        }
        'preseq_lcextrap' {
            args            = '-verbose -bam -seed 1 -seg_len 100000000'
            publish_files   = ['txt':'', 'log':'log']
            publish_dir     = "${params.aligner}/preseq"
        }
        'picard_markduplicates' {
            args            = '--ASSUME_SORTED true --REMOVE_DUPLICATES false --VALIDATION_STRINGENCY LENIENT --TMP_DIR tmp'
            suffix          = '.markdup.sorted'
            publish_files   = ['bam': '', 'metrics.txt':'picard_metrics']
            publish_dir     = "${params.aligner}"
        }
        'picard_markduplicates_samtools' {
            args            = ''
            suffix          = '.markdup.sorted'
            publish_files   = ['bai':'', 'csi':'', 'stats':'samtools_stats', 'flagstat':'samtools_stats', 'idxstats':'samtools_stats']
            publish_dir     = "${params.aligner}"
        }
        'stringtie' {
            args            = '-v'
            publish_dir     = "${params.aligner}/stringtie"
        }
        'subread_featurecounts' {
            args            = '-B -C'
            publish_dir     = "${params.aligner}/featurecounts"
        }
        'multiqc_custom_biotype' {
            publish_dir     = "${params.aligner}/featurecounts"
        }
        'bedtools_genomecov' {
            args            = '-split -du'
            publish_files   = false
        }
        'ucsc_bedclip_forward' {
            suffix          = '.clip.forward'
            publish_files   = false
        }
        'ucsc_bedclip_reverse' {
            suffix          = '.clip.reverse'
            publish_files   = false
        }
        'ucsc_bedgraphtobigwig_forward' {
            suffix          = '.forward'
            publish_dir     = "${params.aligner}/bigwig"
        }
        'ucsc_bedgraphtobigwig_reverse' {
            suffix          = '.reverse'
            publish_dir     = "${params.aligner}/bigwig"
        }
        'deseq2_qc' {
            args            = "--id_col 1 --sample_suffix '' --outprefix deseq2 --count_col 3"
            publish_files   = ['RData':'', 'pca.vals.txt':'', 'plots.pdf':'', 'sample.dists.txt':'', 'size_factors':'', 'log':'']
            publish_dir     = "${params.aligner}/deseq2_qc"
        }
        'qualimap_rnaseq' {
            publish_dir     = "${params.aligner}/qualimap"
        }
        'dupradar' {
            publish_files   = [
                'Dens.pdf':'scatter_plot', 'Boxplot.pdf':'box_plot', 'Hist.pdf':'histogram',
                'Matrix.txt':'gene_data', 'slope.txt':'intercepts_slope'
            ]
            publish_dir     = "${params.aligner}/dupradar"
        }
        'rseqc_bamstat' {
            publish_dir     = "${params.aligner}/rseqc/bam_stat"
        }
        'rseqc_innerdistance' {
            publish_files   = ['txt':'txt', 'pdf':'pdf', '.r':'rscript']
            publish_dir     = "${params.aligner}/rseqc/inner_distance"
        }
        'rseqc_inferexperiment' {
            publish_dir     = "${params.aligner}/rseqc/infer_experiment"
        }
        'rseqc_junctionannotation' {
            publish_files   = ['pdf':'pdf', '.r':'rscript', 'bed':'bed', 'xls':'xls', 'log':'log']
            publish_dir     = "${params.aligner}/rseqc/junction_annotation"
        }
        'rseqc_junctionsaturation' {
            publish_files   = ['pdf':'pdf', '.r':'rscript']
            publish_dir     = "${params.aligner}/rseqc/junction_saturation"
        }
        'rseqc_readdistribution' {
            publish_dir     = "${params.aligner}/rseqc/read_distribution"
        }
        'rseqc_readduplication' {
            publish_files   = ['pdf':'pdf', '.r':'rscript', 'xls':'xls']
            publish_dir     = "${params.aligner}/rseqc/read_duplication"
        }
        'multiqc' {
            args            = ''
            publish_dir     = "multiqc/${params.aligner}"
        }
    }
}
