SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
50 bp paired end reads vs. 100 bp single end reads efoss Bioinformatics 12 01-15-2014 09:05 PM
Bfast alignement with paired end reads in separate files david.tamborero Bioinformatics 2 11-29-2011 08:49 AM
paired-end reads mapped to genome.. gene with only one direction of paired-end reads? danwiththeplan Bioinformatics 2 09-22-2011 03:06 AM
Mira assembler: Medium sized genomes;How to use 2 separate files for paired-end reads ndeshpan Bioinformatics 3 05-23-2011 06:59 PM

Reply
 
Thread Tools
Old 09-27-2012, 07:49 AM   #1
Fad2012
Member
 
Location: UK

Join Date: Sep 2012
Posts: 61
Default Paired-end reads into two different files

Hello all

I am using a software called MetaSim to generate reads based on given genome sequences. My problem is that the reads i produced are paired-ends in one multifasta file. the paired reads look like the following:

>r1.1 |SOURCES={GI=61252,fw,624-696}|ERRORS={67:A}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
ATTGGCCATCCGGTGAAAGTGAGACTCATTATCTATCTGTTTGCTGGATCCGCTCCATTGAGTGT
GTATACT
>r1.2 |SOURCES={GI=61252,bw,789-861}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
GCGTTACTAGCTGAATCTCTATAATAATTAATGGTGGTGTAATTAATGGTAGAACCACCATACGC
TCTATTT
>r2.1 |SOURCES={GI=61252,fw,6323-6395}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
CCACCAGTGCTGGCTACCCTTATGTAGCAATGGGAAAGAAGAAGAGAGACATCTTGAACAAACAA
ACCAGAG
>r2.2 |SOURCES={GI=61252,bw,6502-6574}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
AGCATATAGGTTCCCAAAAGCCATTCTCATTGCCACTGAGTCATTCAAACTAGAAGCTTCAATTA
ATCTGGA

I want the backward reads in a separated file, and the forward reads in another file. Does anyone have any idea about a perl script or any other tool to separate these two reads into two different files; then i will be able to align them using Bowtie or any other alignment tool.

Many thanks
Fad2012 is offline   Reply With Quote
Old 09-27-2012, 09:43 AM   #2
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

You could just use grep. Something like this should work:
Code:
grep -A 1 ".1 " reads.fa > reads_1.fa
grep -A 1 ".2 " reads.fa > reads_2.fa
dpryan is offline   Reply With Quote
Old 09-27-2012, 11:25 AM   #3
vivek_
PhD Student
 
Location: Denmark

Join Date: Jul 2012
Posts: 164
Default

Quote:
Originally Posted by dpryan View Post
You could just use grep. Something like this should work:
Code:
grep -A 1 ".1 " reads.fa > reads_1.fa
grep -A 1 ".2 " reads.fa > reads_2.fa
This should print only the headers and not the sequence right?
vivek_ is offline   Reply With Quote
Old 09-27-2012, 11:27 AM   #4
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Quote:
Originally Posted by vivek_ View Post
This should print only the headers and not the sequence right?
No, check the man page for grep.
dpryan is offline   Reply With Quote
Old 09-27-2012, 11:55 AM   #5
vivek_
PhD Student
 
Location: Denmark

Join Date: Jul 2012
Posts: 164
Default

My bad! Did not notice the -A 1 at the beginning.
vivek_ is offline   Reply With Quote
Old 09-28-2012, 04:09 AM   #6
Fad2012
Member
 
Location: UK

Join Date: Sep 2012
Posts: 61
Default

Hello

I still get both 1.1 and 1.2 in the output file. Does it have to do with the extension of my file which is .fna, this how i am doing it; in the terminal i am in the directory where my file is, my file is: test.fna:

grep -A 1 ".1 " test.fna > reads_1.fna
grep -A 1 ".2 " test.fna > reads_2.fna

Many thanks for your help
Fad2012 is offline   Reply With Quote
Old 09-28-2012, 04:21 AM   #7
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Quote:
Originally Posted by Fad2012 View Post
Hello

I still get both 1.1 and 1.2 in the output file. Does it have to do with the extension of my file which is .fna, this how i am doing it; in the terminal i am in the directory where my file is, my file is: test.fna:

grep -A 1 ".1 " test.fna > reads_1.fna
grep -A 1 ".2 " test.fna > reads_2.fna

Many thanks for your help
Ah, I see that it's treating "." as a match to any character, I should have foreseen that. Try instead:
Code:
grep -A 1 "\.1 " test.fna > reads_1.fna
grep -A 1 "\.2 " test.fna > reads_2.fna
I should note that, at least under Ubuntu, this results in each read being separated by a "--" line. If that happens for you too, then just add the "--no-group-separator" option (i.e, grep -A 1 --no-group-separator "\.1 " test.fna > reads_1.fna).
dpryan is offline   Reply With Quote
Old 09-28-2012, 06:59 AM   #8
Fad2012
Member
 
Location: UK

Join Date: Sep 2012
Posts: 61
Default

Thanks very Much dpryan, it is working now. But yes i do have the separator and when i try to use it, the terminal says: unrecognized option `--no-group-separator'. I am not sure what the reason could be! My terminal is Version 2.3 (309).

Many thanks!
Fad2012 is offline   Reply With Quote
Old 09-28-2012, 07:50 AM   #9
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 7,079
Default

You can add a second grep to remove the "--"
Code:
grep -v "\--" reads_1.fna > reads_1_final.fna
or you could just add the second grep to the original command

Code:
grep -A 1 "\.1 " test.fna | grep -v "\--" > reads_1.fna

Last edited by GenoMax; 09-28-2012 at 07:57 AM.
GenoMax is offline   Reply With Quote
Old 09-28-2012, 09:01 AM   #10
Fad2012
Member
 
Location: UK

Join Date: Sep 2012
Posts: 61
Default

Thanks Very much, it is perfectly working!
Fad2012 is offline   Reply With Quote
Old 08-20-2013, 02:37 PM   #11
Smaugt
Junior Member
 
Location: Chile

Join Date: Mar 2013
Posts: 2
Default

Hi all,

i have the same problem reported here but if do "grep -v "\--" > reads_1.fna" I also remove lines starting with "--"...
Thanks in advance
Smaugt is offline   Reply With Quote
Old 08-20-2013, 02:48 PM   #12
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 7,079
Default

Quote:
Originally Posted by Smaugt View Post
Hi all,

i have the same problem reported here but if do "grep -v "\--" > reads_1.fna" I also remove lines starting with "--"...
Thanks in advance
Can you post a small example from your file? Why do you have lines that start with "--"?
GenoMax is offline   Reply With Quote
Old 08-20-2013, 02:54 PM   #13
Smaugt
Junior Member
 
Location: Chile

Join Date: Mar 2013
Posts: 2
Default

Thanks for ur soon response...

OK, I explain better.... I have something like this

@IC5OSZZ01DTNH9/1
GTTGTCGTGGCTCATGTTCGAGTTATCCATTTGTGCGAATGCGCCTGCTGATACCATG
+IC5OSZZ01DTNH9/1
--GIIIIIIIIIIII444IIIIEEIEIII444IIIIIIIIIIEGGHIIIII@888EII
--

if I remove the -- with "grep -v "\--" > reads_1.fna" it'll remove the qualities row too...
I hope you can help me..

Thanks!
Smaugt is offline   Reply With Quote
Old 08-20-2013, 03:06 PM   #14
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 7,079
Default

What OS are you using?

Did you try the "--no-group-separator" option mentioned by Devon in post #7 instead of the second grep?
GenoMax is offline   Reply With Quote
Old 08-21-2013, 05:31 AM   #15
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

Quote:
Originally Posted by Smaugt View Post
Thanks for ur soon response...

OK, I explain better.... I have something like this

@IC5OSZZ01DTNH9/1
GTTGTCGTGGCTCATGTTCGAGTTATCCATTTGTGCGAATGCGCCTGCTGATACCATG
+IC5OSZZ01DTNH9/1
--GIIIIIIIIIIII444IIIIEEIEIII444IIIIIIIIIIEGGHIIIII@888EII
--

if I remove the -- with "grep -v "\--" > reads_1.fna" it'll remove the qualities row too...
I hope you can help me..

Thanks!
Keep in mind that the grep commands that GenoMax and I had mentioned were for use with fasta files, where this situation wouldn't occur. As GenoMax suggested, try the "--no-group-separator" option. If that doesn't work, you can probably still use grep, you just need to change
Code:
grep -v "\--"
into something like
Code:
grep -v "^--$"
or something like that. The idea is to instead do the inverse match for whole lines that are exactly "--".
dpryan 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:28 AM.


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