Ignore SAM header section using awk
1
0
Entering edit mode
6.0 years ago
max_19 ▴ 170

Hi all,

I'm using awk to filter my sam file (aligned_reads.sam) using a text file (values.txt). I need to tell it to ignore the first few lines (header section) of the sam file. Any ideas how I can specify that within this code?

awk 'FNR==NR { a[$1]; next } !($3 in a)' values.txt aligned_reads.sam > filtered_aligned_reads.sam

Thx

sam sequencing bam • 1.3k views
ADD COMMENT
2
Entering edit mode
6.0 years ago
Ram 44k

Use process substitution instead of supplying the SAM file directly.

awk 'do_awk_stuff' values.txt <(samtools view aligned_reads.sam) >filtered_aligned_reads.sam

In fact, see if samtools can directly filter your sam instead of having awk do it.

ADD COMMENT
0
Entering edit mode

That fixed it! thanks very much!

ADD REPLY

Login before adding your answer.

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