I am trying to create a script that will, within a for loop, identify pairs of files in a directory and then perform a function on each pair. The paired files are named such as FILENAME_1.fastq and FILENAME_2.fastq and there are multiple pairs within the directory. Here are some actual filenames in case it matters for regex functions:
WT1_0min-SRR9929263_1.fastq
WT1_0min-SRR9929263_2.fastq
WT1_20min-SRR9929265_1.fastq
WT1_20min-SRR9929265_2.fastq
WT3_20min-SRR12062597_1.fastq
WT3_20min-SRR12062597_2.fastq
Is it possible to do this without feeding any information about the filename, other than that it has a pair? I am absolutely awful with regex and name-search functions, but below is my latest failed attempt.
cd ~/Directory
for file in *.fastq
do
sample=`basename ${file}` #I think needs a modification to subtract the _1 or _2 and then a search function to find the paired files
myfunction \
-1 ${sample}_1.fastq \
-2 ${sample}_2.fastq \
done
Thanks for any help. Been stuck for 2 days x_x