This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Replace header line of fastq file with third line

Hi,

I want to change my fastq file

@1/1

GTCGCTGACGAGCGAGTACT

+SRR00000.1 1 length=150

FFFFFFFFFFFFFFFFFFFFFFFF

into something like

@SRR00000.1 1 length=150

GTCGCTGACGAGCGAGTACT

+SRR00000.1 1 length=150

FFFFFFFFFFFFFFFFFFFFFFFF

Replacing header line with third line. Iam trying something like this awk 'NR%4==1 {$0=$3} {print}' but ofcourse $3 would be empty in the start so it gives empty header line.

Any help with awk command or anything else would be really appreciated?

Thanks

bash fastq
$ zcat test.fq.gz| sed '0~4 s/$/\n/'  | awk  -F "\n" -v OFS="\n" -v RS="\n\n" '{$1=$3; sub("+","@",$1)}1'

1 answer

 gunzip -c in.fq.gz | paste - - - - | awk -F '\t'  '{OFS="\n";$3=sprintf("+%s",substr($1,2));print;}'

Thankyou, can you please explain this? specially | paste - - - - | part? Plus we also need to replace + with @ here

Thank you so much. With little update in line numbers, it's perfect.

gunzip -c in.fq.gz | paste - - - - | awk -F '\t' '{OFS="\n";$1=sprintf("@%s",substr($3,2));print;}'

Log in to answer this question.