I would appreciate if someone could give me some tips on how to progress here.
The layout: Writing an Ubuntu bash script.
I have 3 input files into a folder called "reads":
$HOME/reads/
-Al-26-c45.fastq.trim.gz
-Br-45-e12.fastq.trim.gz
-Ct-1-d3.fastq.trim.gz
then I have 3 target files into a folder called "genomes":
$HOME/genomes/
-GCA_000066785.1_JCVI-PMFA1-2.0_genomic.fna.gz
-GCA_000003455.1_CPGHF-drosophila_genomic.fna.gz
-GCA_000034485.1_Sirimis_Turnuata.0_genomic.fna.gz
My expected output is:
$HOME/reads/
-Al-26-c45.fastq.aligned.gz
-Al-26-c45.fastq.trim.gz
-Br-45-e12.fastq.aligned.gz
-Br-45-e12.fastq.trim.gz
-Ct-1-d3.fastq.aligned.gz
-Ct-1-d3.fastq.trim.gz
I am trying to write a script using a nested For-Do loop to iterate the program "Myprogram" on each read against all the target genomes, and output a new file that contains the same read name except the "trim" word is replaced with "aligned" word.
This is what I wrote so far, but it only works for the first read file:
#!/bin/bash
dir="$HOME/reads/"
for input in "$dir"/*.fastq.gz; do
orifile=$input
for file in $HOME/genomes/*.fna.gz; do
Myprogram in=$input ref=$file out=unmapped.fastq
old="trim"
new="aligned"
ls -1 "$dir"/*.fastq.trim.gz |\
while read file ; do
mv ./unmapped.fastq "${input/${old}/${new}}"
done
done
done
The script fails to rename the output file for reprocessing on the next iteration.
Any guidance on the parts that need work, and where I can learn, are truly appreciated. Thanks.