This is a test version of Biostars. For the public version, visit https://www.biostars.org.
correct fastq file with SED

Hi friends,

Got a small problem because of my fastq file which is wrong. So I wanted to correct lines manually.

For example I got these lines in my test.fasq file:

@HWI-ST1194:55:C11P5ACXX:4:2316:21380:54479/2
ATAATCTTCCCCAAGCATGGAACAAATACTCTCTTTAGTGGACTTGCATAACCTACAAAAAAACCTTCGTTAACTTT
+
@#1==DDAFFFD=EFFB1CGEEFECFFGIIIIIEGII?DFECEEFDEAFEEII;?A1([M::main_bam2fq] discarded 8840174

Wanted to replace the last line by a real quality :

@@BFFFFFHFFHBFHHIBEE>GIGHEHG+CG3CFFGGIIDBDGGGFDFGEDFHGCCGHEFHE;7@DEDFDACCECDC>

So my command line:

sed '4 s/@#1==DDAFFFD=EFFB1CGEEFECFFGIIIIIEGII?DFECEEFDEAFEEII;?A1([M::main_bam2fq] discarded 8840174/*@@BFFFFFHFFHBFHHIBEE>GIGHEHG+CG3CFFGGIIDBDGGGFDFGEDFHGCCGHEFHE;7@DEDFDACCECDC>*/g' test1

What's wrong ? Or can I proceed with perl maybe?

Thanks

fastq bash sequence

please, format your post. It's hard to see what's wrong.

Hi Pierre,

I've put it here:

2 answers

Try escaping [ ] ([M::main_bam2fq]).

sed 's/@#1==DDAFFFD=EFFB1CGEEFECFFGIIIIIEGII?DFECEEFDEAFEEII;?A1(\[M::main_bam2fq\] discarded 8840174/real quality/'​

Great :) it works !

Thanks again Pgibas.

Siva

If you just want to replace the last line I wouldn't use find & replace but be more explicit and actually print the all file without last line and append as last line what you want. Something like:

nlines=`wc -l in.fq | awk '{print $1-1}'`
head -n $nlines in.fq > out.fq
echo 'myNewLineWithQualities' >> out.fq

nope it's not the last line, here for the example yea but in my real data not.

Log in to answer this question.