This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to change every third line in a fastq library

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

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 @.

Could it be problematic line endings? Invisible characters?

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

2 answers

sed can do this:

sed '3~4s/.+/+/' in.fastq > out.fastq #untested, test on the first ~40 lines before running on entire file

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

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

I just tested and it worked! Thanks for your reply

Log in to answer this question.