-
Notifications
You must be signed in to change notification settings - Fork 956
Add Autocycler postassembly subworkflow #9786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwells-eit
wants to merge
4
commits into
nf-core:master
Choose a base branch
from
dwells-eit:autocycler_postassembly
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+217
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}"} | ||
| ) | ||
|
|
||
| // 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
44
subworkflows/nf-core/fasta_consensus_autocycler/tests/main.nf.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()} | ||
| ) | ||
| } | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
subworkflows/nf-core/fasta_consensus_autocycler/tests/main.nf.test.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
subworkflows/nf-core/fasta_consensus_autocycler/tests/nextflow.config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| process { | ||
| withName: 'AUTOCYCLER_CLUSTER' { | ||
| ext.args = "--min_assemblies 1" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?