Question: Samtools view -f "OR" operator possible?
1
gravatar for QVINTVS_FABIVS_MAXIMVS
15 months ago by
USA SoCal
QVINTVS_FABIVS_MAXIMVS2.4k wrote:

Quick question:

Is it possible to do a samtools view -f XXX using a OR operator?

Say if I wanted to get all reads that were unmapped (4) or supplementary alignments (2048).

Is this possible? Because doing a 2052 is an "AND" (reads are unmapped and supplementary alignments which is impossible)

samtools • 429 views
ADD COMMENTlink modified 15 months ago by dariober11k • written 15 months ago by QVINTVS_FABIVS_MAXIMVS2.4k
2
gravatar for Pierre Lindenbaum
15 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum130k wrote:

using samjdk http://lindenb.github.io/jvarkit/SamJdk.html

 java -jar dist/samjdk.jar -e 'return record.getSupplementaryAlignmentFlag() || record.getReadUnmappedFlag();' in.bam
ADD COMMENTlink written 15 months ago by Pierre Lindenbaum130k
2
gravatar for h.mon
15 months ago by
h.mon31k
Brazil
h.mon31k wrote:

BamTools can do what you want, read the filter section of the tutorial. When you set multiple properties in one filter, these properties are AND-ed, and when you set multiple properties in different filters, these properties are OR-ed.

ADD COMMENTlink modified 15 months ago • written 15 months ago by h.mon31k
2
gravatar for dariober
15 months ago by
dariober11k
WCIP | Glasgow | UK
dariober11k wrote:

The closest I can think of is, using samtools (not tested):

samtools merge - \
    <(samtools view -u -f 4 in.bam) \
    <(samtools view -u -f 2048 in.bam)

This will output BAM to stdout, replace - with an actual output filename.

ADD COMMENTlink written 15 months ago by dariober11k
1

Maybe worth noting that this will output duplicate alignments if a record matches more than one OR conditions (e.g. for 2052 which is not really possible in this case but you never know...)

ADD REPLYlink written 15 months ago by dariober11k
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: 1061 users visited in the last hour