Closed:simulating samtools -f option in pysam
0
0
Entering edit mode
8.7 years ago
sa9 ▴ 860

I am trying to count BAM reads with flag 83 using pysam version 0.8.3. I tried to use bitwise operation AND:

counter = 0
for read in bam:
   if read.flag & 83 == 83:
      counter += 1

which shows 561 reads while using samtools:

samtools view -f 83 example.bam | wc -l

shows 565 reads. There are 4 extra reads with flag 371 listed by samtools option -f that are not captured by my pysam code.

Is this the right way to simulate option -f in samtools?

Here is the example.bam file used for this question (260 kb)

https://www.dropbox.com/s/c35kmfktgx7c5va/example.bam

Thanks

sequencing • 312 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3212 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6