SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
need to deinterleave/split all fastq files within a directory lac302 Bioinformatics 3 01-24-2018 01:12 PM
Efficient way to split FASTQ files based on Illumina indexes in the ID TompaB Bioinformatics 7 04-09-2015 04:01 PM
Split Large FASTQ file in small FASTQ files with user defined number of reads Windows deepbiomed Bioinformatics 3 04-04-2013 07:14 AM
Split fastq files for tophat analysis Bobbieshaban Bioinformatics 2 03-12-2013 06:44 AM
Split fastq into smaller files lorendarith Bioinformatics 10 12-13-2012 04:28 AM

Reply
 
Thread Tools
Old 08-09-2018, 12:52 PM   #1
landrjos
Junior Member
 
Location: Virginia

Join Date: Aug 2018
Posts: 3
Default Split Fastq into 2 files

Hi All,

I have a fastq file which I would like to split into 2 files with every other read going into the 2 separate files. What would the Split function command line be for this? I am a new to computing, so it you are most explicit that would be helpful.

Best,
landrjos is offline   Reply With Quote
Old 08-09-2018, 06:57 PM   #2
anoopkmr
Junior Member
 
Location: Boston

Join Date: Aug 2018
Posts: 4
Default

Found it in a post here:https://stackoverflow.com/questions/...om-a-text-file

"sed
You can accomplish the same thing with sed. devnulls answer shows how to do it with GNU sed. Below are alternatives for versions of sed that do not have the ~ operator:

keep odd lines

sed 'n; d' infile > outfile
keep even lines

sed '1d; n; d' infile > outfile"
anoopkmr is offline   Reply With Quote
Old 08-09-2018, 07:31 PM   #3
landrjos
Junior Member
 
Location: Virginia

Join Date: Aug 2018
Posts: 3
Default Fastq reads are in groups of 4 lines

Hi anoopkmr,

Thanks for the reply. I made a mistake, I was not clear enough. I would like to partition the odd or even "reads" from a fastq file. The reads are in groups of 4 lines in the fastq file. So I would like read 1 (lines 1-4) to go to file1, and read 2 (lines 5-8) to go to file2, and so on until the whole fastq file is divided into two files, the odd (lines 1-4, 9-12, etc...) output file and the even (lines 5-8, 13-16, etc...) output file.

Not every even line and every odd line going to the output files.

Is there a way to do that?

Best,
landrjos is offline   Reply With Quote
Old 08-09-2018, 07:55 PM   #4
anoopkmr
Junior Member
 
Location: Boston

Join Date: Aug 2018
Posts: 4
Default

That makes a lot more sense. Sorry, in my own confusion I thought you were trying something more creative and beyond my understanding.

fastq-dump seems like an option but if you are generating these files from BAMs it might be easier to step back to the previous step and generate them all at once.

Not very useful but I hope it helps. Good luck!
anoopkmr is offline   Reply With Quote
Old 08-10-2018, 04:00 AM   #5
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,795
Default

@landrjos: What you are describing is called an interleaved fastq file where R1 and R2 reads are present in a single file.

You can use reformat.sh from BBMap suite to separate the R1 and R2 reads into their own files.

Code:
reformat.sh in=interleaved.fq.gz out1=R1.fq.gz out2=R2.fq.gz
GenoMax is offline   Reply With Quote
Old 09-27-2018, 10:31 PM   #6
lethalfang
Member
 
Location: San Francisco, CA

Join Date: Aug 2011
Posts: 91
Default

Try this:
cat original.fastq | awk 'NR%8==1 || NR%8==2 || NR%8==3 || NR%8==4' > first4s.fastq
cat original.fastq | awk 'NR%8==5 || NR%8==6 || NR%8==7 || NR%8==0' > second4s.fastq
lethalfang 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 03:21 PM.


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