For cycle and &&

Hello there!

I’m trying to incluce For cycle in my Qiime2 full pipeline.
I already lunch multiple subsequent command with "&& " and now i trying to use for cycle because i analyze different data set in different folder.
I already successfully lunch this command line:
for i in {1…7}
do
qiime taxa collapse
–i-table right/path/ASV_table.qza
–i-taxonomy /right/path/taxonomy.qza
–p-level $i
–o-collapsed-table another/path/ASV_collapsed_Level_$i.qza
done
and that work… so i try another one but with different usage.
i want use “$i” as part of a path.

for i in {first/path/piece,second/path/piece,third/path/piece}
do
qiime feature-classifier classify-sklearn
–i-classifier right/path/classifier.qza
–i-reads same/path/for/all/{i}/rep_seqs.qza \ --o-classification same/path/for/all/{i}/taxonomy.qza
done
but my terminal not work… no error message, no nothing… i trying to press enter multiple time but nothing… i let it in that condition for one nigth, but nothing…

I sure i wrong something but i am a noob in python… help me please

ps sorry for my English :stuck_out_tongue:

Hi @J_D_L,
Welcome in the forum!

First of all, I moved your question to ‘Other bioinformatic tool’, as to me is more on generic programming languages then specific on QIIME2!

I am not a python person, but this code looks very ‘bash’ style to me, so I would suggest to replace ‘i’ with ‘$i’ in any line within the loop.
You may want to use quote marks in the definition of the for loop variable, I’d say!

As general point, try to start using only the first loop variable and make sure it is working his way, then add the following variable!
Hope it helps!
Ciao
Luca

3 Likes

Hi @J_D_L,

If I can offer another suggestion/solution, I’ve had a lot of recent success with snakemake which does the for-loops for you under the hood. (You can see an example of a processing pipeline for 16S runs here.

Best,
Justine

3 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.