Reputation: 13
I am trying to optimize a for loop to download files from a website based in a file with SPECIES names and their corresponding numbers of ACCESSION. I want the loop to work first with the first species and the first accession number of the each file and so on... I tried the basic rule but it is not working.
#!/bin/sh
#Load modules
module load sra-toolkit/2.10.7-centos_linux64
Automatized download and assembly of transcritomes. SRA accession and species code required as arguments for the script
WORKSPACE=/vto
WORKSPACEFINAL=/vto
SPECIES=${WORKSPACE}/species_names.txt
ACCESSION=$accession_numers.txt
for i in $SPECIES
for j in $ACCESION
do
mkdir $SPECIES
cd $SPECIES
#SRA download and processing.
prefetch $ACCESSION
fastq-dump --defline-seq '@$sn[_$rn]/$ri' --split-files ${WORKSPACEFINAL}/ncbi/public/sra/${ACCESSION}.sra -O ${ACCESSION}
done
Upvotes: 1
Views: 100
Reputation: 94
Do you have two loops and just one done and do you have that working?
And as @Mheni said it seems that you aren't using the loop's variables
Here an example of a simple script with two loops one inside the other
file_a=$(cat file_a.txt)
file_b=$(cat file_b.txt)
for i in $file_a
do
for j in $file_b
do
printf "$i\n"
printf "$j\n"
done
#// if you add code here is outside j loop
done
Upvotes: 1