mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add YARA module (#353)
* Initial work on yara module * Adding in index basics * Updated the index stuff * Adding in proper tests * Fix editorconfig * Odd paths * that should do it * Fix tests * Fix tests * FFS * Once more * Mapping is not deterministic
This commit is contained in:
parent
cfc94b96dd
commit
0337916f8a
11 changed files with 440 additions and 0 deletions
60
software/yara/index/functions.nf
Normal file
60
software/yara/index/functions.nf
Normal 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.args3 = args.args3 ?: ''
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
39
software/yara/index/main.nf
Normal file
39
software/yara/index/main.nf
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process YARA_INDEX {
|
||||
tag "$fasta"
|
||||
label 'process_medium'
|
||||
publishDir "${params.outdir}",
|
||||
mode: params.publish_dir_mode,
|
||||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'index', publish_id:'') }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::yara=1.0.2" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/yara:1.0.2--2"
|
||||
} else {
|
||||
container "quay.io/biocontainers/yara:1.0.2--2"
|
||||
}
|
||||
|
||||
input:
|
||||
path fasta
|
||||
|
||||
output:
|
||||
path "yara", emit: index
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
|
||||
"""
|
||||
mkdir yara
|
||||
yara_indexer $fasta -o "yara"
|
||||
mv *.{lf,rid,sa,txt}.* yara
|
||||
cp $fasta yara/yara.fasta
|
||||
|
||||
echo \$(yara_indexer --help 2>&1) | grep -e "yara_indexer version:" | sed 's/yara_indexer version: //g' > ${software}.version.txt
|
||||
"""
|
||||
}
|
34
software/yara/index/meta.yml
Normal file
34
software/yara/index/meta.yml
Normal file
|
@ -0,0 +1,34 @@
|
|||
name: yara_index
|
||||
description: Builds a YARA index for a reference genome
|
||||
keywords:
|
||||
- build
|
||||
- index
|
||||
- fasta
|
||||
- genome
|
||||
- reference
|
||||
tools:
|
||||
- yara:
|
||||
description: Yara is an exact tool for aligning DNA sequencing reads to reference genomes.
|
||||
homepage: https://github.com/seqan/seqan
|
||||
documentation: https://github.com/seqan/seqan
|
||||
tool_dev_url: https://github.com/seqan/seqan
|
||||
doi: ""
|
||||
licence: ['https://raw.githubusercontent.com/seqan/seqan/develop/apps/yara/LICENSE']
|
||||
|
||||
input:
|
||||
- fasta:
|
||||
type: file
|
||||
description: Input genome fasta file
|
||||
|
||||
output:
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
- index:
|
||||
type: file
|
||||
description: YARA genome index files
|
||||
pattern: "yara.*"
|
||||
|
||||
authors:
|
||||
- "@apeltzer"
|
60
software/yara/mapper/functions.nf
Normal file
60
software/yara/mapper/functions.nf
Normal 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.args3 = args.args3 ?: ''
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
48
software/yara/mapper/main.nf
Normal file
48
software/yara/mapper/main.nf
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process YARA_MAPPER {
|
||||
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::yara=1.0.2 bioconda::samtools=1.12" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/mulled-v2-f13549097a0d1ca36f9d4f017636fb3609f6c083:f794a548b8692f29264c8984ff116c2141b90d9e-0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/mulled-v2-f13549097a0d1ca36f9d4f017636fb3609f6c083:f794a548b8692f29264c8984ff116c2141b90d9e-0"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(reads)
|
||||
path index
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.mapped.bam"), emit: bam
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
|
||||
if(meta.single_end) {
|
||||
"""
|
||||
yara_mapper $options.args -t ${task.cpus} -f bam ${index}/yara $reads | samtools view -@ ${task.cpus} -hb -F4 > ${prefix}.mapped.bam
|
||||
|
||||
echo \$(yara_mapper --help 2>&1) > ${software}.version.txt
|
||||
"""
|
||||
} else {
|
||||
"""
|
||||
yara_mapper $options.args -t ${task.cpus} -f bam ${index}/yara ${reads[0]} ${reads[1]} > output.bam
|
||||
samtools view -@ ${task.cpus} -hF 4 -f 0x40 -b output.bam > ${prefix}_1.mapped.bam
|
||||
samtools view -@ ${task.cpus} -hF 4 -f 0x80 -b output.bam > ${prefix}_2.mapped.bam
|
||||
echo \$(yara_mapper --version 2>&1) | grep -e "yara_mapper version:" | sed 's/yara_mapper version: //g' > ${software}.version.txt
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
47
software/yara/mapper/meta.yml
Normal file
47
software/yara/mapper/meta.yml
Normal file
|
@ -0,0 +1,47 @@
|
|||
name: yara_mapper
|
||||
description: Align reads to a reference genome using YARA
|
||||
keywords:
|
||||
- align
|
||||
- genome
|
||||
- reference
|
||||
tools:
|
||||
- yara:
|
||||
description: Yara is an exact tool for aligning DNA sequencing reads to reference genomes.
|
||||
homepage: https://github.com/seqan/seqan
|
||||
documentation: https://github.com/seqan/seqan
|
||||
tool_dev_url: https://github.com/seqan/seqan
|
||||
doi: ""
|
||||
licence: ['https://raw.githubusercontent.com/seqan/seqan/develop/apps/yara/LICENSE']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: file
|
||||
description: |
|
||||
List of input FastQ files of size 1 and 2 for single-end and paired-end data,
|
||||
respectively.
|
||||
- index:
|
||||
type: file
|
||||
description: YARA genome index files
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
- bam:
|
||||
type: file
|
||||
description: Sorted BAM file
|
||||
pattern: "*.{bam}"
|
||||
|
||||
authors:
|
||||
- "@apeltzer"
|
|
@ -458,3 +458,11 @@ untar:
|
|||
vcftools:
|
||||
- software/vcftools/**
|
||||
- tests/software/vcftools/**
|
||||
|
||||
yara:
|
||||
- software/yara/mapper/**
|
||||
- tests/software/yara/mapper/**
|
||||
|
||||
yara_index:
|
||||
- software/yara/index/**
|
||||
- tests/software/yara/index/**
|
||||
|
|
12
tests/software/yara/index/main.nf
Normal file
12
tests/software/yara/index/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { YARA_INDEX } from '../../../../software/yara/index/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_yara_index {
|
||||
|
||||
def input = file("${launchDir}/tests/data/genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
|
||||
|
||||
YARA_INDEX ( input )
|
||||
}
|
30
tests/software/yara/index/test.yml
Normal file
30
tests/software/yara/index/test.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- name: yara index test_yara_index
|
||||
command: nextflow run tests/software/yara/index -entry test_yara_index -c tests/config/nextflow.config
|
||||
tags:
|
||||
- yara_index
|
||||
- yara
|
||||
files:
|
||||
- path: output/index/yara/yara.rid.limits
|
||||
md5sum: 8b814661f30a0c9e350bfbcb454930ce
|
||||
- path: output/index/yara/yara.sa.len
|
||||
md5sum: 45677f66c28c79c02250ceb8b58645e8
|
||||
- path: output/index/yara/yara.sa.ind
|
||||
md5sum: 464314583efb5f07260b0efecc29a1ce
|
||||
- path: output/index/yara/yara.lf.drp
|
||||
md5sum: 3ef99a87a4e44513f46d42f4261f7842
|
||||
- path: output/index/yara/yara.txt.size
|
||||
md5sum: 063987b3c3f747be7d2b8043c9d91000
|
||||
- path: output/index/yara/yara.rid.concat
|
||||
md5sum: 1e4e4c88ddeaf907a12f02f0d88367c5
|
||||
- path: output/index/yara/yara.txt.concat
|
||||
md5sum: 6074d1933c9e7e5ab05fa0def5ce28c0
|
||||
- path: output/index/yara/yara.lf.drs
|
||||
md5sum: 55a54008ad1ba589aa210d2629c1df41
|
||||
- path: output/index/yara/yara.txt.limits
|
||||
md5sum: 4480a068db603e4c9a27bc4fa9ceaf14
|
||||
- path: output/index/yara/yara.sa.val
|
||||
md5sum: ce57cc82e2d3ae7b9824210f54168ce9
|
||||
- path: output/index/yara/yara.lf.pst
|
||||
md5sum: e8daba34298e99e42942435286f9b3f0
|
||||
- path: output/index/yara/yara.lf.drv
|
||||
md5sum: cf6408307fe9fd7f99c33f521bf95550
|
32
tests/software/yara/mapper/main.nf
Normal file
32
tests/software/yara/mapper/main.nf
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
|
||||
include { YARA_INDEX } from '../../../../software/yara/index/main.nf' addParams( options: ['args': '-e 3'] )
|
||||
include { YARA_MAPPER } from '../../../../software/yara/mapper/main.nf' addParams( options: ['args': '-e 3'] )
|
||||
|
||||
workflow test_yara_single_end {
|
||||
|
||||
def fasta = file("${launchDir}/tests/data/genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
|
||||
YARA_INDEX ( fasta )
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:true ], // meta map
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true) ]
|
||||
|
||||
YARA_MAPPER ( input, YARA_INDEX.out.index )
|
||||
}
|
||||
|
||||
workflow test_yara_paired_end {
|
||||
|
||||
def fasta = file("${launchDir}/tests/data/genomics/sarscov2/genome/genome.fasta", checkIfExists: true)
|
||||
YARA_INDEX ( fasta )
|
||||
|
||||
def input = []
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file("${launchDir}/tests/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true),
|
||||
file("${launchDir}/tests/data/genomics/sarscov2/illumina/fastq/test_2.fastq.gz", checkIfExists: true) ] ]
|
||||
|
||||
YARA_MAPPER ( input, YARA_INDEX.out.index )
|
||||
}
|
70
tests/software/yara/mapper/test.yml
Normal file
70
tests/software/yara/mapper/test.yml
Normal file
|
@ -0,0 +1,70 @@
|
|||
- name: yara mapper test_yara_single_end
|
||||
command: nextflow run tests/software/yara/mapper -entry test_yara_single_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- yara_single_end
|
||||
- yara_mapper
|
||||
- yara
|
||||
files:
|
||||
- path: output/yara/test.mapped.bam
|
||||
- path: output/index/yara/yara.txt.size
|
||||
md5sum: 063987b3c3f747be7d2b8043c9d91000
|
||||
- path: output/index/yara/yara.lf.drs
|
||||
md5sum: 55a54008ad1ba589aa210d2629c1df41
|
||||
- path: output/index/yara/yara.lf.pst
|
||||
md5sum: e8daba34298e99e42942435286f9b3f0
|
||||
- path: output/index/yara/yara.sa.len
|
||||
md5sum: 45677f66c28c79c02250ceb8b58645e8
|
||||
- path: output/index/yara/yara.rid.concat
|
||||
md5sum: 1e4e4c88ddeaf907a12f02f0d88367c5
|
||||
- path: output/index/yara/yara.txt.concat
|
||||
md5sum: 6074d1933c9e7e5ab05fa0def5ce28c0
|
||||
- path: output/index/yara/yara.sa.val
|
||||
md5sum: ce57cc82e2d3ae7b9824210f54168ce9
|
||||
- path: output/index/yara/yara.sa.ind
|
||||
md5sum: 464314583efb5f07260b0efecc29a1ce
|
||||
- path: output/index/yara/yara.rid.limits
|
||||
md5sum: 8b814661f30a0c9e350bfbcb454930ce
|
||||
- path: output/index/yara/yara.lf.drp
|
||||
md5sum: 3ef99a87a4e44513f46d42f4261f7842
|
||||
- path: output/index/yara/yara.txt.limits
|
||||
md5sum: 4480a068db603e4c9a27bc4fa9ceaf14
|
||||
- path: output/index/yara/yara.lf.drv
|
||||
md5sum: cf6408307fe9fd7f99c33f521bf95550
|
||||
- path: output/index/yara/yara.fasta
|
||||
md5sum: 6e9fe4042a72f2345f644f239272b7e6
|
||||
|
||||
- name: yara mapper test_yara_paired_end
|
||||
command: nextflow run tests/software/yara/mapper -entry test_yara_paired_end -c tests/config/nextflow.config
|
||||
tags:
|
||||
- yara_mapper
|
||||
- yara_paired_end
|
||||
- yara
|
||||
files:
|
||||
- path: output/yara/test_2.mapped.bam
|
||||
- path: output/yara/test_1.mapped.bam
|
||||
- path: output/index/yara/yara.txt.size
|
||||
md5sum: 063987b3c3f747be7d2b8043c9d91000
|
||||
- path: output/index/yara/yara.lf.drs
|
||||
md5sum: 55a54008ad1ba589aa210d2629c1df41
|
||||
- path: output/index/yara/yara.lf.pst
|
||||
md5sum: e8daba34298e99e42942435286f9b3f0
|
||||
- path: output/index/yara/yara.sa.len
|
||||
md5sum: 45677f66c28c79c02250ceb8b58645e8
|
||||
- path: output/index/yara/yara.rid.concat
|
||||
md5sum: 1e4e4c88ddeaf907a12f02f0d88367c5
|
||||
- path: output/index/yara/yara.txt.concat
|
||||
md5sum: 6074d1933c9e7e5ab05fa0def5ce28c0
|
||||
- path: output/index/yara/yara.sa.val
|
||||
md5sum: ce57cc82e2d3ae7b9824210f54168ce9
|
||||
- path: output/index/yara/yara.sa.ind
|
||||
md5sum: 464314583efb5f07260b0efecc29a1ce
|
||||
- path: output/index/yara/yara.rid.limits
|
||||
md5sum: 8b814661f30a0c9e350bfbcb454930ce
|
||||
- path: output/index/yara/yara.lf.drp
|
||||
md5sum: 3ef99a87a4e44513f46d42f4261f7842
|
||||
- path: output/index/yara/yara.txt.limits
|
||||
md5sum: 4480a068db603e4c9a27bc4fa9ceaf14
|
||||
- path: output/index/yara/yara.lf.drv
|
||||
md5sum: cf6408307fe9fd7f99c33f521bf95550
|
||||
- path: output/index/yara/yara.fasta
|
||||
md5sum: 6e9fe4042a72f2345f644f239272b7e6
|
Loading…
Reference in a new issue