diff --git a/modules/minimap2/align/main.nf b/modules/minimap2/align/main.nf index fe06f14d..7ba05ee9 100644 --- a/modules/minimap2/align/main.nf +++ b/modules/minimap2/align/main.nf @@ -2,18 +2,22 @@ process MINIMAP2_ALIGN { tag "$meta.id" label 'process_medium' - conda (params.enable_conda ? 'bioconda::minimap2=2.21' : null) + conda (params.enable_conda ? 'bioconda::minimap2=2.21 bioconda::samtools=1.12' : null) container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/minimap2:2.21--h5bf99c6_0' : - 'quay.io/biocontainers/minimap2:2.21--h5bf99c6_0' }" + 'https://depot.galaxyproject.org/singularity/mulled-v2-66534bcbb7031a148b13e2ad42583020b9cd25c4:1679e915ddb9d6b4abda91880c4b48857d471bd8-0' : + 'quay.io/biocontainers/mulled-v2-66534bcbb7031a148b13e2ad42583020b9cd25c4:1679e915ddb9d6b4abda91880c4b48857d471bd8-0' }" input: tuple val(meta), path(reads) path reference + val bam_format + val cigar_paf_format + val cigar_bam output: - tuple val(meta), path("*.paf"), emit: paf - path "versions.yml" , emit: versions + tuple val(meta), path("*.paf"), optional: true, emit: paf + tuple val(meta), path("*.bam"), optional: true, emit: bam + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -22,13 +26,19 @@ process MINIMAP2_ALIGN { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def input_reads = meta.single_end ? "$reads" : "${reads[0]} ${reads[1]}" + def bam_output = bam_format ? "-a | samtools sort | samtools view -@ ${task.cpus} -b -h -o ${prefix}.bam" : "-o ${prefix}.paf" + def cigar_paf = cigar_paf_format && !sam_format ? "-c" : '' + def set_cigar_bam = cigar_bam && sam_format ? "-L" : '' """ minimap2 \\ $args \\ -t $task.cpus \\ $reference \\ $input_reads \\ - > ${prefix}.paf + $cigar_paf \\ + $set_cigar_bam \\ + $bam_output + cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/minimap2/align/meta.yml b/modules/minimap2/align/meta.yml index 89e24283..991b39a0 100644 --- a/modules/minimap2/align/meta.yml +++ b/modules/minimap2/align/meta.yml @@ -29,6 +29,17 @@ input: type: file description: | Reference database in FASTA format. + - bam_format: + type: boolean + description: Specify that output should be in BAM format + - cigar_paf_format: + type: boolean + description: Specify that output CIGAR should be in PAF format + - cigar_bam: + type: boolean + description: | + Write CIGAR with >65535 ops at the CG tag. This is recommended when + doing XYZ (https://github.com/lh3/minimap2#working-with-65535-cigar-operations) output: - meta: type: map @@ -39,9 +50,16 @@ output: type: file description: Alignment in PAF format pattern: "*.paf" + - bam: + type: file + description: Alignment in BAM format + pattern: "*.bam" - versions: type: file description: File containing software versions pattern: "versions.yml" authors: - "@heuermh" + - "@sofstam" + - "@sateeshperi" + - "@jfy133" diff --git a/tests/modules/minimap2/align/main.nf b/tests/modules/minimap2/align/main.nf index e507d3e5..ee6c0838 100644 --- a/tests/modules/minimap2/align/main.nf +++ b/tests/modules/minimap2/align/main.nf @@ -9,8 +9,11 @@ workflow test_minimap2_align_single_end { [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)] ] fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + bam_format = true + cigar_paf_format = false + cigar_bam = false - MINIMAP2_ALIGN ( input, fasta ) + MINIMAP2_ALIGN ( input, fasta, bam_format, cigar_paf_format, cigar_bam) } workflow test_minimap2_align_paired_end { @@ -19,6 +22,9 @@ workflow test_minimap2_align_paired_end { file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ] ] fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + bam_format = true + cigar_paf_format = false + cigar_bam = false - MINIMAP2_ALIGN ( input, fasta ) + MINIMAP2_ALIGN ( input, fasta, bam_format, cigar_paf_format, cigar_bam ) } diff --git a/tests/modules/minimap2/align/test.yml b/tests/modules/minimap2/align/test.yml index 73dd73e2..c392e313 100644 --- a/tests/modules/minimap2/align/test.yml +++ b/tests/modules/minimap2/align/test.yml @@ -1,17 +1,17 @@ -- name: minimap2 align single-end - command: nextflow run ./tests/modules/minimap2/align -entry test_minimap2_align_single_end -c ./tests/config/nextflow.config -c ./tests/modules/minimap2/align/nextflow.config +- name: minimap2 align test_minimap2_align_single_end + command: nextflow run tests/modules/minimap2/align -entry test_minimap2_align_single_end -c tests/config/nextflow.config tags: - minimap2 - minimap2/align files: - - path: ./output/minimap2/test.paf - md5sum: 70e8cf299ee3ecd33e629d10c1f588ce + - path: output/minimap2/test.bam + - path: output/minimap2/versions.yml -- name: minimap2 align paired-end - command: nextflow run ./tests/modules/minimap2/align -entry test_minimap2_align_paired_end -c ./tests/config/nextflow.config -c ./tests/modules/minimap2/align/nextflow.config +- name: minimap2 align test_minimap2_align_paired_end + command: nextflow run tests/modules/minimap2/align -entry test_minimap2_align_paired_end -c tests/config/nextflow.config tags: - minimap2 - minimap2/align files: - - path: ./output/minimap2/test.paf - md5sum: 5e7b55a26bf0ea3a2843423d3e0b9a28 + - path: output/minimap2/test.bam + - path: output/minimap2/versions.yml