Arctick
Arctick

Reputation: 25

Nextflow dynamic includes and output

I'm trying to use dynamic includes but I have problem to manage output files:

/* 
 * enables modules 
 */
nextflow.enable.dsl = 2

include { requestData } from './modules/get_xapi_data'
include { uniqueActors } from './modules/unique_actors'
include { compileJson } from './modules/unique_actors'

if (params.user_algo) {
    include { userAlgo } from params.user_algo
}

workflow {
    dataChannel = Channel.from("xapi_data.json")
    requestData(dataChannel)
    uniqueActors(requestData.out.channel_data)

    if (params.user_algo) {
        user_algo = userAlgo(requestData.out.channel_data)
    } else {
        user_algo = null
    }

    output_json = [user_algo, uniqueActors.out]
    // Filter output
    Channel.fromList(output_json)
        .filter{ it != null }            <--- problem here
        .map{ file(it) }
        .set{jsonFiles}

    compileJson(jsonFiles)
}

The problem is userAlgo can be dynamically loaded. And I don't know how I can take care of it. With this solution, I got a Unknown method invocation getFileSystem on ChannelOut type error.

Upvotes: 1

Views: 866

Answers (1)

Steve
Steve

Reputation: 54502

The problem is that fromList expects a list of values, not a list of channels. If you use an empty Channel instead of checking for a null value, you could use:

if( params.user_algo ) {
    user_algo = userAlgo(requestData.out.channel_data)
} else {
    user_algo = Channel.empty()
}

user_algo
    | concat( uniqueActors.out )
    | map { file(it) }
    | compileJson

Upvotes: 2

Related Questions