Awk tips and tricks and Bioinformatics applications
Awk programs
Awk programs are a sequence of combinations of “search pattern” and “action”. Check this example, it sums up all cell counts in this table:
Parameters
Field separators (-F
)
The parameter -F
is provided a regexp. To define both ‘=’ and ‘;’ as field separators, do this:
Examples
Filter a tsv file by column2==”foo”
How many reads are mapped [awk, wc]
The third bit (“unaligned read”) has to be unset/zero/not 1:
Get only aligned and only primary lines
The flags 256 (secondary alignment) and 4 (unmapped read) have to be off: