sam header is not recognized by awk?
2
0
Entering edit mode
9.4 years ago
mosquitoes • 0

Why doesn't awk recognize the sam header? I match on ^@ and it will print to stdout but not to a file. It prints to stdout but never finishes.

awk '/^@/ {print}' filename

I can't make any sense of this.

Thanks!

sequencing samtools next-gen awk • 2.3k views
ADD COMMENT
2
Entering edit mode
awk '/^@/{print}!/^@/{exit}'
ADD REPLY
1
Entering edit mode

what's in filename? a BAM?

ADD REPLY
3
Entering edit mode
9.4 years ago

It prints to stdout but never finishes.

It's got perhaps several dozen headers to read through and print out, followed by perhaps several hundred million alignment records to read though. I'm sure it will finish if you wait long enough!

Perhaps you should consider samtools view -H or similar.

ADD COMMENT
0
Entering edit mode
9.4 years ago
Zhilong Jia ★ 2.2k

For file 1.t:

@HD VN:1.5 SO:coordinate
@SQ SN:ref LN:45
r001 99 ref 7 30 8M2I4M1D3M = 37 39 TTAGATAAAGGATACTG *

awk '/^@/ {print}' 1.t > 2.t

And 2.t will get the output. It works in mawk and gawk.

ADD COMMENT

Login before adding your answer.

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