Question: Bash Script Loop Help
0
gravatar for V
18 months ago by
V110
UK/London
V110 wrote:

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

bash loop rnaseq • 1.0k views
ADD COMMENTlink written 18 months ago by V110

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

ADD REPLYlink written 18 months ago by h.mon27k

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 REPLYlink modified 18 months ago • written 18 months ago by V110
1
gravatar for h.mon
18 months ago by
h.mon27k
Brazil
h.mon27k wrote:

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 COMMENTlink written 18 months ago by h.mon27k

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

ADD REPLYlink written 18 months ago by V110
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1840 users visited in the last hour