Skip to content
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

Function for mapcombinemultimap #339

Merged
merged 7 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 28 additions & 0 deletions lib/WorkflowTaxprofiler.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import nextflow.Nextflow
import groovy.text.SimpleTemplateEngine
import groovyx.gpars.dataflow.DataflowBroadcast

class WorkflowTaxprofiler {

Expand Down Expand Up @@ -242,4 +243,31 @@ class WorkflowTaxprofiler {
Nextflow.error(error_string)
}
}


/**
* Join output from a channel back to the original database the output was associated with
*
* The channel elements are assumed to be tuples one of [ meta, profile ], and the
* database to be of [db_key, meta, database_file].
*
* @param ch_profile A channel containing a meta and the profilign report of a given profiler
* @param ch_database A channel containing a key, the database meta, and the database file/folders itself
* @return An multiMap'ed output channel with two sub channels, one with the profile and the other with the db
*/

static DataflowBroadcast mapCombineMultimap(DataflowBroadcast ch_profile, DataflowBroadcast ch_database) {

DataflowBroadcast ch_prepped_channel = ch_profile
.map { meta, profile -> [meta.db_name, meta, profile] }
.combine(ch_database, by: 0)
.multiMap {
key, meta, profile, db_meta, db ->
profile: [meta, profile]
db: db
}

return ch_prepped_channel
}
Midnighter marked this conversation as resolved.
Show resolved Hide resolved

}
9 changes: 1 addition & 8 deletions subworkflows/local/profiling.nf
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,7 @@ workflow PROFILING {
.filter { meta, db -> meta.tool == 'centrifuge' }
.map { meta, db -> [meta.db_name, meta, db] }

ch_input_for_centrifuge_kreport = CENTRIFUGE_CENTRIFUGE.out.report
.map { meta, profile -> [meta.db_name, meta, profile] }
.combine(ch_database_for_centrifugekreport, by: 0)
.multiMap {
key, meta, profile, db_meta, db ->
profile: [meta, profile]
db: db
}
ch_input_for_centrifuge_kreport = WorkflowTaxprofiler.mapCombineMultimap(CENTRIFUGE_CENTRIFUGE.out.report, ch_database_for_centrifugekreport)

// Generate profile
CENTRIFUGE_KREPORT (ch_input_for_centrifuge_kreport.profile, ch_input_for_centrifuge_kreport.db)
Expand Down
Loading