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
85 changes: 85 additions & 0 deletions subworkflows/nf-core/fasta_consensus_autocycler/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

include { AUTOCYCLER_COMPRESS } from '../../../modules/nf-core/autocycler/compress/main'
include { AUTOCYCLER_CLUSTER } from '../../../modules/nf-core/autocycler/cluster/main'
include { AUTOCYCLER_TRIM } from '../../../modules/nf-core/autocycler/trim/main'
include { AUTOCYCLER_RESOLVE } from '../../../modules/nf-core/autocycler/resolve/main'
include { AUTOCYCLER_COMBINE } from '../../../modules/nf-core/autocycler/combine/main'

workflow FASTA_CONSENSUS_AUTOCYCLER {

take:
ch_grouped_contigs // channel: [ val(meta), [ fasta, fasta, ... ] ]

main:

AUTOCYCLER_COMPRESS (
ch_grouped_contigs
)

AUTOCYCLER_CLUSTER (
AUTOCYCLER_COMPRESS.out.gfa
)

AUTOCYCLER_CLUSTER.out.clusters
.flatMap { meta, gfa_list ->
( gfa_list instanceof List ? gfa_list: [gfa_list] )
.collect { gfa -> [meta, gfa] } // Separate gfas, each with a meta
}
.map { meta, file ->
def cluster_id = (file.parent.name) // Add cluster id to meta
[ meta + [cluster: cluster_id], file ]
}
.set{ ch_clusters } // channel: [ val(meta), gfa]

AUTOCYCLER_TRIM(
ch_clusters
)

AUTOCYCLER_RESOLVE(
AUTOCYCLER_TRIM.out.gfa
)

// Rename resolved gfa files to include cluster ID and avoid filename collisions
RENAME(
AUTOCYCLER_RESOLVE.out.resolved,
AUTOCYCLER_RESOLVE.out.resolved.map{meta, file -> "${meta.id}_${meta.cluster}"}
)
Comment on lines +43 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially that could be fixed in the AUTOCYCLER_RESOLVE module? Instead of having
https://github.com/nf-core/modules/blob/e6f6c211fed71038331afa8ed963e006f9acdbc9/modules/nf-core/autocycler/resolve/main.nf#L16C5-L16C67
it could be tuple val(meta), path("${prefix}_5_final.gfa"), emit: resolved (and name the files in the module script appropriately)?
I understand that this doesnt follow the tutorial of the tool, but wont most users of that module need to fix the output naming similar to here?


// Group clusters based on meta, ignoring cluster id
RENAME.out.renamed
.map{ meta, file ->
def new_meta = meta.clone()
new_meta.remove("cluster")
tuple( new_meta, file)
}
.groupTuple()
.set{ ch_assembly_clusters } // channel: [ meta, [ cluster1, cluster2, ... ] ]

AUTOCYCLER_COMBINE(
ch_assembly_clusters
)

ch_consensus_assembly = AUTOCYCLER_COMBINE.out.fasta // channel: [ val(meta), fasta ]
ch_consensus_assembly_graph = AUTOCYCLER_COMBINE.out.gfa // channel: [ val(meta), gfa ]


emit:
consensus_assembly = ch_consensus_assembly // channel: [ val(meta), fasta ]
consensus_assembly_graph = ch_consensus_assembly_graph // channel: [ val(meta), gfa ]
}

process RENAME {
tag "$meta.id"

input:
tuple val(meta), path(file)
val key

output:
tuple val(meta), path("${key}_${file}"), emit: renamed

script:
"""
ln -s ${file} "${key}_${file}"
"""
}
Comment on lines +71 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks unusual to me to have a process in here. I havent seen a precedence among nf-core subworkflows. Maybe that can be solved differently?

38 changes: 38 additions & 0 deletions subworkflows/nf-core/fasta_consensus_autocycler/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "fasta_consensus_autocycler"
description: Generate consensus assemblies and assembly graphs from grouped contig FASTA files using autocycler
keywords:
- autocycler
- consensus
- assembly
- fasta
components:
- autocycler/compress
- autocycler/cluster
- autocycler/trim
- autocycler/resolve
- autocycler/combine
input:
- ch_grouped_contigs:
type: file
description: |
The input channel containing grouped contig FASTA files
Structure: [ val(meta), [ fasta, fasta, ... ] ]
pattern: "*.{fasta,fa,fna}"
output:
- consensus_assembly:
type: file
description: |
Channel containing consensus assembly FASTA files
Structure: [ val(meta), path(fasta) ]
pattern: "*/consensus_assembly.fasta"
- consensus_assembly_graph:
type: file
description: |
Channel containing consensus assembly graphs
Structure: [ val(meta), path(gfa) ]
pattern: "*/consensus_assembly.gfa"
authors:
- "@dwells-eit"
maintainers:
- "@dwells-eit"
44 changes: 44 additions & 0 deletions subworkflows/nf-core/fasta_consensus_autocycler/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
nextflow_workflow {

name "Test Subworkflow FASTA_CONSENSUS_AUTOCYCLER"
script "../main.nf"
workflow "FASTA_CONSENSUS_AUTOCYCLER"
config "./nextflow.config"

tag "subworkflows"
tag "subworkflows_nfcore"
tag "subworkflows/fasta_consensus_autocycler"
tag "autocycler"
tag "autocycler/compress"
tag "autocycler/cluster"
tag "autocycler/trim"
tag "autocycler/resolve"
tag "autocycler/combine"


test("sarscov2 - grouped contigs - fasta") {

when {
workflow {
"""
input[0] = Channel.of(
[
[ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/transcriptome.fasta', checkIfExists: true)
]
]
)
"""
}
}

then {
assertAll(
{ assert workflow.success},
{ assert snapshot(workflow.out).match()}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"sarscov2 - grouped contigs - fasta": {
"content": [
{
"0": [
[
{
"id": "test"
},
"consensus_assembly.fasta:md5,7bfb21bf1e4eeb3c5e6ee60c2a803202"
]
],
"1": [
[
{
"id": "test"
},
"consensus_assembly.gfa:md5,6812f1bbdbea6722b9726dd9251b080d"
]
],
"consensus_assembly": [
[
{
"id": "test"
},
"consensus_assembly.fasta:md5,7bfb21bf1e4eeb3c5e6ee60c2a803202"
]
],
"consensus_assembly_graph": [
[
{
"id": "test"
},
"consensus_assembly.gfa:md5,6812f1bbdbea6722b9726dd9251b080d"
]
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "25.04.4"
},
"timestamp": "2026-01-26T09:07:26.200354507"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: 'AUTOCYCLER_CLUSTER' {
ext.args = "--min_assemblies 1"
}
}
Loading