How to handle the case where a tool simply returns...
# modules
e
How to handle the case where a tool simply returns a single value and nothing else? (to stdout)
m
you mean like this?
e
No, I think I worded my request wrongly: I mean, I want to store it somewhere (so it can be collected at the end of whatever workflow is used), but the tool just spits out this value and nothing else
m
You can use
eval
and handle it like we do the versions?
e
Oh, right, my idea was to wrap it somewhow with
meta.id
so I can have the sample and the associated value
or just redirect to a file
m
you can use the
stdout
option, then read it and add it to
meta
using
map
e
Hmm, are there any modules that do that?
Because this is omething I want to make a PR for
m
No idea 🤷🏻
search says no
e
Ok, redirect to file it is!
m
Nothing stopping you from using
stdout
if you’re just going to read the value anyway
saves you the code for writing and reading
Copy code
process stdoutprocess {
    input:
    tuple val(meta), path(whatever)

    output:
    tuple val(meta), stdout, emit: results

    script:
    """
    tool --input $whatever
    """
}

workflow {
    stdoutprocess.results.map{ meta, out -> return [meta + [output: out]]}
}
Or smth like this
e
Yeah, but I thought it would be better for the end user to have a file with the data and the
meta.id
so I just piped it into
sed
to prepend
meta.id
then a tab, done.
m
Also works 😄
p
I don't like
stdout
because it can sometimes pick up noise from other side processes (eg. slurm complaining about something)
If you redirect to a file, you're guaranteed to capture only the stdout from that tool invocation, so it's fractionally safer