update muscle (#542)

This commit is contained in:
MGordon09 2021-06-28 07:20:02 +01:00 committed by GitHub
parent 81aba5734c
commit af4b8814b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 217 additions and 0 deletions

View file

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

60
software/muscle/main.nf Normal file
View file

@ -0,0 +1,60 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process MUSCLE {
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::muscle=3.8.1551" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/muscle:3.8.1551--h7d875b9_6"
} else {
container "quay.io/biocontainers/muscle:3.8.1551--h7d875b9_6"
}
input:
tuple val(meta), path(fasta)
output:
tuple val(meta), path("*.afa") , optional: true, emit: aligned_fasta
tuple val(meta), path("*.phyi"), optional: true, emit: phyi
tuple val(meta), path("*.phys"), optional: true, emit: phys
tuple val(meta), path("*.clw") , optional: true, emit: clustalw
tuple val(meta), path("*.html"), optional: true, emit: html
tuple val(meta), path("*.msf") , optional: true, emit: msf
tuple val(meta), path("*.tree"), optional: true, emit: tree
path "*.log" , emit: log
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def fasta_out = options.args.contains('-fasta') ? "-fastaout ${prefix}_muscle_msa.afa" : ''
def clw_out = options.args.contains('-clw') ? "-clwout ${prefix}_muscle_msa.clw" : ''
def msf_out = options.args.contains('-msf') ? "-msfout ${prefix}_muscle_msa.msf" : ''
def phys_out = options.args.contains('-phys') ? "-physout ${prefix}_muscle_msa.phys" : ''
def phyi_out = options.args.contains('-phyi') ? "-phyiout ${prefix}_muscle_msa.phyi" : ''
def html_out = options.args.contains('-html') ? "-htmlout ${prefix}_muscle_msa.html" : ''
def tree_out = options.args.contains('-maketree') ? "-out ${prefix}_muscle_msa.tree" : ''
"""
muscle \\
$options.args \\
-in $fasta \\
$fasta_out \\
$clw_out \\
$msf_out \\
$phys_out \\
$phyi_out \\
$html_out \\
$tree_out \\
-loga muscle_msa.log
muscle -version | sed 's/^MUSCLE v//; s/by.*\$//' > ${software}.version.txt
"""
}

56
software/muscle/meta.yml Normal file
View file

@ -0,0 +1,56 @@
name: muscle
description: MUSCLE is a program for creating multiple alignments of amino acid or nucleotide sequences. A range of options are provided that give you the choice of optimizing accuracy, speed, or some compromise between the two
keywords:
- msa
- multiple sequence alignment
tools:
- muscle:
description: MUSCLE is a multiple sequence alignment tool with high accuracy and throughput
homepage: https://www.drive5.com/muscle
documentation: http://www.drive5.com/muscle/muscle.html#_Toc81224840
doi: "https://pubmed.ncbi.nlm.nih.gov/15034147/"
licence: ['http://www.drive5.com/muscle/manual/license.html']
input:
- fasta:
type: file
description: Input sequences for alignment must be in FASTA format
pattern: "*.{fasta,fa,fna}"
output:
- aligned_fasta:
type: file
description: Multiple sequence alignment produced in FASTA format
pattern: "*.{afa}"
- msf:
type: file
description: GCG Multiple Sequence File (MSF) alignment format (similar to CLUSTALW)
pattern: "*.{msf}"
- clustalw:
type: file
description: Multiple sequence alignment produced in ClustalW format without base/residue numbering
pattern: "*.{clw}"
- phyi:
type: file
description: Multiple sequence alignment produced in PHYLIP interleaved format
pattern: "*.{phyi}"
- phys:
type: file
description: Multiple sequence alignment produced in PHYLIP sequential format
pattern: "*.{phys}"
- html:
type: file
description: Multiple sequence alignment produced in HTML format
pattern: "*.{html}"
- tree:
type: file
description: NJ or UPGMA tree in Newick format produced from a multiple sequence alignment
pattern: "*.{tree}"
- log:
type: file
description: Log file of MUSCLE run
pattern: "*{.log}"
- version:
type: file
description: File containing MUSCLE software version
pattern: "*.{version.txt}"
authors:
- "@MGordon"

View file

@ -463,6 +463,10 @@ multiqc:
- software/multiqc/**
- tests/software/multiqc/**
muscle:
- software/muscle/**
- tests/software/muscle/**
nanolyse:
- software/nanolyse/**
- tests/software/nanolyse/**

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { MUSCLE } from '../../../software/muscle/main.nf' addParams( options: ['args': '-fasta -verbose -phys -phyi -maxiters 2'])
include { MUSCLE as MUSCLE_TREE } from '../../../software/muscle/main.nf' addParams( options: ['args': '-maketree'])
workflow test_muscle {
input = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['genome']['informative_sites_fas'], checkIfExists: true) ]
MUSCLE ( input )
MUSCLE_TREE ( MUSCLE.out.aligned_fasta )
}

View file

@ -0,0 +1,14 @@
- name: muscle test_muscle
command: nextflow run tests/software/muscle -entry test_muscle -c tests/config/nextflow.config
tags:
- muscle
files:
- path: output/muscle/muscle_msa.log
- path: output/muscle/test_muscle_msa.afa
md5sum: 93732f6876054d82b0cd252d702c143f
- path: output/muscle/test_muscle_msa.phyi
md5sum: 1f2a246dcca53125456149770763d5d1
- path: output/muscle/test_muscle_msa.phys
md5sum: 12f9dd45672a3d92ba1205fcc8010490
- path: output/muscle/test_muscle_msa.tree
md5sum: 6bf1080bca2440f08ffa2675f74f732a