Merge pull request #134 from JoseEspinosa/bcftools_viralrecon

Bcftools viralrecon
This commit is contained in:
Harshil Patel 2021-02-08 21:52:57 +00:00 committed by GitHub
commit 85926b20d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 1180 additions and 0 deletions

24
.github/filters.yml vendored
View file

@ -2,6 +2,30 @@ bandage_image:
- software/bandage/image/**
- tests/software/bandage/image/**
bcftools_bgzip:
- software/bcftools/bgzip/**
- tests/software/bcftools/bgzip**
bcftools_consensus:
- software/bcftools/consensus/**
- tests/software/bcftools/consensus**
bcftools_filter:
- software/bcftools/filter/**
- tests/software/bcftools/filter**
bcftools_isec:
- software/bcftools/isec/**
- tests/software/bcftools/isec**
bcftools_stats:
- software/bcftools/stats/**
- tests/software/bcftools/stats**
bcftools_tabix:
- software/bcftools/tabix/**
- tests/software/bcftools/tabix**
bedtools_complement:
- software/bedtools/complement/**
- tests/software/bedtools/complement/**

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,34 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_BGZIP {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcf)
output:
tuple val(meta), path("*.gz"), emit: vcf
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bgzip -c $options.args $vcf > ${prefix}.vcf.gz
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,60 @@
name: bcftools_bgzip
description: Compresses VCF files
keywords:
- variant calling
- compress
- VCF
tools:
- bgzip:
description: |
Bgzip compresses files in a similar manner to, and compatible with, gzip.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bgzip.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcf:
type: file
description: VCF text file
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- vcf:
type: file
description: Output compressed VCF file
pattern: "*.{vcf}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,37 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_CONSENSUS {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcf), path(tbi), path(fasta)
output:
tuple val(meta), path("*.fa"), emit: fasta
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
cat $fasta | bcftools consensus $vcf $options.args > ${prefix}.fa
header=\$(head -n 1 ${prefix}.fa | sed 's/>//g')
sed -i "s/\${header}/${meta.id}/g" ${prefix}.fa
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,69 @@
name: bcftools_consensus
description: Compresses VCF files
keywords:
- variant calling
- consensus
- VCF
tools:
- consensus:
description: |
Create consensus sequence by applying VCF variants to a reference fasta file.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bcftools.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcf:
type: file
description: VCF file
pattern: "*.{vcf}"
- tbi:
type: file
description: tabix index file
pattern: "*.{tbi}"
- fasta:
type: file
description: FASTA reference file
pattern: "*.{fasta,fa}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: FASTA reference consensus file
pattern: "*.{fasta,fa}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,38 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_FILTER {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcf)
output:
tuple val(meta), path("*.gz"), emit: vcf
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bcftools filter \\
--output ${prefix}.vcf.gz \\
$options.args \\
$vcf
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,61 @@
name: bcftools_filter
description: Filters VCF files
keywords:
- variant calling
- filtering
- VCF
tools:
- filter:
description: |
Apply fixed-threshold filters to VCF files.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bcftools.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcf:
type: file
description: VCF input file
pattern: "*.{vcf}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- vcf:
type: file
description: VCF filtered output file
pattern: "*.{vcf}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,37 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_ISEC {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcfs), path(tbis)
output:
tuple val(meta), path("${prefix}"), emit: results
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bcftools isec \\
$options.args \\
-p $prefix \\
*.vcf.gz
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,69 @@
name: bcftools_isec
description: Apply set operations to VCF files
keywords:
- variant calling
- intersect
- union
- complement
- VCF
tools:
- isec:
description: |
Computes intersections, unions and complements of VCF files.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bcftools.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcfs:
type: files
description: |
List containing 2 or more vcf files
e.g. [ 'file1.vcf', 'file2.vcf' ]
- tbis:
type: files
description: |
List containing the tbi index files corresponding to the vcfs input files
e.g. [ 'file1.vcf.tbi', 'file2.vcf.tbi' ]
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- results:
type: directory
description: Folder containing the set operations results perform on the vcf files
pattern: "${prefix}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,34 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_STATS {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcf)
output:
tuple val(meta), path("*.txt"), emit: stats
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
bcftools stats $options.args $vcf > ${prefix}.bcftools_stats.txt
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,62 @@
name: bcftools_stats
description: Generates stats from VCF files
keywords:
- variant calling
- stats
- VCF
tools:
- stats:
description: |
Parses VCF or BCF and produces text file stats which is suitable for
machine processing and can be plotted using plot-vcfstats.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bcftools.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcf:
type: file
description: VCF input file
pattern: "*.{vcf}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- stats:
type: file
description: Text output file containing stats
pattern: "*.{txt}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* 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"
}
}
}

View file

@ -0,0 +1,33 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BCFTOOLS_TABIX {
tag "$meta.id"
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::bcftools=1.11" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/bcftools:1.11--h7c999a4_0"
} else {
container "quay.io/biocontainers/bcftools:1.11--h7c999a4_0"
}
input:
tuple val(meta), path(vcf)
output:
tuple val(meta), path("*.tbi"), emit: tbi
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
"""
tabix $options.args $vcf
echo \$(bcftools --version 2>&1) | sed 's/^.*bcftools //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,63 @@
name: bcftools_tabix
description: Index GFF/BED/SAM/VCF file
keywords:
- index
- vcf
- bed
- sam
- gff
tools:
- stats:
description: |
Indexes a TAB-delimited genome position file.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: http://www.htslib.org/doc/bcftools.html
doi: 10.1093/bioinformatics/btp352
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- 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 ]
- vcf:
type: file
description: TAB-delimited genome position file compressed with bgzip
pattern: "*.{vcf.gz,bed.gz,sam.gz,gff.gz}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- tbi:
type: file
description: Index file
pattern: "*.{tbi}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,20 @@
>1:2-501
TACcAtATgTgACAtATAAaAAAGAACATAACCTACGTATCAACTAAAGTGGTTGTTTG
cAGAAAAGGAAGACTTAAAAAGAGTCAGTACTAACCTACATAATATATACAATGTTCATT
AAATAATAAAATGAGCTCATCATACTTAGGTCATCATAAATATATCTGAAATTCACAAAT
ATTGATCAAATGGTAAAATAGACAAGTAGATTTTAATAGGTTAAACAATTACTGATTCTC
TTGAAAGAATAAATTTAATATGAGACCTATTTCATTATAATGAACTCACAAATTAGAAAC
TTCACACTGGGGGCTGGAGAGATGGCTCAGTAGTTAAGAACACTGACTGCTCTTCTGAAG
GTCCTGAGTTCAAATCCCAGCAACCACATGGTGACTTACAACCATCTGTAATGACATCTG
ATGCCCTCTGGTGTGTCTGAAGACAGCTACAGTGTACTTACATAAAATAATAAATAAATC
TTTAAAAACAAAAAAAAAGAA
>2
gaagatcttttccttattaaggatctgaagctctgtagatttgtattctattaaacatgg
AgagattagtgattttccatattctttaagtcattttagagtaatgtgttcttaagatAa
atcagaaaaacaaaaacttgtgctttcctgtttgaaaaacaaacagctgtggggaatgGt
gtcgggacagcctttttatAaaatttttctaaataatgttgaggctttgatacgtcaaag
ttatatttcaaatggaatcacttagacctcgtttctgagtgtcaatggccatattggggA
tttgctgctgccaatgacaGcacaccctgggaatgccccaactacttactacaaagcagt
gttacatggagaagatcttcaagagtctttttgctagatctttccttggcttttgatgtg
actcctctcaataaaatccacagtaatatagtgagtggtctcctgctccaaaccagtatt
Tcagacacagttaatccagac

24
tests/data/vcf/test.vcf Normal file
View file

@ -0,0 +1,24 @@
##fileformat=VCFv4.2
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##reference=file://some/path/human_g1k_v37.fasta
##INFO=<ID=END,Number=1,Type=Integer,Description="End position of the variant described in this record">
##INFO=<ID=MinDP,Number=1,Type=Integer,Description="Dummy">
##ALT=<ID=DEL,Description="Deletion">
##contig=<ID=1,assembly=b37,length=249250621>
##contig=<ID=2,assembly=b37,length=249250621>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA001
1 5 . C A . PASS . GT 0/1
1 5 . C T . PASS . GT 0/1
1 7 . T A . PASS . GT .
1 10 . G A . PASS . GT 0/1
1 12 . GACA GA . PASS . GT 0/1
1 16 . T TAAA . PASS . GT 1/1
1 19 . A C . PASS . GT 0/1
1 61 . C A . PASS . GT 0/1
2 61 . agag aa . PASS . GT 0/1
2 119 . aaa t . PASS . GT 0/1
2 179 . g gacgtacgt . PASS . GT 0/1
2 200 . a <DEL> . PASS END=210 GT 1/0
2 300 . a . . PASS END=310;MinDP=10 GT 0/1
2 320 . a <*> . PASS END=330;MinDP=20 GT 0/1
2 481 . t c,a . PASS . GT 0/2

BIN
tests/data/vcf/test.vcf.gz Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/data/vcf/test2.vcf.gz Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/data/vcf/test3.vcf.gz Normal file

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BCFTOOLS_BGZIP } from '../../../../software/bcftools/bgzip/main.nf' addParams( options: [:] )
workflow test_bcftools_bgzip {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf", checkIfExists: true) ]]
BCFTOOLS_BGZIP ( input )
}

View file

@ -0,0 +1,8 @@
- name: bcftools bgzip
command: nextflow run ./tests/software/bcftools/bgzip -entry test_bcftools_bgzip -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_bgzip
files:
- path: output/bcftools/test.vcf.gz
md5sum: eb75ae1f08a1884f8edc59ed423471a2

View file

@ -0,0 +1,16 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BCFTOOLS_CONSENSUS } from '../../../../software/bcftools/consensus/main.nf' addParams( options: [:] )
workflow test_bcftools_consensus {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf.gz", checkIfExists: true) ],
[ file("${launchDir}/tests/data/vcf/test.vcf.gz.tbi", checkIfExists: true) ],
[ file("${launchDir}/tests/data/vcf/test.consensus.fa", checkIfExists: true) ] ]
BCFTOOLS_CONSENSUS ( input )
}

View file

@ -0,0 +1,8 @@
- name: bcftools consensus
command: nextflow run ./tests/software/bcftools/consensus -entry test_bcftools_consensus -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_consensus
files:
- path: output/bcftools/test.fa
md5sum: c9e7ac4537756a0b33bcf17117f9a065

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
//keep --no-verson argument, otherwise md5 will change on each execution
include { BCFTOOLS_FILTER } from '../../../../software/bcftools/filter/main.nf' addParams( options: ['args': '--no-version'] )
workflow test_bcftools_filter {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf", checkIfExists: true) ]]
BCFTOOLS_FILTER ( input )
}

View file

@ -0,0 +1,8 @@
- name: bcftools filter
command: nextflow run ./tests/software/bcftools/filter -entry test_bcftools_filter -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_filter
files:
- path: output/bcftools/test.vcf.gz
md5sum: 16947ce72a127938d881113a1e6e696b

View file

@ -0,0 +1,20 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BCFTOOLS_ISEC } from '../../../../software/bcftools/isec/main.nf' addParams( options: ['args': '--nfiles +2 --output-type z --no-version'] )
workflow test_bcftools_isec {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf.gz", checkIfExists: true),
file("${launchDir}/tests/data/vcf/test2.vcf.gz", checkIfExists: true),
file("${launchDir}/tests/data/vcf/test3.vcf.gz", checkIfExists: true)],
[ file("${launchDir}/tests/data/vcf/test.vcf.gz.tbi", checkIfExists: true),
file("${launchDir}/tests/data/vcf/test2.vcf.gz.tbi", checkIfExists: true),
file("${launchDir}/tests/data/vcf/test3.vcf.gz.tbi", checkIfExists: true) ]]
BCFTOOLS_ISEC ( input )
}

View file

@ -0,0 +1,22 @@
- name: bcftools isec
command: nextflow run ./tests/software/bcftools/isec -entry test_bcftools_isec -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_isec
files:
- path: output/bcftools/test/0000.vcf.gz
md5sum: 4e84e3b6903fa44e8bd1acdeff9b265d
- path: output/bcftools/test/0000.vcf.gz.tbi
md5sum: 8484b151ef902e25e54f7713d46ed90e
- path: output/bcftools/test/0001.vcf.gz
md5sum: 4e84e3b6903fa44e8bd1acdeff9b265d
- path: output/bcftools/test/0001.vcf.gz.tbi
md5sum: 8484b151ef902e25e54f7713d46ed90e
- path: output/bcftools/test/0002.vcf.gz
md5sum: 4e84e3b6903fa44e8bd1acdeff9b265d
- path: output/bcftools/test/0002.vcf.gz.tbi
md5sum: 8484b151ef902e25e54f7713d46ed90e
- path: output/bcftools/test/README.txt
md5sum: 63ef64134d2685bc5d50332ef20389d2
- path: output/bcftools/test/sites.txt
md5sum: 01bb949ed7825ecf692bf0640e363647

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BCFTOOLS_STATS } from '../../../../software/bcftools/stats/main.nf' addParams( options: [:] )
workflow test_bcftools_stats {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf", checkIfExists: true) ]]
BCFTOOLS_STATS ( input )
}

View file

@ -0,0 +1,8 @@
- name: bcftools stats
command: nextflow run ./tests/software/bcftools/stats -entry test_bcftools_stats -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_stats
files:
- path: output/bcftools/test.bcftools_stats.txt
md5sum: abfc6a90f84e24b2cc7e92cbce06200a

View file

@ -0,0 +1,14 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BCFTOOLS_TABIX } from '../../../../software/bcftools/tabix/main.nf' addParams( options: [:] )
workflow test_bcftools_tabix {
def input = []
input = [ [ id:'test' ], // meta map
[ file("${launchDir}/tests/data/vcf/test.vcf.gz", checkIfExists: true) ] ]
BCFTOOLS_TABIX ( input )
}

View file

@ -0,0 +1,8 @@
- name: bcftools tabix
command: nextflow run ./tests/software/bcftools/tabix -entry test_bcftools_tabix -c tests/config/nextflow.config
tags:
- bcftools
- bcftools_tabix
files:
- path: output/bcftools/test.vcf.gz.tbi
md5sum: 06d52177f819730dd409157914534e8d