Question: Ignore SAM header section using awk
0
gravatar for max_19
11 months ago by
max_19120
max_19120 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 • 324 views
ADD COMMENTlink modified 11 months ago by RamRS25k • written 11 months ago by max_19120
2
gravatar for RamRS
11 months ago by
RamRS25k
Houston, TX
RamRS25k 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 11 months ago • written 11 months ago by RamRS25k

That fixed it! thanks very much!

ADD REPLYlink written 11 months ago by max_19120
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: 1150 users visited in the last hour