/*
 * --------------------------------------------------
 *  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).
 *       publish_dir    = Directory to publish results.
 *       publish_by_id  = Publish results in separate folders by meta.id value.
 *       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 {
        'sra_ids_to_runinfo' {
            publish_dir   = 'public_data'
            publish_files = ['tsv':'runinfo']
        }
        'sra_runinfo_to_ftp' {
            publish_dir   = 'public_data'
            publish_files = ['tsv':'runinfo']
        }
        'sra_fastq_ftp' {
            publish_dir   = 'public_data'
            publish_files = ['fastq.gz':'', 'md5':'md5']
        }
        'sra_to_samplesheet' {
            publish_dir   = 'public_data'
            publish_files = false
        }
        'sra_merge_samplesheet' {
            publish_dir   = 'public_data'
        }
        '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' {
            publish_files = ['log':'']
        }
        '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"
            publish_files = ['out':'log', 'tab':'log']
        }
        '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' {
            suffix        = ".sorted"
            publish_files = ['stats':'samtools_stats', 'flagstat':'samtools_stats', 'idxstats':'samtools_stats']
            publish_dir   = "${params.aligner}"
        }
        'salmon_index' {
            args          = ""
            publish_dir   = "genome/index"
        }
        'salmon_quant' {
            args          = "--validateMappings --seqBias --useVBOpt --gcBias"
        }
        'salmon_merge_counts' {
            publish_dir   = "${params.pseudo_aligner}"
        }
        'preseq_lcextrap' {
            args          = "-verbose -bam -seed 1 -seg_len 100000000"
            publish_files = ['txt':'', 'log':'log']
            publish_dir   = "${params.aligner}/preseq"
        }
        'umitools_dedup' {
            publish_files = ['tsv':'umitools']
            suffix        = ".umi_dedup.sorted"
            publish_dir   = "${params.aligner}"
        }
        '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' {
            suffix        = ".markdup.sorted"
            publish_files = ['bai':'', '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"
        }
        'featurecounts_merge_counts' {
            publish_dir   = "${params.aligner}"
        }
        'subread_featurecounts_biotype' {
            args          = "-B -C"
            publish_dir   = "${params.aligner}/featurecounts/biotype"
        }
        'multiqc_custom_biotype' {
            publish_dir   = "${params.aligner}/featurecounts/biotype"
        }
        'bedtools_genomecov' {
            publish_files = false
        }
        'ucsc_bedgraphtobigwig' {
            publish_dir   = "${params.aligner}/bigwig"
        }
        'deseq2_qc' {
            args          = "--id_col 1 --sample_suffix '' --outdir ./ --outprefix deseq2"
            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}"
        }
    }
}
