SEQanswers

Go Back   SEQanswers > Applications Forums > Metagenomics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sam to Bam using bowtie and using the shell script AnushaC Bioinformatics 7 11-01-2013 05:17 PM
shell script help Kennels Bioinformatics 2 07-15-2013 06:26 PM
Shell script to get MiSeq tech support info... ECO Illumina/Solexa 0 08-02-2012 09:35 AM
running samtools in shell script zorph Bioinformatics 4 03-02-2012 06:46 AM
Mira assembly -shell script robelb4 Bioinformatics 2 07-21-2011 07:57 AM

Reply
 
Thread Tools
Old 04-21-2016, 11:41 AM   #1
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Default shell script for concatenating fastq files

Hi,

I have 30 samples, each was sequenced in 3 flow cells in all 8 lanes. So I have three directories: FC1, FC2, and FC3. Inside FC1, there are 30 sub-directories: Sample_1, Sample_2,...,Sample_30. Inside Sample_1, e.g., there are 8 files for forward and 8 files for reverse (pair-end). All are .gz files.

I wrote a shell script to concatenate all the fastq reads from the same sample so that each sample has two fastq files: Sample_1_R1.fastq and Sample_2_R2.fastq (reverse).

for i in `seq 1 30`
do
gzip -dc Sample_${i}/*_R1_*fastq.gz >>Sample_${i}/Sample_${i}_R1.fastq ## forward
done

There are bugs but I can't figure out. Wonder what did I do wrong? Or someone here can show me a btter way to do this?

thanks
John
JQL is offline   Reply With Quote
Old 04-21-2016, 12:10 PM   #2
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

for i in `seq 1 30`
do
cat /dev/null > bigSample_${i}.R1.fq # create empty file
cat /dev/null > bigSample_${i}.R2.fq # create empty file

# create big R1 file for i-th sample
zcat FC1/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq
zcat FC2/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq
zcat FC3/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq

# create big R2 file for i-th sample
zcat FC1/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
zcat FC2/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
zcat FC3/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
done

Last edited by Richard Finney; 04-21-2016 at 12:13 PM.
Richard Finney is offline   Reply With Quote
Old 04-21-2016, 02:13 PM   #3
JQL
Member
 
Location: MO, USA

Join Date: Apr 2011
Posts: 83
Smile

Thanks Richard.
I got mine to work. But I think your code is much cleaner. I like it.

John


Quote:
Originally Posted by Richard Finney View Post
for i in `seq 1 30`
do
cat /dev/null > bigSample_${i}.R1.fq # create empty file
cat /dev/null > bigSample_${i}.R2.fq # create empty file

# create big R1 file for i-th sample
zcat FC1/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq
zcat FC2/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq
zcat FC3/Sample_${i}/*R1*fastq.gz >> bigSample_${i}.R1.fq

# create big R2 file for i-th sample
zcat FC1/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
zcat FC2/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
zcat FC3/Sample_${i}/*R2*fastq.gz >> bigSample_${i}.R2.fq
done
JQL is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 02:54 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO