For loop to go over all files in a folder to execute after qc
1
0
Entering edit mode
2.1 years ago

Hello everyone, i am new in bash scripting, so I want your help on How to execute 100 directories with pared end _1.fastq and _2.fastq sequence files.

For indivisibly here how I am doing For 1st sample

cd SSR1
python /home/jitender/miniconda3/envs/py2/bin/after.py -1 ./SRR1/ERR13556376.lite.1_1.fastq -2 ./SRR1/ERR13556376.lite.1_2.fastq

for 2nd sample

cd SSR2
python /home/jitender/miniconda3/envs/py2/bin/after.py -1 ./SRR2/SRR13556377.lite.1_1.fastq -2 ./SRR2/SRR13556377.lite.1_2.fastq

like this i have 100 samples, for individually it is quit bit difficult or there is chance of mistake while preparing script.

So, i am trying to prepare bash script it but i am not able to understand how to proceed with. I searched online and find some solution but isn't working for me.

So, anyone out there please help me how should i proceed with.

My data folder structure following type:

main directory: Data/
Subdirectories of samples: SRR1, SRR2, SRR3, SRR4 .......SRR100.
Fastq files: sample SRR1/E12345_1.fastq, E12345_2.fastq

Thank you :)

bash loop script • 1.2k views
ADD COMMENT
2
Entering edit mode
2.1 years ago
iraun 6.2k

Not sure if I have understood your folder organisation but try to go inside your Data folder, (where all the SRR directories are located) and:

for d in SRR*/; do
    # your command
     python  /home/jitender/miniconda3/envs/py2/bin/after.py -1 $d/*_1.fastq -2 $d/*_2.fastq
done
ADD COMMENT
0
Entering edit mode

Thank you very much iraun for your early reply.

I think its works for me

I appreciate your help

thanx lot :)

have a good day !!!

ADD REPLY
0
Entering edit mode

Hi iraun

I need one more help and suggestions above code generating QC report in my Data directory. Due to this there will be chance of replacing existing one, so Is there any code to generate QC report in same SRR* directory

Thank you vey much :)

ADD REPLY
4
Entering edit mode

Hey, glad that worked :). So, if I understand it, you want the output QC files inside each SRR directory? If so, I guess you could try something like:

for d in SRR*/; do
     cd $d;
     # your command
     python  /home/jitender/miniconda3/envs/py2/bin/after.py -1 *_1.fastq -2 *_2.fastq
     cd ..
done
ADD REPLY
1
Entering edit mode

Exactly what I mean.

Thank you once again !!! :)

ADD REPLY

Login before adding your answer.

Traffic: 1971 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6