| 1 |
# cython: language_level=3 |
| 2 |
|
| 3 |
from pysam.libcalignmentfile cimport AlignmentFile, AlignedSegment |
| 4 |
from pysam.libctabix cimport Tabixfile |
| 5 |
|
| 6 |
cdef AlignmentFile samfile |
| 7 |
cdef Tabixfile tabixfile |
| 8 |
|
| 9 |
|
| 10 |
def testCountBAM(AlignmentFile samfile): |
| 11 |
'''test reading from a BAM file accessing |
| 12 |
the flag field directly.''' |
| 13 |
|
| 14 |
cdef AlignedSegment read |
| 15 |
cdef int n = 0 |
| 16 |
|
| 17 |
for read in samfile.fetch(): |
| 18 |
flag = read._delegate.core.flag |
| 19 |
n += 1 |
| 20 |
|
| 21 |
return n |
| 22 |
|
| 23 |
def testCountGTF(Tabixfile tabixfile): |
| 24 |
'''test reading from a tabixfile.''' |
| 25 |
|
| 26 |
cdef int n = 0 |
| 27 |
|
| 28 |
for entry in tabixfile.fetch(): |
| 29 |
n += 1 |
| 30 |
|
| 31 |
return n |