Bash Script Loop Help
1
0
Entering edit mode
6.1 years ago
V ▴ 380

Hello,

I'm trying to run hisat on loop and I've been trying to modify an existing loop I had set up but can't get it to work with my new file names.

My R1 is called WTCH_1_val_1.fastq and my R2 is called WTCH_2_val_2.fastq, where every time WTCH is actually a different value to distinguish the difference samples. This is the loop I was using so far when all of my samples were WTCH_1.fastq and WTCH_2.fastq

for f in `ls -1 *_1.fastq.gz | sed 's/_1.fastq.gz//' `
do
echo hisat2 -x mm10idx -1 ${f}_1.fastq.gz -2 ${f}_2.fastq.gz -S ${f}.bam
done

Could someone that is much better at this than I am please modify it for me? thanks

rnaseq bash loop • 4.0k views
ADD COMMENT
0
Entering edit mode

Just replace every instance of .fastq.gz with .fastq and it should work.

ADD REPLY
0
Entering edit mode

I've tried that but it doesnt work sadly, the echo returns:

hisat2 -x mm10idx -1 WTCHG_465974_296190_1_val_1.fq.gz -2 WTCHG_465974_296190_1_val_2.fq.gz -S WTCHG_465974_296190_1_val.bam

The loop as is thinks that the R2 finishes in "_1_val_2.fq.gz" but it finishes in "_2_val_2.fq.gz" the issue is the first _2 I think.

ADD REPLY
1
Entering edit mode
6.1 years ago
h.mon 35k

Revise and clean up your post: you are using .fastq, .fastq.gz and .fq.gz, with no indication on which is the correct.

If your files are named ${whatever}_1_val_1.fastq.gz and ${whatever}_2_val_2.fastq.gz, then:

for f in `ls -1 *_1.fastq.gz | sed 's/_1_val_1.fastq.gz//' `
do
echo hisat2 -x mm10idx -1 ${f}_1_val_1.fastq.gz -2 ${f}_2_val_2.fastq.gz -S ${f}.bam
done
ADD COMMENT
0
Entering edit mode

Sorry for the confusion, had mixed version of it. All sorted now with your post. Thanks alot! works like a charm.

ADD REPLY

Login before adding your answer.

Traffic: 1440 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6