Invalid Contig error when using bamfile.fetch
0
0
Entering edit mode
19 months ago
bxxxmxxxx ▴ 10

Hey all,

I am new to using Pysam module in vs code. I am having issues getting my code to work. So I have two files: first is a CSV that I imported as pandas df and it has two columns: chromosome and coordinate. The second file is a sorted, indexed BAM file that contains reads that I imported as Pysam.AlignmentFile [I had to set sq to false in order for the code to work].

Since I want to check reads that contain the coordinates from file1, I wanted to fetch relevant reads, but this is where I run into the:

File "pysam/libcalignmentfile.pyx", line 1087, in pysam.libcalignmentfile.AlignmentFile.fetch File "pysam/libchtslib.pyx", line 686, in pysam.libchtslib.HTSFile.parse_region ValueError: invalid contig chr1 error. Can anyone help me please?

For additional info, all I do is

for i in range(DF - 1):
    x = DF.iloc[i]['CHROM']
    y = DF.iloc[i]['POS']
    for read in Bamfile.fetch(x, y - 2000, y):

I appreciate any help!

sam Pysam bam python • 933 views
ADD COMMENT

Login before adding your answer.

Traffic: 1679 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