Workhorse
Workhorse

Reputation: 1560

For loop on Subset of Files

Cell1.1.annot.gz
Cell1.2.annot.gz
Cell1.3.annot.gz
Cell1.4.annot.gz
Cell1.5.annot.gz
Cell2.1.annot.gz
         .
         .
         .
Cell3.5.annot.gz

Making for a total of 3 X 5 = 15 files. I would like to run a python script on them. However, the catch is that each number (clarified here:Cell2.NUMBER.annot.gz) has to be matched to another file in a separate directory. I have code that works below, although it only works for one Cell file at a time. How can I automate this so it works for all files? (So Cell1...Cell3?)

for i in `seq 1 5`; 
do python script.py --file1 DNA_FILE.${i} --file2 Cell1.${i}.annot.gz --thin-annot --out Cell1.${i} ;done

Upvotes: 0

Views: 162

Answers (1)

Paul Hodges
Paul Hodges

Reputation: 15273

Another loop?

for c in 1 2 3
do  for i in 1 2 3 4 5
    do python script.py --file1 DNA_FILE.${i} --file2 Cell${c}.${i}.annot.gz --thin-annot --out Cell${c}.${i}
    done
done

Upvotes: 1

Related Questions