Is this the good way to handle one or many inputs?...
# nostupidquestions
a
Is this the good way to handle one or many inputs?
Copy code
input:
    tuple val(meta), path(reads)
    ....

    """
    fastcat \\
        $args \\
        --threads $task.cpus \\
        --sample ${prefix} \\
        ${reads.join(' ')} 2&>1 /dev/null <--- this
    """
s
I think that by default
${reads}
will expand to
file1.ext file2.ext file3.ext ...
If you need to give them each a flag (e.g.
-i
) you can do something like: https://github.com/nf-core/modules/blob/96398d76ad719f9b57f27ff39c09834b7815461b/modules/nf-core/sentieon/dedup/main.nf#L36
👀 1
a
Thanks a ton, I'll test that out.
Also don't judge my code 😭 the redirect is wrong
s
I did wonder what the redirect was for
a
Correct me if I'm wrong, but I think a single input file will not be a list and the
join
method will not be found in this case. Therefore, you should use
path(reads, arity: '1..*')
to always force it into a list.
a
What's the arity option for?
I should have reported back, Simon's suggestion was spot on
a
The
arity: '1..*'
will make sure that
reads
is always a list, even if only a single input file is provided. This will make sure that the
reads
object will always have a
join
method to call. But of course, you don't need the
join
at all in this case.
🙏 1
a
Oh thats a cool feature, thanks for explaining.