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...)
Samtools view -f "OR" operator possible?
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)
• 2,059 views
•
link
3 answers
using samjdk http://lindenb.github.io/jvarkit/SamJdk.html
java -jar dist/samjdk.jar -e 'return record.getSupplementaryAlignmentFlag() || record.getReadUnmappedFlag();' in.bam
• 0 views
•
link
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.
• 0 views
•
link
• 0 views
•
link
Log in to answer this question.