This tool uses the sambamba view command to filter BAM/SAM on flags, fields, tags, and region. Input is SAM or BAM file.
A filter expression is a number of basic conditions linked by and, or, not logical operators, and enclosed in parentheses where needed.
Basic condition is a one for a single record field, tag, or flag.
You can use ==, !=, >, <, >=, <= comparison operators for both integers and strings.
Strings are delimited by single quotes, if you need a single quote inside a string, escape it with \\.
mapping_quality >= 30 and ([RG] =~ /^abcd/ or [NM] == 7) read_name == 'abc\'def'
not (unmapped or mate_is_unmapped) and first_of_pair
Conditions for integer and string fields are supported.
ref_id == 3 and mapping_quality >= 50 and sequence_length >= 80
Tags are denoted by their names in square brackets, for instance, [RG] or [Q2]. They support conditions for both integers and strings, i.e. the tag must also hold value of the corresponding type.
In order to do filtering based on the presence of a particular tag, you can use special null value.
[RG] != null and [AM] == 37