/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Config file for defining DSL2 per module options and publishing paths
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Available keys to override module options:
        ext.args            = Additional arguments appended to command in module.
        ext.args2           = Second set of arguments appended to command in module (multi-tool modules).
        ext.args3           = Third set of arguments appended to command in module (multi-tool modules).
        ext.prefix          = File name prefix for output files.
        ext.when            = Conditional clause
----------------------------------------------------------------------------------------
*/

//
// Extract mitochondrial reads from bam and save them in fastq files
//

process {

    withName: '.*ALIGN:CONVERT_MT_BAM_TO_FASTQ:GATK4_PRINTREADS_MT' {
        ext.args = { [
            "-L ${params.mito_name}",
            "--read-filter MateOnSameContigOrNoMappedMateReadFilter",
            "--read-filter MateUnmappedAndUnmappedReadFilter",
            "--tmp-dir ."
        ].join(" ").trim() }
    }

    withName: '.*ALIGN:CONVERT_MT_BAM_TO_FASTQ:GATK4_REVERTSAM_MT' {
        ext.args = '--TMP_DIR . --OUTPUT_BY_READGROUP false --VALIDATION_STRINGENCY LENIENT --ATTRIBUTE_TO_CLEAR FT --ATTRIBUTE_TO_CLEAR CO --SORT_ORDER queryname --RESTORE_ORIGINAL_QUALITIES false'
    }

    withName: '.*ALIGN:CONVERT_MT_BAM_TO_FASTQ:GATK4_SAMTOFASTQ_MT' {
        ext.args = '--VALIDATION_STRINGENCY LENIENT --TMP_DIR .'
    }
}
