mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
New Snpsites module (#416)
* new gubbins module * new gubbins module * new gubbins module * Update software/gubbins/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gubbins/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gubbins/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update software/gubbins/meta.yml Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * new gubbins module * new gubbins module * new gubbins module * new gubbins module * new gubbins module * new gubbins module * new gubbins module * Update tests/config/test_data.config Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Update tests/software/gubbins/main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * new gubbins module * new gubbins module * new snpsites module * new snpsites module * new snpsites module * new snpsites module * adding fasttree module * correct trailing whitespace * using sarscov2 as a test dir * use sars-cov-2 alignment * remove old test alignment * new snpsites module * new snpsites module * new snpsites module * updated test file names * new snpsites module * revert to gubbins test on upstream * add new lines * renove whitespace * Apply suggestions from code review Co-authored-by: avantonder <avt@sanger.ac.uk> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: avantonder <ajv37@cam.ac.uk>
This commit is contained in:
parent
f34892c1af
commit
6927f1d086
6 changed files with 155 additions and 0 deletions
60
software/snpsites/functions.nf
Normal file
60
software/snpsites/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/snpsites/main.nf
Normal file
39
software/snpsites/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 SNPSITES {
|
||||
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:'') }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::snp-sites=2.5.1" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/snp-sites:2.5.1--hed695b0_0"
|
||||
} else {
|
||||
container "quay.io/biocontainers/snp-sites:2.5.1--hed695b0_0"
|
||||
}
|
||||
|
||||
input:
|
||||
path alignment
|
||||
|
||||
output:
|
||||
path "*.fas" , emit: fasta
|
||||
path "*.sites.txt" , emit: constant_sites
|
||||
path "*.version.txt", emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
"""
|
||||
snp-sites -c \\
|
||||
$alignment \\
|
||||
> filtered_alignment.fas
|
||||
|
||||
echo \$(snp-sites -C $alignment) > constant.sites.txt
|
||||
|
||||
echo \$(snp-sites -V 2>&1) | sed 's/snp-sites //' > ${software}.version.txt
|
||||
"""
|
||||
}
|
31
software/snpsites/meta.yml
Normal file
31
software/snpsites/meta.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
name: snpsites
|
||||
description: Rapidly extracts SNPs from a multi-FASTA alignment.
|
||||
keywords:
|
||||
- SNPs
|
||||
- invariant
|
||||
- constant
|
||||
tools:
|
||||
- snpsites:
|
||||
description: Rapidly extracts SNPs from a multi-FASTA alignment.
|
||||
homepage: https://www.sanger.ac.uk/tool/snp-sites/
|
||||
documentation: https://github.com/sanger-pathogens/snp-sites
|
||||
input:
|
||||
- alignment:
|
||||
type: file
|
||||
description: fasta alignment file
|
||||
pattern: "*.{fasta,fas,fa,aln}"
|
||||
output:
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
- fasta:
|
||||
type: file
|
||||
description: Variant fasta file
|
||||
pattern: "*.{fas}"
|
||||
- constant_sites:
|
||||
type: file
|
||||
description: Text file containing counts of constant sites
|
||||
pattern: "*.{sites.txt}"
|
||||
authors:
|
||||
- "@avantonder"
|
|
@ -458,6 +458,10 @@ shovill:
|
|||
- software/shovill/**
|
||||
- tests/software/shovill/**
|
||||
|
||||
snpsites:
|
||||
- software/snpsites/**
|
||||
- tests/software/snpsites/**
|
||||
|
||||
spades:
|
||||
- software/spades/**
|
||||
- tests/software/spades/**
|
||||
|
|
12
tests/software/snpsites/main.nf
Normal file
12
tests/software/snpsites/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { SNPSITES } from '../../../software/snpsites/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_snpsites {
|
||||
|
||||
input = file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)
|
||||
|
||||
SNPSITES ( input )
|
||||
}
|
9
tests/software/snpsites/test.yml
Normal file
9
tests/software/snpsites/test.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- name: snpsites
|
||||
command: nextflow run ./tests/software/snpsites -entry test_snpsites -c tests/config/nextflow.config
|
||||
tags:
|
||||
- snpsites
|
||||
files:
|
||||
- path: output/snpsites/filtered_alignment.fas
|
||||
md5sum: 34a3d2ae4439447eabe80282f4625dba
|
||||
- path: output/snpsites/constant.sites.txt
|
||||
md5sum: 8b9b226e3787f7baaefce07405af22c9
|
Loading…
Reference in a new issue