Hi, there
I want to assign the sample id to the output of trimmomatic but I failed. The name of the output is _clean.fastq and the variable j is missing. How can I figure out this issue? Thanks in advance!
for i in ./single/*.fastq
do
echo ${i}
j=$(echo ${i} | cut -d "." -f1)
java -jar /home/anaconda3/share/trimmomatic/trimmomatic.jar SE -phred33 ${i} ./single/${j}_clean.fastq ILLUMINACLIP:/home/anaconda3/share/trimmomatic/adapters/TruSeq3-SE.fa:2:30:10 SLIDINGWINDOW:4:15 LEADING:3 TRAILING:3 MINLEN:36
done
what are the names of the files, what are the errors, what are the messages, and what is the shell ?
Actually, I just want to test if this shell script works. There is only one .fastq file in the ./single directory named SRR222423.fastq. The input of trimming is SRR222423.fastq. And I want to get the output in the same directory with the name like SRR222423_clean.fastq. No error appears. The output is a .fastq file with the name _clean.fastq. There is no sample id SRR222423. The shell is bash.
if your input is really
./single/*.fastq
then
will be an empty string... because the first char is just a dot...
Nope, I think the input is SRR222423.fastq and I split it by using dot. After that, I use -f1 to choose the first part then I get SRR222423. Is it correct?
If it generates expected output then it is correct. In this case. If you had more than one
.
in file names then you may get unexpected results. You could usebasename
instead.I’d even say you should always use basename for things like this.
The command basename works well, thanks so much!