hey all, I encountered a problem that when I get m...
# help
c
hey all, I encountered a problem that when I get many files that I want to run in parallel in the same process. If take it in with
each()
in the process then it's not input as a file as
path()
does. How can I process each path?
Copy code
workflow {
file = Channel.fromPath("${params.input_dir}/*", checkIfExists: true).view()
index_reference(files, params.threads)

}

process index_reference {
    input:
    each(input_ref)
    val(threads)

...
}
a
It's not exactly clear what you mean with "in parallel in the same process": do you mean to process a large number of samples in parallel, i.e. using multiple tasks of the same process that can run in parallel? Or do you want to have a single task of your process that takes all the files together? In each case, you input should look like this:
Copy code
input:
path input_ref
Path inputs can either take a single file or a list of files, so the only difference between these cases is how you call your process: First case:
Copy code
def ch_files = Channel.fromPath("${params.input_dir}/*", checkIfExists: true)
index_reference(ch_files)
ch_files
here is a queue channel that contains 1 file per channel entry. Each entry will spawn a task of the
index_reference
task. In each task,
input_ref
is a single file. Nextflow will run these tasks in parallel if you executor has enough resources for it. Second case:
Copy code
def ch_files = Channel.value(files("${params.input_dir}/*", checkIfExists: true))
index_reference(ch_files)
Here,
ch_files
is a value channel with only a single entry that is a list of all your input files. The
index_reference
process is invoked only once and
input_ref
is a list of files.
c
I mean run a large number of samples respectively with the same process
however when my input look like this
Copy code
input:
path input_ref
it took all the files in the same process together than respectively, even if I tried to use ch_files.flatten() as input
a
How does your
view
from the input channel looks like? You have a typo with
file/files
in your code example, so I assume that's not actually the code that you are running?
c
you are right. After resolving the version issue,
path()
works. Thanks for helping!