dsl2 functions and processes

105 views
Skip to first unread message

Eldad Kdoshim

unread,
Mar 16, 2021, 3:41:31 AM3/16/21
to Nextflow
hi 
is there an example of doing something like this
processB(inputChannel.join(foo(processA.out)))

while foo is a mapping function. 
processA.out is a channel of tuples
my aim is to give a name or a context to the mapping 
instated of just doing map{it[0],it[3],it[4]} for example.

or alternatively,  Is it possible to call foo from inside the map block?

Thanks

Eldad Kdoshim

unread,
Mar 16, 2021, 5:34:46 AM3/16/21
to Nextflow
I did a small example   that works but on my real flow I got InvocationTargetException

nextflow.enable.dsl=2

include {extractText} from './func.nf'

process x{
input:
val x

output:
tuple val(x), val(a2x), path(out_file)

script:
out_file="xout"
a2x = x+2
"""
echo "$x, perfect!" > $out_file
"""

}

process b{
echo true
input:
tuple val (x), val(a2x), val(message)

script:
"""
echo $x:
echo $a2x:
echo $message
echo "*****"
"""
}

ch = Channel.from(1,2,3,4)

empty_file = file('EMPTY')


workflow{
x(ch)
ch2 = extractText(ch.join(x.out, remainder: true))
b(ch2)
}

func.nf:
def foo (it){
it.readLines()[0]
}

def extractText(channel_tuple) {
channel_tuple.map{[it[0],foo(it[2])]}
}

Reply all
Reply to author
Forward
0 new messages