Pysam ValueError

89 views
Skip to first unread message

Ranjita Thapa

unread,
Oct 16, 2019, 12:43:07 PM10/16/19
to Pysam User group
Does anyone know about this error? I used pysam to read bamfile, samfile = pysam.AlignmentFile(os.path.join(path,bam),'rb') and wanted to count inside samfile, sum1 = samfile.count(chr,start,stop). I have defined chr, start and stop in my script.

sum1 = samfile.count(chr,start,stop)
  File "pysam/libcalignmentfile.pyx", line 1431, in pysam.libcalignmentfile.AlignmentFile.count
  File "pysam/libcalignmentfile.pyx", line 1112, in pysam.libcalignmentfile.AlignmentFile.fetch
ValueError: fetching by region is not available for SAM files

F F

unread,
Oct 17, 2019, 2:56:59 AM10/17/19
to Pysam User group
You need to convert your SAM file (which is a plain text format) into a (sorted) BAM file and an index.
Reply all
Reply to author
Forward
0 new messages