Replace header line of fastq file with third line
1
0
Entering edit mode
2.1 years ago

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 • 953 views
ADD COMMENT
0
Entering edit mode
$ zcat test.fq.gz| sed '0~4 s/$/\n/'  | awk  -F "\n" -v OFS="\n" -v RS="\n\n" '{$1=$3; sub("+","@",$1)}1'
ADD REPLY
3
Entering edit mode
2.1 years ago
 gunzip -c in.fq.gz | paste - - - - | awk -F '\t'  '{OFS="\n";$3=sprintf("+%s",substr($1,2));print;}'
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode

Plus we also need to replace + with @ here

ah yes, fixed.

specially | paste - - - -

"Combining N consecutive lines" https://www.geeksforgeeks.org/paste-command-in-linux-with-examples/

ADD REPLY
0
Entering edit mode

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;}'

ADD REPLY

Login before adding your answer.

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