File: _cython_flagstat.pyx

package info (click to toggle)
python-pysam 0.15.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 17,604 kB
  • sloc: ansic: 125,787; python: 7,782; sh: 284; makefile: 222; 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