Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions modules/local/rename/decompress_fasta.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
process DECOMPRESS_FASTA {
label 'process_tiny'

tag { name }

conda "${moduleDir}/environment.yml"
container "community.wave.seqera.io/library/bbmap:801715ef64484762"

input:
tuple val(name), path(fasta_gz)

output:
tuple val(name), path("DECOMPRESSED/${name}.fa"), emit: decompressed_fasta

script:
"""
mkdir -p DECOMPRESSED
reformat.sh in=${fasta_gz} out=DECOMPRESSED/${name}.fa
"""
}
4 changes: 2 additions & 2 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
"format": "path",
"exists": true,
"description": "Path to FASTA directory",
"help_text": "This parameter is *mandatory*.",
"help_text": "This parameter is *mandatory*. Files may be uncompressed (.fa/.fna/.fasta) or gzip-compressed (.fa.gz/.fna.gz/.fasta.gz); compressed inputs are decompressed automatically before downstream stages.",
"fa_icon": "fas fa-folder-open"
},
"fasta_fmt": {
"type": "string",
"default": "*.f*",
"description": "Input format for the FASTA file.",
"description": "Input glob for the FASTA files. The default matches both plain and .gz files.",
"fa_icon": "fas fa-plus"
},
"input_genes": {
Expand Down
20 changes: 16 additions & 4 deletions workflows/dram.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include { MERGE } from "../subworkflows/local/merge.nf"
include { ANNOTATE } from "../subworkflows/local/annotate.nf"
include { ADD_ANNOTATIONS } from "../modules/local/add_and_combine/add_annotations.nf"
include { SUMMARIZE } from "../modules/local/distill/distill.nf"
include { DECOMPRESS_FASTA } from "../modules/local/rename/decompress_fasta.nf"


/*
Expand Down Expand Up @@ -59,14 +60,25 @@ workflow DRAM {
}

if (params.input_fasta && (params.rename || call)) {
ch_fasta = Channel
ch_fasta_raw = Channel
.fromPath(file(params.input_fasta) / params.fasta_fmt, checkIfExists: true)
.ifEmpty { exit 1, "Cannot find any fasta files matching: ${params.input_fasta}\nNB: Path needs to follow pattern: path/to/directory/" }

ch_fasta = ch_fasta.map {
fasta_name = it.getBaseName()
tuple(fasta_name, it)
// Strip .gz (if present) and then .fa/.fna/.fasta so a sample's
// gz and plain inputs yield the same downstream sample name.
ch_fasta_named = ch_fasta_raw.map { f ->
def name = f.name.replaceAll(/\.gz$/, '').replaceAll(/\.(fa|fna|fasta)$/, '')
tuple(name, f)
}

// Route .gz inputs through DECOMPRESS_FASTA; pass plain inputs unchanged.
ch_fasta_branched = ch_fasta_named.branch { entry ->
gz: entry[1].name.endsWith('.gz')
plain: true
}

DECOMPRESS_FASTA( ch_fasta_branched.gz )
ch_fasta = DECOMPRESS_FASTA.out.decompressed_fasta.mix( ch_fasta_branched.plain )
}
viz_rules_system = params.viz_rules_system

Expand Down