mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2025-01-03 04:52:09 -05:00
add graphmap index and align modules (from nanoseq modules) (#468)
* add graphmap index module * add graphmap2/index * add graohmap2 align module * remove graphmap2 align md5sum
This commit is contained in:
parent
05b067e907
commit
a8720463ac
11 changed files with 335 additions and 0 deletions
70
software/graphmap2/align/functions.nf
Normal file
70
software/graphmap2/align/functions.nf
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* 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_meta = args.publish_by_meta ?: []
|
||||||
|
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_meta) {
|
||||||
|
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||||
|
for (key in key_list) {
|
||||||
|
if (args.meta && key instanceof String) {
|
||||||
|
def path = key
|
||||||
|
if (args.meta.containsKey(key)) {
|
||||||
|
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||||
|
}
|
||||||
|
path = path instanceof String ? path : ''
|
||||||
|
path_list.add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
software/graphmap2/align/main.nf
Normal file
35
software/graphmap2/align/main.nf
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
def options = initOptions(params.options)
|
||||||
|
|
||||||
|
process GRAPHMAP2_ALIGN {
|
||||||
|
tag "$meta.id"
|
||||||
|
publishDir "${params.outdir}",
|
||||||
|
mode: params.publish_dir_mode,
|
||||||
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::graphmap=0.6.3" : null)
|
||||||
|
container "quay.io/biocontainers/graphmap:0.6.3--he513fc3_0"
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(fastq)
|
||||||
|
path(fasta)
|
||||||
|
path(index)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.sam"), emit: align_sam
|
||||||
|
|
||||||
|
script:
|
||||||
|
"""
|
||||||
|
graphmap2 \\
|
||||||
|
align \\
|
||||||
|
-t $task.cpus \\
|
||||||
|
-r $fasta \\
|
||||||
|
-i $index \\
|
||||||
|
-d $fastq \\
|
||||||
|
-o ${meta.id}.sam \\
|
||||||
|
--extcigar
|
||||||
|
"""
|
||||||
|
}
|
49
software/graphmap2/align/meta.yml
Normal file
49
software/graphmap2/align/meta.yml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
name: graphmap2_align
|
||||||
|
description: A versatile pairwise aligner for genomic and spliced nucleotide sequences
|
||||||
|
keywords:
|
||||||
|
- align
|
||||||
|
- fasta
|
||||||
|
- fastq
|
||||||
|
- genome
|
||||||
|
- reference
|
||||||
|
tools:
|
||||||
|
- graphmap2:
|
||||||
|
description: |
|
||||||
|
A versatile pairwise aligner for genomic and spliced nucleotide sequences.
|
||||||
|
homepage: https://github.com/lh3/minimap2
|
||||||
|
documentation: https://github.com/lh3/minimap2#uguide
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- fastq:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
List of input FASTQ files
|
||||||
|
and paired-end data, respectively.
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Reference database in FASTA format.
|
||||||
|
- index:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
FASTA index in gmidx.
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- sam:
|
||||||
|
type: file
|
||||||
|
description: Alignment in SAM format
|
||||||
|
pattern: "*.sam"
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
authors:
|
||||||
|
- "@yuukiiwa"
|
70
software/graphmap2/index/functions.nf
Normal file
70
software/graphmap2/index/functions.nf
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* 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_meta = args.publish_by_meta ?: []
|
||||||
|
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_meta) {
|
||||||
|
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||||
|
for (key in key_list) {
|
||||||
|
if (args.meta && key instanceof String) {
|
||||||
|
def path = key
|
||||||
|
if (args.meta.containsKey(key)) {
|
||||||
|
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||||
|
}
|
||||||
|
path = path instanceof String ? path : ''
|
||||||
|
path_list.add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
software/graphmap2/index/main.nf
Normal file
31
software/graphmap2/index/main.nf
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
def options = initOptions(params.options)
|
||||||
|
|
||||||
|
process GRAPHMAP2_INDEX {
|
||||||
|
publishDir "${params.outdir}",
|
||||||
|
mode: params.publish_dir_mode,
|
||||||
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::graphmap=0.6.3" : null)
|
||||||
|
container "quay.io/biocontainers/graphmap:0.6.3--he513fc3_0"
|
||||||
|
|
||||||
|
input:
|
||||||
|
path(fasta)
|
||||||
|
|
||||||
|
output:
|
||||||
|
path("*.gmidx") ,emit: index
|
||||||
|
path "*.version.txt" ,emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
"""
|
||||||
|
graphmap2 \\
|
||||||
|
align \\
|
||||||
|
-t $task.cpus \\
|
||||||
|
-I \\
|
||||||
|
-r $fasta
|
||||||
|
echo \$(graphmap2 2>&1) > graphmap2.version.txt
|
||||||
|
"""
|
||||||
|
}
|
28
software/graphmap2/index/meta.yml
Normal file
28
software/graphmap2/index/meta.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
name: graphmap2_index
|
||||||
|
description: A versatile pairwise aligner for genomic and spliced nucleotide sequences
|
||||||
|
keywords:
|
||||||
|
- index
|
||||||
|
- fasta
|
||||||
|
- reference
|
||||||
|
tools:
|
||||||
|
- graphmap2:
|
||||||
|
description: |
|
||||||
|
A versatile pairwise aligner for genomic and spliced nucleotide sequences.
|
||||||
|
homepage: https://github.com/lbcb-sci/graphmap2
|
||||||
|
documentation: https://github.com/lbcb-sci/graphmap2#graphmap2---a-highly-sensitive-and-accurate-mapper-for-long-error-prone-reads
|
||||||
|
input:
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Reference database in FASTA format.
|
||||||
|
output:
|
||||||
|
- gmidx:
|
||||||
|
type: file
|
||||||
|
description: Graphmap2 fasta index in gmidx format
|
||||||
|
pattern: "*.gmidx"
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
authors:
|
||||||
|
- "@yuukiiwa"
|
|
@ -274,6 +274,14 @@ gffread:
|
||||||
- software/gffread/**
|
- software/gffread/**
|
||||||
- tests/software/gffread/**
|
- tests/software/gffread/**
|
||||||
|
|
||||||
|
graphmap2/align:
|
||||||
|
- software/graphmap2/align/**
|
||||||
|
- tests/software/graphmap2/align/**
|
||||||
|
|
||||||
|
graphmap2/index:
|
||||||
|
- software/graphmap2/index/**
|
||||||
|
- tests/software/graphmap2/index/**
|
||||||
|
|
||||||
gubbins:
|
gubbins:
|
||||||
- software/gubbins/**
|
- software/gubbins/**
|
||||||
- tests/software/gubbins/**
|
- tests/software/gubbins/**
|
||||||
|
|
17
tests/software/graphmap2/align/main.nf
Normal file
17
tests/software/graphmap2/align/main.nf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { GRAPHMAP2_INDEX } from '../../../../software/graphmap2/index/main.nf' addParams( options: [:] )
|
||||||
|
include { GRAPHMAP2_ALIGN } from '../../../../software/graphmap2/align/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_graphmap2_align {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
[ file(params.test_data['sarscov2']['nanopore']['test_fastq_gz'], checkIfExists: true) ]
|
||||||
|
]
|
||||||
|
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||||
|
|
||||||
|
GRAPHMAP2_INDEX ( fasta )
|
||||||
|
GRAPHMAP2_ALIGN ( input, fasta, GRAPHMAP2_INDEX.out.index )
|
||||||
|
}
|
7
tests/software/graphmap2/align/test.yml
Normal file
7
tests/software/graphmap2/align/test.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- name: graphmap2 align
|
||||||
|
command: nextflow run ./tests/software/graphmap2/align -entry test_graphmap2_align -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- graphmap2
|
||||||
|
- graphmap2/align
|
||||||
|
files:
|
||||||
|
- path: ./output/graphmap2/test.sam
|
12
tests/software/graphmap2/index/main.nf
Normal file
12
tests/software/graphmap2/index/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { GRAPHMAP2_INDEX } from '../../../../software/graphmap2/index/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_graphmap2_index {
|
||||||
|
|
||||||
|
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
|
||||||
|
|
||||||
|
GRAPHMAP2_INDEX ( fasta )
|
||||||
|
}
|
8
tests/software/graphmap2/index/test.yml
Normal file
8
tests/software/graphmap2/index/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: graphmap2 index
|
||||||
|
command: nextflow run ./tests/software/graphmap2/index -entry test_graphmap2_index -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- graphmap2
|
||||||
|
- graphmap2/index
|
||||||
|
files:
|
||||||
|
- path: ./output/graphmap2/genome.fasta.gmidx
|
||||||
|
md5sum: 2973f9b7fa52c78899c73908f8afc6be
|
Loading…
Reference in a new issue