ryanlayer / samplot

Plot structural variant signals from many BAMs and CRAMs
MIT License
516 stars 66 forks source link

can not parse correct name of chrID #106

Open XuewenWangUGA opened 4 years ago

XuewenWangUGA commented 4 years ago

Can not parse any name of chrID This tool can not parse any other format of chrID except chr#. For example, if my chr ID or reference seq id is "Mygenom.chr01", then failure will occur.

I suggested to allow any format of customized ID for each reference sequence once it is used in the bam file.

error information: samplot plot will parse the other format of chromosome name e.g. "my.gnm1.chr01" as "chrchrmy.gnm1.03", which will cause failure in plot.

detailed error: Traceback (most recent call last): File "/home/xuewen/anaconda3/lib/python3.7/site-packages/samplot/samplot.py", line 2650, in get_read_data bam_iter = bam_file.fetch(r.chrm, max(0, r.start - 1000), r.end + 1000) File "pysam/libcalignmentfile.pyx", line 1081, in pysam.libcalignmentfile.AlignmentFile.fetch File "pysam/libchtslib.pyx", line 686, in pysam.libchtslib.HTSFile.parse_region ValueError: invalid contig my.gnm1.03

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/xuewen/anaconda3/bin/samplot", line 10, in sys.exit(main()) File "/home/xuewen/anaconda3/lib/python3.7/site-packages/samplot/main.py", line 31, in main args.func(parser) File "/home/xuewen/anaconda3/lib/python3.7/site-packages/samplot/samplot.py", line 3524, in plot options.ignore_hp, File "/home/xuewen/anaconda3/lib/python3.7/site-packages/samplot/samplot.py", line 2657, in get_read_data bam_iter = bam_file.fetch(chrm, max(0, r.start - 1000), r.end + 1000) File "pysam/libcalignmentfile.pyx", line 1081, in pysam.libcalignmentfile.AlignmentFile.fetch File "pysam/libchtslib.pyx", line 686, in pysam.libchtslib.HTSFile.parse_region ValueError: invalid contig chrmy.gnm1.03

KamilSJaron commented 4 years ago

Hello, I had the same error message before I found that my bamfile was not sorted and indexed. Once I did that (samtools sort / index), everythings worked.

I suppose the error message could be more intuitive, but I don't think there is a real bug in the software.

K

P.S. full disclaimer, I am not a developer. I just happen to have had the exact same problem.