I am trying to modify a pipeline for viral taxonomy analysis. In this pipeline, the variables R1 and R2 are the two input paired-end fastq files. But theses files can be .fastq.gz
or .fq.gz
. After trimming of these fastq files with the program Trimgalore, the pipeline is coded to rename them by removing the suffix and adding an other. The pipeline can treat only .fq.gz files for the moment:
mv `basename $R1 .fq.gz`_val_1.fq $trimmedR1
mv `basename $R2 .fq.gz`_val_2.fq $trimmedR2
and I am trying to correct it:
#Command to execute:
if [[ "$R1" == *.fq.gz ]]
then
mv `basename $R1 .fq.gz`_val_1.fq $trimmedR1
mv `basename $R2 .fq.gz`_val_2.fq $trimmedR2
else
mv `basename $R1 .fastq.gz`_val_1.fq $trimmedR1
mv `basename $R2 .fastq.gz`_val_2.fq $trimmedR2
fi
but my command above is not correct and I don't know why. I also tried to use the command basename -a
but it didn't work too. Thanks in advance to help me correct my code.