Entering edit mode
17 months ago
Jinsoul
•
0
Hi all,
I'm expecting to get 17 different paired-end fastq files (34 in total), so I want to make a bash script to just run my code through all the fastq files in a directory at once. How can I change the name of the input and output files each time the script runs though each file? So when it moves to the file_002, all names have file_002 at the beginning instead of file_001 and so on. And also, when merging the R1 and R2 reads how can I make that it only merges the corresponding files with a loop?
for file in directory_name
do
pear -f file_001_R1.fastq.gz -r file_001_R2.fastq.gz -o file_001.fastq
cutadapt -g TGATAACAATTGGAGCAGCCTC...GGATCGACCAAGAACCAGCA -o file_001_barcode.fastq file_001.fastq
cutadapt -g GTGTACAAATAATTGTCAAC...CTGTCTCTTATACACATCTC -o file_001_UMI.fastq file_001.fastq
seqkit concat file_001_barcode.fastq file_001_UMI.fastq > file_001_concatenation.fastq
done
Thank you
You could try something like this:
This is a fairly clunky approach.
It would be better to use bash parameter expansion. Some examples of this are shown here: How to run BWA or the other aligner for paired .fastq in a bash loop and pipeline?