How to change every third line in a fastq library
2
0
Entering edit mode
22 months ago
ricksama • 0

Hello, I need to modify the third line of the fastq to keep only the + symbol. The library I downloaded from SRA has the + with the header and this is causing some troubles when using this library.

This is the way the library is, every sequence has the same format

Can someone help me with this change?

Thanks in advance

fastq • 1.4k views
ADD COMMENT
1
Entering edit mode

It's surprising there is a problem, because the FASTQ specs say it is absolutely legal to look like that, so long as the content after the + is identical to the content after the @.

ADD REPLY
0
Entering edit mode

Could it be problematic line endings? Invisible characters?

ADD REPLY
0
Entering edit mode

Thank you all for the responses and contributions, the Perl code size_t wrote worked just fine :)

ADD REPLY
1
Entering edit mode
22 months ago
Ram 44k

sed can do this:

sed '3~4s/.+/+/' in.fastq > out.fastq #untested, test on the first ~40 lines before running on entire file
ADD COMMENT
1
Entering edit mode
22 months ago
size_t ▴ 120

perl:

perl -e 'open A,shift; my $idx=0; while(<A>){$idx++; $idx==3 ? print "+\n" : print "$_"; $idx==4 ? $idx=0 : $idx;} close A;'  test.fq
ADD COMMENT
0
Entering edit mode

If your trouble still exists, as @Ram said, maybe Invisible characters, check your file with command cat -A xx.fq

ADD REPLY
0
Entering edit mode

I just tested and it worked! Thanks for your reply

ADD REPLY

Login before adding your answer.

Traffic: 2362 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