Hi,
You can do a nested loop: the first loop checks each folder and the second does the salmon alignment.
Your folders name are a bit weird with :
and /
. Therefore, I will give you 3 example folders name: folder_1
, folder_2
, folder_3
.
folder_list=folder_1 folder_2 folder_3
for folder in $folder_list;
do
cd folder_1;
for f in `ls *.fq.gz | sed 's/_[12].fq.gz//g' | sort -u`;
do
echo "Processing sample $f"
salmon quant -i gencode.v33.transcripts.index -l A -1 ${f}_1.fq.gz -2 ${f}_2.fq.gz -p 6 --gcBias --validateMappings -o quants/${f}_quant
done;
cd ..;
done;
Since I don't want to mess with your for loop, what I did is to put a for loop before that will go through folder_1
, folder_2
, folder_3
, at each step will enter the current folder, it'll perform your for loop, then will go back and enter the next folder, and so on. This assumes that you're running your script in the directory that contains folder_1
, folder_2
, folder_3
.
I think this is one possibility to do what you want. Though has mentioned by @Pierre Lindenbaum a workflow manager such as nextflow or snakeflow is the way to go (though never use it myself).
I hope this helps.
António
try gnu-parallel or bash arrays.
using plain bash ? you'd better learn how to work with a with a workflow manager like nextflow / snakemake...
otherwise, use
find dir1 dir2 -type -f name "*.fq.gz"
instead ofls
Thanks ill look into snakemake