mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
add pirate module (#777)
* new module pirate * remove md5 check for non reproducible binary files * get those to-dos out * Update main.nf * Update meta.yml * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
e77b3d72f3
commit
053797510d
6 changed files with 286 additions and 0 deletions
78
modules/pirate/functions.nf
Normal file
78
modules/pirate/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// 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()
|
||||
}
|
||||
|
||||
//
|
||||
// Extract name of module from process name using $task.process
|
||||
//
|
||||
def getProcessName(task_process) {
|
||||
return task_process.tokenize(':')[-1]
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
|
||||
// Do not publish versions.yml unless running from pytest workflow
|
||||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||
return null
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
43
modules/pirate/main.nf
Normal file
43
modules/pirate/main.nf
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process PIRATE {
|
||||
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::pirate=1.0.4" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/pirate%3A1.0.4--hdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/pirate:1.0.4--hdfd78af_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(gff)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("results/*") , emit: results
|
||||
tuple val(meta), path("results/core_alignment.fasta"), optional: true, emit: aln
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
PIRATE \\
|
||||
$options.args \\
|
||||
--threads $task.cpus \\
|
||||
--input ./ \\
|
||||
--output results/
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$( echo \$( PIRATE --version 2>&1) | sed 's/PIRATE //' )
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
47
modules/pirate/meta.yml
Normal file
47
modules/pirate/meta.yml
Normal file
|
@ -0,0 +1,47 @@
|
|||
name: pirate
|
||||
description: Pangenome toolbox for bacterial genomes
|
||||
keywords:
|
||||
- gff
|
||||
- pan-genome
|
||||
- alignment
|
||||
tools:
|
||||
- pirate:
|
||||
description: Pangenome analysis and threshold evaluation toolbox
|
||||
homepage: https://github.com/SionBayliss/PIRATE
|
||||
documentation: https://github.com/SionBayliss/PIRATE/wiki
|
||||
tool_dev_url: https://github.com/SionBayliss/PIRATE
|
||||
doi: "https://doi.org/10.1093/gigascience/giz119"
|
||||
licence: ['GPL v3']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- gff:
|
||||
type: file
|
||||
description: A set of GFF3 formatted files
|
||||
pattern: "*.{gff}"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- results:
|
||||
type: directory
|
||||
description: Directory containing PIRATE result files
|
||||
pattern: "*/*"
|
||||
- aln:
|
||||
type: file
|
||||
description: Core-genome alignment produced by PIRATE (Optional)
|
||||
pattern: "*.{fasta}"
|
||||
|
||||
authors:
|
||||
- "@rpetit3"
|
|
@ -755,6 +755,10 @@ picard/sortsam:
|
|||
- modules/picard/sortsam/**
|
||||
- tests/modules/picard/sortsam/**
|
||||
|
||||
pirate:
|
||||
- modules/pirate/**
|
||||
- tests/modules/pirate/**
|
||||
|
||||
plasmidid:
|
||||
- modules/plasmidid/**
|
||||
- tests/modules/plasmidid/**
|
||||
|
|
16
tests/modules/pirate/main.nf
Normal file
16
tests/modules/pirate/main.nf
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { PIRATE } from '../../../modules/pirate/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_pirate {
|
||||
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_000292685.gff", checkIfExists: true),
|
||||
file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_000298385.gff", checkIfExists: true),
|
||||
file("https://github.com/bactopia/bactopia-tests/raw/main/data/reference/gff/GCF_002849995.gff", checkIfExists: true) ]
|
||||
]
|
||||
|
||||
PIRATE ( input )
|
||||
}
|
98
tests/modules/pirate/test.yml
Normal file
98
tests/modules/pirate/test.yml
Normal file
|
@ -0,0 +1,98 @@
|
|||
- name: pirate test_pirate
|
||||
command: nextflow run tests/modules/pirate -entry test_pirate -c tests/config/nextflow.config
|
||||
tags:
|
||||
- pirate
|
||||
files:
|
||||
- path: output/pirate/results/PIRATE.gene_families.ordered.tsv
|
||||
contains: ['allele_name']
|
||||
- path: output/pirate/results/PIRATE.gene_families.tsv
|
||||
contains: ['allele_name']
|
||||
- path: output/pirate/results/PIRATE.genomes_per_allele.tsv
|
||||
contains: ['g0197']
|
||||
- path: output/pirate/results/PIRATE.log
|
||||
contains: ['PIRATE input options']
|
||||
- path: output/pirate/results/PIRATE.pangenome_summary.txt
|
||||
md5sum: 4551c291bc06b21f984f25c09329ed7d
|
||||
- path: output/pirate/results/PIRATE.unique_alleles.tsv
|
||||
contains: ['allele_name']
|
||||
- path: output/pirate/results/binary_presence_absence.fasta
|
||||
contains: ['GCF_000292685']
|
||||
- path: output/pirate/results/binary_presence_absence.nwk
|
||||
md5sum: 5b5d86bf97d97de37bb9db514abb7762
|
||||
- path: output/pirate/results/cluster_alleles.tab
|
||||
contains: ['g0001']
|
||||
- path: output/pirate/results/co-ords/GCF_000292685.co-ords.tab
|
||||
md5sum: d5ca0f06ca7ea1f5486683d5859bc9b8
|
||||
- path: output/pirate/results/co-ords/GCF_000298385.co-ords.tab
|
||||
md5sum: a24d6048b3074242bb558c7fa27a8b03
|
||||
- path: output/pirate/results/co-ords/GCF_002849995.co-ords.tab
|
||||
md5sum: 0c08228585f4fa95686e9b025e0fe9c1
|
||||
- path: output/pirate/results/genome2loci.tab
|
||||
md5sum: bbcea5bfcdcafe14a9aa7261c8e931b8
|
||||
- path: output/pirate/results/genome_list.txt
|
||||
md5sum: 6534b1635c258ad92b829077addc1ff5
|
||||
- path: output/pirate/results/link_clusters.log
|
||||
contains: ['parsing paralog file']
|
||||
- path: output/pirate/results/loci_list.tab
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/loci_paralog_categories.tab
|
||||
md5sum: 6404d2a32526a398f42d7da768a389bd
|
||||
- path: output/pirate/results/modified_gffs/GCF_000292685.gff
|
||||
md5sum: 2b73bda2f84dc634303dc90e641040ca
|
||||
- path: output/pirate/results/modified_gffs/GCF_000298385.gff
|
||||
md5sum: b1a9d6557d47e09249f08a7acdbbd618
|
||||
- path: output/pirate/results/modified_gffs/GCF_002849995.gff
|
||||
md5sum: 68532fc9bb639e6d83c731a069f60cf8
|
||||
- path: output/pirate/results/pan_sequences.fasta
|
||||
md5sum: ed835c77fdb20c36aa9d5208eb7ca0cb
|
||||
- path: output/pirate/results/pangenome.connected_blocks.tsv
|
||||
contains: ['block_number']
|
||||
- path: output/pirate/results/pangenome.edges
|
||||
contains: ['g0259']
|
||||
- path: output/pirate/results/pangenome.gfa
|
||||
contains: ['g0001']
|
||||
- path: output/pirate/results/pangenome.order.tsv
|
||||
contains: ['g0172']
|
||||
- path: output/pirate/results/pangenome.reversed.tsv
|
||||
md5sum: b2396ce09a6e4178761eca6dc7f4434f
|
||||
- path: output/pirate/results/pangenome.syntenic_blocks.tsv
|
||||
contains: ['g0091']
|
||||
- path: output/pirate/results/pangenome.temp
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.50.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.60.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.70.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.80.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.90.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.95.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.98.reclustered.reinflated
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.blast.output
|
||||
md5sum: 9da25d27684bfcc5488987ab2d1fd3a1
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.cdhit_clusters
|
||||
contains: ['GCF_000298385_00081']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.core_clusters.tab
|
||||
contains: ['GCF_000298385_00242']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.mcl_log.txt
|
||||
contains: ['chaos']
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.representative.fasta
|
||||
md5sum: 84668b6c65b57026a17a50b0edd02541
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.representative.fasta.pdb
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.representative.fasta.pot
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.representative.fasta.ptf
|
||||
- path: output/pirate/results/pangenome_iterations/pan_sequences.representative.fasta.pto
|
||||
- path: output/pirate/results/pangenome_log.txt
|
||||
contains: ['Creating pangenome on amino acid']
|
||||
- path: output/pirate/results/paralog_clusters.tab
|
||||
contains: ['g0216']
|
||||
- path: output/pirate/results/representative_sequences.faa
|
||||
contains: ['representative_genome']
|
||||
- path: output/pirate/results/representative_sequences.ffn
|
||||
contains: ['representative_genome']
|
||||
- path: output/pirate/results/split_groups.log
|
||||
contains: ['g0213']
|
Loading…
Reference in a new issue