From 2fe3210f88ca8aea591075a7636f1257e644e992 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 09:27:59 -0800 Subject: [PATCH 01/25] Add ivar variants --- software/ivar/variants/functions.nf | 59 +++++++++++++++++++++++++++++ software/ivar/variants/main.nf | 53 ++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 software/ivar/variants/functions.nf create mode 100644 software/ivar/variants/main.nf diff --git a/software/ivar/variants/functions.nf b/software/ivar/variants/functions.nf new file mode 100644 index 00000000..d25eea86 --- /dev/null +++ b/software/ivar/variants/functions.nf @@ -0,0 +1,59 @@ +/* + * ----------------------------------------------------- + * Utility functions used in nf-core DSL2 module files + * ----------------------------------------------------- + */ + +/* + * Extract name of software tool from process name using $task.process + */ +def getSoftwareName(task_process) { + return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase() +} + +/* + * Function to initialise default values and to generate a Groovy Map of available options for nf-core modules + */ +def initOptions(Map args) { + def Map options = [:] + options.args = args.args ?: '' + options.args2 = args.args2 ?: '' + options.publish_by_id = args.publish_by_id ?: false + options.publish_dir = args.publish_dir ?: '' + options.publish_files = args.publish_files + options.suffix = args.suffix ?: '' + return options +} + +/* + * Tidy up and join elements of a list to return a path string + */ +def getPathFromList(path_list) { + def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries + paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes + return paths.join('/') +} + +/* + * Function to save/publish module results + */ +def saveFiles(Map args) { + if (!args.filename.endsWith('.version.txt')) { + def ioptions = initOptions(args.options) + def path_list = [ ioptions.publish_dir ?: args.publish_dir ] + if (ioptions.publish_by_id) { + path_list.add(args.publish_id) + } + if (ioptions.publish_files instanceof Map) { + for (ext in ioptions.publish_files) { + if (args.filename.endsWith(ext.key)) { + def ext_list = path_list.collect() + ext_list.add(ext.value) + return "${getPathFromList(ext_list)}/$args.filename" + } + } + } else if (ioptions.publish_files == null) { + return "${getPathFromList(path_list)}/$args.filename" + } + } +} diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf new file mode 100644 index 00000000..93e8d36c --- /dev/null +++ b/software/ivar/variants/main.nf @@ -0,0 +1,53 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +def options = initOptions(params.options) + +process IVAR_VARIANTS { + tag "$meta.id" + label 'process_medium' + publishDir "${params.outdir}", + mode: params.publish_dir_mode, + saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + + conda (params.enable_conda ? "bioconda::ivar=1.3.1" : null) + + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/1.3.1--h089eab3_0" + } else { + container "quay.io/biocontainers/1.3.1--h089eab3_0" + } + + input: + tuple val(meta), path(bam) + path fasta + path gff_file + + output: + tuple val(meta), path("*.tsv"), emit: variants + tuple val(meta), path("*.mpileup"), emit: mpileup + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def save_mpileup = params.save_mpileup ? "tee ${prefix}.mpileup |" : "" + // the gff file is optional, so following the pattern suggested here: + //https://github.com/nextflow-io/patterns/blob/master/docs/optional-input.adoc + def gff = gff_file.name != 'NO_FILE' ? "-g $gff_file" : "" + """ + samtools mpileup \\ + $options.args2 \\ + --reference $fasta \\ + $bam | \\ + $save_mpileup \\ + ivar variants \\ + $options.args \\ + $gff \\ + -r $fasta \\ + -p $prefix + + ivar version | head -n1 2>&1 | sed 's/^.*iVar version //g' > ${software}.version.txt + """ +} From 4ab3ccc9054f19c855f9cef8bdac109c5725a5c3 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 09:28:10 -0800 Subject: [PATCH 02/25] Add ivar variants --- .github/filters.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/filters.yml b/.github/filters.yml index 5a1ed42e..fa37f990 100644 --- a/.github/filters.yml +++ b/.github/filters.yml @@ -136,6 +136,10 @@ ivar_trim: - software/ivar/trim/** - tests/software/ivar/trim/** +ivar_variants: + - software/ivar/variants/** + - tests/software/ivar/variants/** + minimap2_align: - software/minimap2/align/** - tests/software/minimap2/align/** From 9e3c4e598cd48b9d950d47ced301c6d93410aaf0 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 09:29:10 -0800 Subject: [PATCH 03/25] Add meta to ivar variants --- software/ivar/variants/meta.yml | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 software/ivar/variants/meta.yml diff --git a/software/ivar/variants/meta.yml b/software/ivar/variants/meta.yml new file mode 100644 index 00000000..2b815ec1 --- /dev/null +++ b/software/ivar/variants/meta.yml @@ -0,0 +1,68 @@ +name: ivar_variants +description: Call variants from a BAM file using iVar +keywords: + - amplicon sequencing + - variants + - fasta +tools: + - ivar: + description: | + iVar - a computational package that contains functions broadly useful for viral amplicon-based sequencing. + homepage: https://github.com/andersen-lab/ivar + documentation: https://andersen-lab.github.io/ivar/html/manualpage.html +params: + - outdir: + type: string + description: | + The pipeline's output directory. By default, the module will + output files into `$params.outdir/` + - publish_dir_mode: + type: string + description: | + Value for the Nextflow `publishDir` mode parameter. + Available: symlink, rellink, link, copy, copyNoFollow, move. + - enable_conda: + type: boolean + description: | + Run the module with Conda using the software specified + via the `conda` directive + - singularity_pull_docker_container: + type: boolean + description: | + Instead of directly downloading Singularity images for use with Singularity, + force the workflow to pull and convert Docker containers instead. +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: A sorted (with samtools sort) and trimmed (with iVar trim) bam file + pattern: "*.bam" + - fasta: + type: file + description: The reference sequence used for mapping and generating the BAM file + pattern: "*.fa" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - variants: + type: file + description: iVar generated TSV file with the variants + pattern: "*.tsv" + - mpileup: + type: file + description: mpileup output from samtools mpileup [OPTIONAL] + pattern: "*.mpileup" + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" +authors: + - "@andersgs" + - "@drpatelh" From 4af7414419f8024e45f967f8cba13e60e24be43a Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 09:29:40 -0800 Subject: [PATCH 04/25] Add tests for ivar variants --- tests/data/gff/sarscov2/MN908947.3.gff3 | 27 +++++++++++++++++++++++++ tests/software/ivar/variants/main.nf | 25 +++++++++++++++++++++++ tests/software/ivar/variants/test.yml | 21 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/data/gff/sarscov2/MN908947.3.gff3 create mode 100644 tests/software/ivar/variants/main.nf create mode 100644 tests/software/ivar/variants/test.yml diff --git a/tests/data/gff/sarscov2/MN908947.3.gff3 b/tests/data/gff/sarscov2/MN908947.3.gff3 new file mode 100644 index 00000000..d5cf08a5 --- /dev/null +++ b/tests/data/gff/sarscov2/MN908947.3.gff3 @@ -0,0 +1,27 @@ +##sequence-region MN908947.3 1 29903 +##species https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=2697049 +MN908947.3 Genbank region 1 29903 . + . ID=MN908947.3:1..29903;Dbxref=taxon:2697049;collection-date=Dec-2019;country=China;gb-acronym=SARS-CoV-2;gbkey=Src;genome=genomic;isolate=Wuhan-Hu-1;mol_type=genomic RNA;nat-host=Homo sapiens;old-name=Wuhan seafood market pneumonia virus +MN908947.3 Genbank five_prime_UTR 1 265 . + . ID=id-MN908947.3:1..265;gbkey=5'UTR +MN908947.3 Genbank gene 266 21555 . + . ID=gene-orf1ab;Name=orf1ab;gbkey=Gene;gene=orf1ab;gene_biotype=protein_coding +MN908947.3 Genbank CDS 266 13468 . + 0 ID=cds-QHD43415.1;Parent=gene-orf1ab;Dbxref=NCBI_GP:QHD43415.1;Name=QHD43415.1;Note=translated by -1 ribosomal frameshift;exception=ribosomal slippage;gbkey=CDS;gene=orf1ab;part=1;product=orf1ab polyprotein;protein_id=QHD43415.1 +MN908947.3 Genbank CDS 13468 21555 . + 0 ID=cds-QHD43415.1;Parent=gene-orf1ab;Dbxref=NCBI_GP:QHD43415.1;Name=QHD43415.1;Note=translated by -1 ribosomal frameshift;exception=ribosomal slippage;gbkey=CDS;gene=orf1ab;part=2;product=orf1ab polyprotein;protein_id=QHD43415.1 +MN908947.3 Genbank gene 21563 25384 . + . ID=gene-S;Name=S;gbkey=Gene;gene=S;gene_biotype=protein_coding +MN908947.3 Genbank CDS 21563 25384 . + 0 ID=cds-QHD43416.1;Parent=gene-S;Dbxref=NCBI_GP:QHD43416.1;Name=QHD43416.1;Note=structural protein;gbkey=CDS;gene=S;product=surface glycoprotein;protein_id=QHD43416.1 +MN908947.3 Genbank gene 25393 26220 . + . ID=gene-ORF3a;Name=ORF3a;gbkey=Gene;gene=ORF3a;gene_biotype=protein_coding +MN908947.3 Genbank CDS 25393 26220 . + 0 ID=cds-QHD43417.1;Parent=gene-ORF3a;Dbxref=NCBI_GP:QHD43417.1;Name=QHD43417.1;gbkey=CDS;gene=ORF3a;product=ORF3a protein;protein_id=QHD43417.1 +MN908947.3 Genbank gene 26245 26472 . + . ID=gene-E;Name=E;gbkey=Gene;gene=E;gene_biotype=protein_coding +MN908947.3 Genbank CDS 26245 26472 . + 0 ID=cds-QHD43418.1;Parent=gene-E;Dbxref=NCBI_GP:QHD43418.1;Name=QHD43418.1;Note=structural protein%3B E protein;gbkey=CDS;gene=E;product=envelope protein;protein_id=QHD43418.1 +MN908947.3 Genbank gene 26523 27191 . + . ID=gene-M;Name=M;gbkey=Gene;gene=M;gene_biotype=protein_coding +MN908947.3 Genbank CDS 26523 27191 . + 0 ID=cds-QHD43419.1;Parent=gene-M;Dbxref=NCBI_GP:QHD43419.1;Name=QHD43419.1;Note=structural protein;gbkey=CDS;gene=M;product=membrane glycoprotein;protein_id=QHD43419.1 +MN908947.3 Genbank gene 27202 27387 . + . ID=gene-ORF6;Name=ORF6;gbkey=Gene;gene=ORF6;gene_biotype=protein_coding +MN908947.3 Genbank CDS 27202 27387 . + 0 ID=cds-QHD43420.1;Parent=gene-ORF6;Dbxref=NCBI_GP:QHD43420.1;Name=QHD43420.1;gbkey=CDS;gene=ORF6;product=ORF6 protein;protein_id=QHD43420.1 +MN908947.3 Genbank gene 27394 27759 . + . ID=gene-ORF7a;Name=ORF7a;gbkey=Gene;gene=ORF7a;gene_biotype=protein_coding +MN908947.3 Genbank CDS 27394 27759 . + 0 ID=cds-QHD43421.1;Parent=gene-ORF7a;Dbxref=NCBI_GP:QHD43421.1;Name=QHD43421.1;gbkey=CDS;gene=ORF7a;product=ORF7a protein;protein_id=QHD43421.1 +MN908947.3 Genbank gene 27894 28259 . + . ID=gene-ORF8;Name=ORF8;gbkey=Gene;gene=ORF8;gene_biotype=protein_coding +MN908947.3 Genbank CDS 27894 28259 . + 0 ID=cds-QHD43422.1;Parent=gene-ORF8;Dbxref=NCBI_GP:QHD43422.1;Name=QHD43422.1;gbkey=CDS;gene=ORF8;product=ORF8 protein;protein_id=QHD43422.1 +MN908947.3 Genbank gene 28274 29533 . + . ID=gene-N;Name=N;gbkey=Gene;gene=N;gene_biotype=protein_coding +MN908947.3 Genbank CDS 28274 29533 . + 0 ID=cds-QHD43423.2;Parent=gene-N;Dbxref=NCBI_GP:QHD43423.2;Name=QHD43423.2;Note=structural protein;gbkey=CDS;gene=N;product=nucleocapsid phosphoprotein;protein_id=QHD43423.2 +MN908947.3 Genbank gene 29558 29674 . + . ID=gene-ORF10;Name=ORF10;gbkey=Gene;gene=ORF10;gene_biotype=protein_coding +MN908947.3 Genbank CDS 29558 29674 . + 0 ID=cds-QHI42199.1;Parent=gene-ORF10;Dbxref=NCBI_GP:QHI42199.1;Name=QHI42199.1;gbkey=CDS;gene=ORF10;product=ORF10 protein;protein_id=QHI42199.1 +MN908947.3 Genbank three_prime_UTR 29675 29903 . + . ID=id-MN908947.3:29675..29903;gbkey=3'UTR + diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf new file mode 100644 index 00000000..dca23033 --- /dev/null +++ b/tests/software/ivar/variants/main.nf @@ -0,0 +1,25 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +params.save_mpileup = true + +include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) + +workflow test_ivar_variants_no_gff { + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def gff = file('NO_FILE') + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] + IVAR_VARIANTS ( input, ref, gff ) +} + +workflow test_ivar_variants_with_gff { + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkIfExists: true) + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] + IVAR_VARIANTS ( input, ref, gff ) +} diff --git a/tests/software/ivar/variants/test.yml b/tests/software/ivar/variants/test.yml new file mode 100644 index 00000000..86f833a6 --- /dev/null +++ b/tests/software/ivar/variants/test.yml @@ -0,0 +1,21 @@ +- name: ivar variants no gff + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff -c tests/config/nextflow.config + tags: + - ivar + - ivar_variants + files: + - path: output/ivar/test.tsv + md5sum: 3fd376b8ad80f27a999edf3345d2014a + - path: output/ivar/test.mpileup + md5sum: b3dfd337dfcd313d6cc9680d7e796fe6 + +- name: ivar variants with gff + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_with_gff -c tests/config/nextflow.config + tags: + - ivar + - ivar_variants + files: + - path: output/ivar/test.tsv + md5sum: 3fd376b8ad80f27a999edf3345d2014a + - path: output/ivar/test.mpileup + md5sum: b3dfd337dfcd313d6cc9680d7e796fe6 \ No newline at end of file From e8d1171b5d85768a84397bf478ce182fd83a74ce Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 11:50:52 -0800 Subject: [PATCH 05/25] Make gff a param and not an optional input --- software/ivar/variants/main.nf | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 93e8d36c..71d3bf05 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -22,7 +22,6 @@ process IVAR_VARIANTS { input: tuple val(meta), path(bam) path fasta - path gff_file output: tuple val(meta), path("*.tsv"), emit: variants @@ -32,10 +31,8 @@ process IVAR_VARIANTS { script: def software = getSoftwareName(task.process) def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" - def save_mpileup = params.save_mpileup ? "tee ${prefix}.mpileup |" : "" - // the gff file is optional, so following the pattern suggested here: - //https://github.com/nextflow-io/patterns/blob/master/docs/optional-input.adoc - def gff = gff_file.name != 'NO_FILE' ? "-g $gff_file" : "" + def save_mpileup = params.containsKey('save_mpileup') ? "tee ${prefix}.mpileup |" : "" + def gff = params.containsKey('gff') ? "-g ${params.get('gff')}" : "" """ samtools mpileup \\ $options.args2 \\ From 9a5aa0f1452f3dd310df58c4099f73d9d4b4ddb1 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 11:51:04 -0800 Subject: [PATCH 06/25] Fix tests to work with gff param --- tests/software/ivar/variants/main.nf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index dca23033..520cdae1 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -8,18 +8,19 @@ include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addP workflow test_ivar_variants_no_gff { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) - def gff = file('NO_FILE') def input = [] input = [ [ id:'test'], file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] - IVAR_VARIANTS ( input, ref, gff ) + IVAR_VARIANTS ( input, ref ) } +params.gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkIfExists: true) + workflow test_ivar_variants_with_gff { + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) - def gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkIfExists: true) def input = [] input = [ [ id:'test'], file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] - IVAR_VARIANTS ( input, ref, gff ) + IVAR_VARIANTS ( input, ref ) } From f841483a706710f27597f8a2770711f3887d76fa Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 13:23:35 -0800 Subject: [PATCH 07/25] Fix URL for containers --- software/ivar/variants/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 71d3bf05..3ada428e 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -14,9 +14,9 @@ process IVAR_VARIANTS { conda (params.enable_conda ? "bioconda::ivar=1.3.1" : null) if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { - container "https://depot.galaxyproject.org/singularity/1.3.1--h089eab3_0" + container "https://depot.galaxyproject.org/singularity/ivar:1.3.1--h089eab3_0" } else { - container "quay.io/biocontainers/1.3.1--h089eab3_0" + container "quay.io/biocontainers/ivar:1.3.1--h089eab3_0" } input: From ef1e1b25390e4b8515f93d1bf96113db44bc7923 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:51:45 -0800 Subject: [PATCH 08/25] Fix indentation Co-authored-by: Harshil Patel --- software/ivar/variants/main.nf | 1 - 1 file changed, 1 deletion(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 3ada428e..d285f9c9 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -12,7 +12,6 @@ process IVAR_VARIANTS { saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } conda (params.enable_conda ? "bioconda::ivar=1.3.1" : null) - if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { container "https://depot.galaxyproject.org/singularity/ivar:1.3.1--h089eab3_0" } else { From 6259b7208164d47fe391086e3766a13d6900190d Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:52:30 -0800 Subject: [PATCH 09/25] Fix output format Co-authored-by: Harshil Patel --- software/ivar/variants/main.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index d285f9c9..1777874e 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -23,9 +23,9 @@ process IVAR_VARIANTS { path fasta output: - tuple val(meta), path("*.tsv"), emit: variants - tuple val(meta), path("*.mpileup"), emit: mpileup - path "*.version.txt" , emit: version + tuple val(meta), path("*.tsv") , emit: tsv + tuple val(meta), path("*.mpileup"), optional:true, emit: mpileup + path "*.version.txt" , emit: version script: def software = getSoftwareName(task.process) From 8c483d4c6ab793ce57b2b824e1bd3c4e1048665b Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:53:13 -0800 Subject: [PATCH 10/25] Add gff as input for proper staging Co-authored-by: Harshil Patel --- software/ivar/variants/main.nf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 1777874e..6fe755a2 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -20,7 +20,8 @@ process IVAR_VARIANTS { input: tuple val(meta), path(bam) - path fasta + path fasta + path gff output: tuple val(meta), path("*.tsv") , emit: tsv From 4f8ab8bd6981098802807d31cbcaafeecbffee1f Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:53:30 -0800 Subject: [PATCH 11/25] Rename gff to features Co-authored-by: Harshil Patel --- software/ivar/variants/main.nf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 6fe755a2..531db710 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -40,10 +40,10 @@ process IVAR_VARIANTS { $bam | \\ $save_mpileup \\ ivar variants \\ - $options.args \\ - $gff \\ - -r $fasta \\ - -p $prefix + $options.args \\ + $features \\ + -r $fasta \\ + -p $prefix ivar version | head -n1 2>&1 | sed 's/^.*iVar version //g' > ${software}.version.txt """ From 8b6989f2d75412a51d368710be968d073fb52e3b Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:54:19 -0800 Subject: [PATCH 12/25] Add gff as input Co-authored-by: Harshil Patel --- tests/software/ivar/variants/main.nf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 520cdae1..49278623 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -19,8 +19,9 @@ params.gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkI workflow test_ivar_variants_with_gff { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def gff = file(params.gff, checkIfExists: true) def input = [] input = [ [ id:'test'], - file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] - IVAR_VARIANTS ( input, ref ) + file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] + IVAR_VARIANTS ( input, ref, gff ) } From 39401ccd075c9e27a26b8a395b83fe8128768512 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:54:36 -0800 Subject: [PATCH 13/25] Add gff as input Co-authored-by: Harshil Patel --- tests/software/ivar/variants/main.nf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 49278623..d2300e29 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -7,11 +7,12 @@ params.save_mpileup = true include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) workflow test_ivar_variants_no_gff { - def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) def input = [] input = [ [ id:'test'], - file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] - IVAR_VARIANTS ( input, ref ) + file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] + IVAR_VARIANTS ( input, ref, dummy ) } params.gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkIfExists: true) From ee4c2828a0c5ac1faa608e18d3c8dd0e1f35af02 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:55:12 -0800 Subject: [PATCH 14/25] Update gff assignment to string Co-authored-by: Harshil Patel --- tests/software/ivar/variants/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index d2300e29..f707ae70 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -15,7 +15,7 @@ workflow test_ivar_variants_no_gff { IVAR_VARIANTS ( input, ref, dummy ) } -params.gff = file("${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3", checkIfExists: true) +params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" workflow test_ivar_variants_with_gff { From 3188b8e30ec382ccaeb23560f4deb2a6a7928ce7 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:55:34 -0800 Subject: [PATCH 15/25] Add explicit gff is false param Co-authored-by: Harshil Patel --- tests/software/ivar/variants/main.nf | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index f707ae70..bc660905 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -3,6 +3,7 @@ nextflow.enable.dsl = 2 params.save_mpileup = true +params.gff = false include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) From 26189f41322291c4559c1d10574f257f3a1d643e Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 19:56:22 -0800 Subject: [PATCH 16/25] Change ternary expressions back to traditional format Co-authored-by: Harshil Patel --- software/ivar/variants/main.nf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/software/ivar/variants/main.nf b/software/ivar/variants/main.nf index 531db710..1f940d67 100644 --- a/software/ivar/variants/main.nf +++ b/software/ivar/variants/main.nf @@ -29,10 +29,10 @@ process IVAR_VARIANTS { path "*.version.txt" , emit: version script: - def software = getSoftwareName(task.process) - def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" - def save_mpileup = params.containsKey('save_mpileup') ? "tee ${prefix}.mpileup |" : "" - def gff = params.containsKey('gff') ? "-g ${params.get('gff')}" : "" + def software = getSoftwareName(task.process) + def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def save_mpileup = params.save_mpileup ? "tee ${prefix}.mpileup |" : "" + def features = params.gff ? "-g $gff" : "" """ samtools mpileup \\ $options.args2 \\ From c12a558f15aa44865490fe946a58f00686d29cfc Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 20:49:27 -0800 Subject: [PATCH 17/25] Add tests without mpileup --- tests/software/ivar/variants/main.nf | 23 ++++++++++++++++++----- tests/software/ivar/variants/test.yml | 17 +++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index bc660905..e1d51c55 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -2,12 +2,12 @@ nextflow.enable.dsl = 2 -params.save_mpileup = true -params.gff = false - include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) -workflow test_ivar_variants_no_gff { +params.save_mpileup = false +params.gff = false + +workflow test_ivar_variants_no_gff_no_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) def input = [] @@ -16,9 +16,22 @@ workflow test_ivar_variants_no_gff { IVAR_VARIANTS ( input, ref, dummy ) } +params.save_mpileup = true +params.gff = false + +workflow test_ivar_variants_no_gff_with_mpileup { + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) + def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bam/test-sc2-artic-v3-sorted-trimmed.bam", checkIfExists: true) ] + IVAR_VARIANTS ( input, ref, dummy ) +} + +params.save_mpileup = true params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" -workflow test_ivar_variants_with_gff { +workflow test_ivar_variants_with_gff_with_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def gff = file(params.gff, checkIfExists: true) diff --git a/tests/software/ivar/variants/test.yml b/tests/software/ivar/variants/test.yml index 86f833a6..de93c0a3 100644 --- a/tests/software/ivar/variants/test.yml +++ b/tests/software/ivar/variants/test.yml @@ -1,5 +1,14 @@ -- name: ivar variants no gff - command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff -c tests/config/nextflow.config +- name: ivar variants no gff no mpileup + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff_no_mpileup -c tests/config/nextflow.config + tags: + - ivar + - ivar_variants + files: + - path: output/ivar/test.tsv + md5sum: 3fd376b8ad80f27a999edf3345d2014a + +- name: ivar variants no gff with mpileup + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff_with_mpileup -c tests/config/nextflow.config tags: - ivar - ivar_variants @@ -9,8 +18,8 @@ - path: output/ivar/test.mpileup md5sum: b3dfd337dfcd313d6cc9680d7e796fe6 -- name: ivar variants with gff - command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_with_gff -c tests/config/nextflow.config +- name: ivar variants with gff with mpileup + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_with_gff_with_mpileup -c tests/config/nextflow.config tags: - ivar - ivar_variants From 7cae9b1842c826b4efad237dfa0d4eea1120a422 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 20:49:37 -0800 Subject: [PATCH 18/25] Add gff to meta yaml --- software/ivar/variants/meta.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/software/ivar/variants/meta.yml b/software/ivar/variants/meta.yml index 2b815ec1..6f8e828a 100644 --- a/software/ivar/variants/meta.yml +++ b/software/ivar/variants/meta.yml @@ -45,13 +45,17 @@ input: type: file description: The reference sequence used for mapping and generating the BAM file pattern: "*.fa" + - gff: + type: file + description: A GFF file in the GFF3 format can be supplied to specify coordinates of open reading frames (ORFs). In absence of GFF file, amino acid translation will not be done. + patter: "*.gff" output: - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - variants: + - tsv: type: file description: iVar generated TSV file with the variants pattern: "*.tsv" From b99972f3a0f2f1d9d2b63d7c4cf52711570944f9 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 20:59:45 -0800 Subject: [PATCH 19/25] Move params to nextflow invocation --- tests/software/ivar/variants/main.nf | 9 +-------- tests/software/ivar/variants/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index e1d51c55..ac7e56ed 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -4,9 +4,6 @@ nextflow.enable.dsl = 2 include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) -params.save_mpileup = false -params.gff = false - workflow test_ivar_variants_no_gff_no_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) @@ -16,9 +13,6 @@ workflow test_ivar_variants_no_gff_no_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } -params.save_mpileup = true -params.gff = false - workflow test_ivar_variants_no_gff_with_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) @@ -28,8 +22,7 @@ workflow test_ivar_variants_no_gff_with_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } -params.save_mpileup = true -params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" +//params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" workflow test_ivar_variants_with_gff_with_mpileup { diff --git a/tests/software/ivar/variants/test.yml b/tests/software/ivar/variants/test.yml index de93c0a3..ac78d3d1 100644 --- a/tests/software/ivar/variants/test.yml +++ b/tests/software/ivar/variants/test.yml @@ -8,7 +8,7 @@ md5sum: 3fd376b8ad80f27a999edf3345d2014a - name: ivar variants no gff with mpileup - command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff_with_mpileup -c tests/config/nextflow.config + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_no_gff_with_mpileup -c tests/config/nextflow.config --save_mpileup tags: - ivar - ivar_variants @@ -19,7 +19,7 @@ md5sum: b3dfd337dfcd313d6cc9680d7e796fe6 - name: ivar variants with gff with mpileup - command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_with_gff_with_mpileup -c tests/config/nextflow.config + command: nextflow run ./tests/software/ivar/variants -entry test_ivar_variants_with_gff_with_mpileup -c tests/config/nextflow.config --gff tests/data/gff/sarscov2/MN908947.3.gff3 --save_mpileup tags: - ivar - ivar_variants From eeedb959c9e1767ffa20b6ade5b6d0c524f2d5d0 Mon Sep 17 00:00:00 2001 From: Anders Goncalves da Silva Date: Mon, 15 Feb 2021 21:04:17 -0800 Subject: [PATCH 20/25] Clean out comments --- tests/software/ivar/variants/main.nf | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index ac7e56ed..bd5dad80 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -22,8 +22,6 @@ workflow test_ivar_variants_no_gff_with_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } -//params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" - workflow test_ivar_variants_with_gff_with_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) From 23987bdad0f2e0adc2a54da68cba5d09a53ef7c7 Mon Sep 17 00:00:00 2001 From: Harshil Patel Date: Tue, 16 Feb 2021 22:57:47 +0000 Subject: [PATCH 21/25] Update tests/software/ivar/variants/main.nf --- tests/software/ivar/variants/main.nf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index bd5dad80..885965eb 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -22,6 +22,8 @@ workflow test_ivar_variants_no_gff_with_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } +params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" + workflow test_ivar_variants_with_gff_with_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) From de90d371dc3219aa409b3fa268b9a48d9a4ea18a Mon Sep 17 00:00:00 2001 From: Harshil Patel Date: Tue, 16 Feb 2021 22:58:38 +0000 Subject: [PATCH 22/25] Update tests/software/ivar/variants/main.nf --- tests/software/ivar/variants/main.nf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 885965eb..56a61077 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -4,6 +4,8 @@ nextflow.enable.dsl = 2 include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) +params.gff = false + workflow test_ivar_variants_no_gff_no_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) From 27020105aaf50cdb293ff2cce704659b650f3d81 Mon Sep 17 00:00:00 2001 From: Harshil Patel Date: Tue, 16 Feb 2021 23:00:30 +0000 Subject: [PATCH 23/25] Update tests/software/ivar/variants/main.nf --- tests/software/ivar/variants/main.nf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 56a61077..56984579 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -4,7 +4,8 @@ nextflow.enable.dsl = 2 include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) -params.gff = false +params.gff = false +params.save_mpileup = false workflow test_ivar_variants_no_gff_no_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) From 7c276d297422641827f60bfa6d33ee20993c4595 Mon Sep 17 00:00:00 2001 From: Harshil Patel Date: Tue, 16 Feb 2021 23:01:27 +0000 Subject: [PATCH 24/25] Update tests/software/ivar/variants/main.nf --- tests/software/ivar/variants/main.nf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 56984579..07999457 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -16,6 +16,9 @@ workflow test_ivar_variants_no_gff_no_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } +params.gff = false +params.save_mpileup = true + workflow test_ivar_variants_no_gff_with_mpileup { def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) From cf2f0762aa44dc822634f11d9db6701b243a6c1e Mon Sep 17 00:00:00 2001 From: Harshil Patel Date: Tue, 16 Feb 2021 23:06:26 +0000 Subject: [PATCH 25/25] Update main.nf --- tests/software/ivar/variants/main.nf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/software/ivar/variants/main.nf b/tests/software/ivar/variants/main.nf index 07999457..306d4585 100644 --- a/tests/software/ivar/variants/main.nf +++ b/tests/software/ivar/variants/main.nf @@ -4,10 +4,10 @@ nextflow.enable.dsl = 2 include { IVAR_VARIANTS } from '../../../../software/ivar/variants/main.nf' addParams([:]) -params.gff = false -params.save_mpileup = false - workflow test_ivar_variants_no_gff_no_mpileup { + params.gff = false + params.save_mpileup = false + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) def input = [] @@ -16,10 +16,10 @@ workflow test_ivar_variants_no_gff_no_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } -params.gff = false -params.save_mpileup = true - workflow test_ivar_variants_no_gff_with_mpileup { + params.gff = false + params.save_mpileup = true + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def dummy = file("${launchDir}/tests/data/dummy/dummy_file.txt", checkIfExists: true) def input = [] @@ -28,10 +28,10 @@ workflow test_ivar_variants_no_gff_with_mpileup { IVAR_VARIANTS ( input, ref, dummy ) } -params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" - workflow test_ivar_variants_with_gff_with_mpileup { - + params.gff = "${launchDir}/tests/data/gff/sarscov2/MN908947.3.gff3" + params.save_mpileup = true + def ref = file("${launchDir}/tests/data/fasta/sarscov2/MN908947.3.fa", checkIfExists: true) def gff = file(params.gff, checkIfExists: true) def input = []