mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 02:58:17 +00:00
New module to use hmmalign from HMMER to align sequences (#470)
* Ignore vim tmp files * Added hmmalign module, not yet tests * Test output * Replaced functions.nf for hmmalign with upstream * Update software/hmmer/hmmalign/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/hmmer/hmmalign/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/hmmer/hmmalign/meta.yml Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/hmmer/hmmalign/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/hmmer/hmmalign/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/hmmer/hmmalign/test.yml Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/config/pytest_software.yml Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/hmmer/hmmalign/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
d63ff4ba1b
commit
d7a3286a9a
7 changed files with 188 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,3 +5,5 @@ test_output/
|
||||||
output/
|
output/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
.screenrc
|
||||||
|
.*.sw?
|
||||||
|
|
70
software/hmmer/hmmalign/functions.nf
Normal file
70
software/hmmer/hmmalign/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
software/hmmer/hmmalign/main.nf
Normal file
42
software/hmmer/hmmalign/main.nf
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process HMMER_HMMALIGN {
|
||||||
|
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), meta:meta, publish_by_meta:['id']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::hmmer=3.3.2" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/hmmer:3.3.2--h1b792b2_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/hmmer:3.3.2--h1b792b2_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(fasta)
|
||||||
|
path hmm
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*.sthlm.gz"), emit: sthlm
|
||||||
|
path "*.version.txt" , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def fastacmd = fasta.getExtension() == 'gz' ? "gunzip -c $fasta" : "cat $fasta"
|
||||||
|
"""
|
||||||
|
$fastacmd | \\
|
||||||
|
hmmalign \\
|
||||||
|
$options.args \\
|
||||||
|
$hmm \\
|
||||||
|
- | gzip -c > ${meta.id}.sthlm.gz
|
||||||
|
|
||||||
|
echo \$(hmmalign -h | grep -o '^# HMMER [0-9.]*') | sed 's/^# HMMER *//' > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
45
software/hmmer/hmmalign/meta.yml
Normal file
45
software/hmmer/hmmalign/meta.yml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
name: hmmer_hmmalign
|
||||||
|
description: hmmalign from the HMMER suite aligns a number of sequences to an HMM profile
|
||||||
|
keywords:
|
||||||
|
- alignment
|
||||||
|
tools:
|
||||||
|
- hmmer:
|
||||||
|
description: Biosequence analysis using profile hidden Markov models
|
||||||
|
homepage: http://hmmer.org/
|
||||||
|
documentation: http://hmmer.org/documentation.html
|
||||||
|
tool_dev_url: None
|
||||||
|
doi: "http://dx.doi.org/10.1371/journal.pcbi.1002195"
|
||||||
|
licence: ['BSD']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test' ]
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: Amino acid or nucleotide fasta file, gzipped or not
|
||||||
|
pattern: "*.{fna,fna.gz,faa,faa.gz,fasta,fasta.gz,fa,fa.gz}"
|
||||||
|
- hmm:
|
||||||
|
type: file
|
||||||
|
description: HMM file
|
||||||
|
pattern: "*.hmm"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
- sthlm:
|
||||||
|
type: file
|
||||||
|
description: Multiple alignment in gzipped Stockholm format
|
||||||
|
pattern: "*.sthlm.gz"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@erikrikarddaniel"
|
|
@ -297,6 +297,10 @@ hisat2/extractsplicesites:
|
||||||
- software/hisat2/extractsplicesites/**
|
- software/hisat2/extractsplicesites/**
|
||||||
- tests/software/hisat2/extractsplicesites/**
|
- tests/software/hisat2/extractsplicesites/**
|
||||||
|
|
||||||
|
hmmer/hmmalign:
|
||||||
|
- software/hmmer/hmmalign/**
|
||||||
|
- tests/software/hmmer/hmmalign/**
|
||||||
|
|
||||||
homer/annotatepeaks:
|
homer/annotatepeaks:
|
||||||
- software/homer/annotatepeaks/**
|
- software/homer/annotatepeaks/**
|
||||||
- tests/software/homer/annotatepeaks/**
|
- tests/software/homer/annotatepeaks/**
|
||||||
|
|
17
tests/software/hmmer/hmmalign/main.nf
Normal file
17
tests/software/hmmer/hmmalign/main.nf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { HMMER_HMMALIGN } from '../../../../software/hmmer/hmmalign/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_hmmer_hmmalign {
|
||||||
|
|
||||||
|
input = [
|
||||||
|
[ id:'test' ], // meta map
|
||||||
|
file('https://raw.githubusercontent.com/erikrikarddaniel/test-datasets/modules/data/delete_me/e_coli_k12_16s.fna') // Change to params.test_data syntax after the data is included in tests/config/test_data.config
|
||||||
|
]
|
||||||
|
|
||||||
|
hmm = file('https://raw.githubusercontent.com/erikrikarddaniel/test-datasets/modules/data/delete_me/bac.16S_rRNA.hmm')
|
||||||
|
|
||||||
|
HMMER_HMMALIGN ( input, hmm )
|
||||||
|
}
|
8
tests/software/hmmer/hmmalign/test.yml
Normal file
8
tests/software/hmmer/hmmalign/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: hmmer hmmalign test_hmmer_hmmalign
|
||||||
|
command: nextflow run tests/software/hmmer/hmmalign -entry test_hmmer_hmmalign -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- hmmer
|
||||||
|
- hmmer/hmmalign
|
||||||
|
files:
|
||||||
|
- path: output/hmmer/test.sthlm.gz
|
||||||
|
md5sum: ddaa8b96291edf4e1a929a224329161b
|
Loading…
Reference in a new issue