currently I'am working on a script that that should produce some PBS script which can be submited to the cluster. My normal scripts are working well but now I'am facing the problem of having two input file for one program. One of my scripts for example looks like:
#!/bin/bash
echo -e "#!/bin/bash\n
#SBATCH --job-name=whatever
#SBATCH --export=NONE
#SBATCH --nodes=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=80G
#SBATCH --partition=blabla
#SBATCH --blabla" >> $1
echo -e "touch log_file_$1\n" >> $1
x=$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd )
for file in /foo/bar/foo/bar/*; do
rl=$(readlink -f $file)
kw=${rl##*/}
id=${kw%%.*}
gz_weg=${kw%.*}
if [ ! -d "$id" ]; then
mkdir "$id"
fi
echo "echo $kw >> log_file_$1" >> $1
printf "foo-bar --mode barbar -e 0.001 --index /barz/barz/barz.index --inFile $rl --output $x/$id/$gz_weg.rma 2>> $x/log_file_$1 \n" >> $1
echo "echo -e '"\\n"' >> log_file_$1" >> $1
echo -e "\n" >> $1
done
Not a beauty I guess but it works for me. But now as stated above I'am facing the problem of having two input files. They are both in the same folder and I tried something like:
for file in /ifs/data/nfs_share/sukmb241/raw_data/samples/iceman_old/iceman.UDG.*/*.fastq.gz; do
bs=$(basename $file)
if [[ "$bs" == *R1* ]]; then
r1=$(readlink -f $file)
k1=${r1##*/}
id1=${k1%%.*}
gz_weg1=${k1%.*}
fi
if [[ "$bs" == *R2* ]]; then
r2=$(readlink -f $file)
k2=${r2##*/}
id2=${k2%%.*}
gz_weg1=${k2%.*}
fi
if [ ! -d "$id1" ]; then
mkdir "$id1"
fi
echo "echo $kw >> log_file_$1" >> $1
printf "blablabla -in1 $r1 -in2 $r2 -f foo -r bar -l 25 -qt -q 20 -o $x/$id1/whatever -verbose 2>> $x/log_file_$1 \n" >> $1
echo "echo -e '"\\n"' >> log_file_$1" >> $1
echo -e "\n" >> $1
done
fi
Because the files differ only in R1 or R2 in their filenames. However I realised this will not work properly because it will only get me one file. So how to solve the problem that -in1 is pointing to the file containing the R1 and -in2 containing the R2
Thanks in advance :)