Question: Samtools view -f "OR" operator possible?
1
gravatar for QVINTVS_FABIVS_MAXIMVS
4 months ago by
USA SoCal
QVINTVS_FABIVS_MAXIMVS2.3k 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 • 219 views
ADD COMMENTlink modified 4 months ago by dariober10k • written 4 months ago by QVINTVS_FABIVS_MAXIMVS2.3k
2
gravatar for Pierre Lindenbaum
4 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum124k 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 4 months ago by Pierre Lindenbaum124k
2
gravatar for h.mon
4 months ago by
h.mon28k
Brazil
h.mon28k 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 4 months ago • written 4 months ago by h.mon28k
2
gravatar for dariober
4 months ago by
dariober10k
WCIP | Glasgow | UK
dariober10k 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 4 months ago by dariober10k
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 4 months ago by dariober10k
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: 1843 users visited in the last hour