How do I iterate over nth files from within a process? #3820
Answered
by
bentsherman
DescartesM
asked this question in
Q&A
-
I found an example on the FAQ, but it not work for me. Maybe I made some mistakes.
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
process copy_data_for_loop {
input:
path inList from in_ch.collect()
output:
path('*.txt')
script:
"""
for inElem in ${inList}
do
cp ${inElem} new-${inElem}.txt;
echo ${inElem};
done
"""
}
workflow {
in_ch = Channel.fromPath(params.in)
outputs = copy_data_for_loop(in_ch)
} Then I change my nf file, get the different error
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
process copy_data_for_loop {
input:
path inList
output:
path('*.txt')
script:
"""
for inElem in ${inList}
do
cp ${inElem} new-${inElem}.txt;
echo ${inElem};
done
"""
}
workflow {
in_ch = Channel.fromPath(params.in).collect()
outputs = copy_data_for_loop(in_ch)
} |
Beta Was this translation helpful? Give feedback.
Answered by
bentsherman
Apr 3, 2023
Replies: 1 comment
-
That FAQ is very out of date, it will be removed soon. The example you copied was in DSL1, but I see you ported it to DSL2. Your current error is that |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DescartesM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That FAQ is very out of date, it will be removed soon. The example you copied was in DSL1, but I see you ported it to DSL2.
Your current error is that
inElem
is a Bash variable, not a Nextflow variable, so you need to escape it in the script:\${inElem}
.