File: _cython_flagstat.pyx

package info (click to toggle)
python-pysam 0.15.4+ds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 27,992 kB
  • sloc: ansic: 140,738; python: 7,881; sh: 265; makefile: 223; perl: 41
file content (18 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pysam.libcalignmentfile cimport AlignmentFile, AlignedSegment
from pysam.libcalignmentfile cimport BAM_FPROPER_PAIR, BAM_FPAIRED
from pysam.libcalignedsegment cimport pysam_get_flag

def count(AlignmentFile samfile):
    cdef int is_proper = 0
    cdef int is_paired = 0
    cdef AlignedSegment read
    cdef int f

    for read in samfile:
        f = pysam_get_flag(read._delegate)
        if f & BAM_FPAIRED:
            is_paired += 1
        if f & BAM_FPROPER_PAIR:
            is_proper += 1

    return is_paired, is_proper