Dear All,
I am trying to us pysam for one of my scripts.
Here is a snippet of the code.
tabixfile = pysam.Tabixfile(vcf_dir_file)
for i in snp_pos:
        (chrom, snp) = i.split(" ")[0], i.split(" ")[1]
        val = int(snp)-1
        chrom = "'" + chrom + "'"
        for vcf in tabixfile.fetch(str(chrom), val, int(snp)):
                print vcf
Here snp_pos is an array of likewise of chr1 snp_position
When I am running this scripts then geting error here with tabixfile.fetch(str(chrom), val, int(snp)): part.
Error is : File "lowFrequency_impro.py", line 55, in <module>
    for vcf in tabixfile.fetch(str(chrom), val, int(snp)):
  File "ctabix.pyx", line 353, in pysam.ctabix.Tabixfile.fetch (pysam/ctabix.c:4318)
ValueError: could not create iterator for region ''chr1':774047-774047'`
But if I try to run same snippets at python terminal the I can able to run and get correct results with position 774047 as below then
>>> for gtf in tabixfile.fetch('chr1', 752565, 752566):
...     print gtf
I am wondering that what could be the error here and possible solution !! Please help me on this !! Its bit urgent too..
what are those quotes in ''chr1':774047-774047' ? are you sure about chr1 (and not only '1' )