Question: Ignore SAM header section using awk
0
gravatar for max_19
23 months ago by
max_19150
max_19150 wrote:

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

sequencing sam bam • 478 views
ADD COMMENTlink modified 23 months ago by _r_am30k • written 23 months ago by max_19150
2
gravatar for _r_am
23 months ago by
_r_am30k
Baylor College of Medicine, Houston, TX
_r_am30k wrote:

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 COMMENTlink modified 23 months ago • written 23 months ago by _r_am30k

That fixed it! thanks very much!

ADD REPLYlink written 23 months ago by max_19150
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1026 users visited in the last hour