mgymrek / pybamview

Browser based application for viewing bam alignments
MIT License
56 stars 17 forks source link

ParseCigar for c in cigar: TypeError: 'NoneType' object is not iterable #7

Closed trickytank closed 10 years ago

trickytank commented 10 years ago

With three WES BAMs loaded that were aligned with Novoalign, Picard duplicate marking, GATK IndelRealigner, going to location chr6:16327764 causes me this error:

10.1.17.246 - - [07/Feb/2014 13:50:38] "GET /?bamfiles=A1-11_novoalign-realign.bam&bamfiles=A1-2_novoalign-realign.bam&bamfiles=A1-45_novoalign-realign.bam&region=chr6%3A16325764 HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?bamfiles=A1-11_novoalign-realign.bam&bamfiles=A1-2_novoalign-realign.bam&bamfiles=A1-45_novoalign-realign.bam&region=chr6%3A16327764 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/pybamview/mgymrek-pybamview-60d2cb6/build/scripts-2.7/pybamview", line 78, in listbams
    return display_bam(bamfiles)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/pybamview/mgymrek-pybamview-60d2cb6/build/scripts-2.7/pybamview", line 92, in display_bam
    return display_bam_region(bamfiles, region)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/pybamview/mgymrek-pybamview-60d2cb6/build/scripts-2.7/pybamview", line 111, in display_bam_region
    bv.LoadAlignmentGrid(chrom, pos, _settings=SETTINGS)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/pybamview-0.0.1-py2.7.egg/pybamview/bam_alignment.py", line 290, in LoadAlignmentGrid
    self.alignment_grid = AlignmentGrid(self.bamreaders, self.read_groups, self.reference, _chrom, _pos, _settings=_settings)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/pybamview-0.0.1-py2.7.egg/pybamview/bam_alignment.py", line 91, in __init__
    self.LoadGrid()
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/pybamview-0.0.1-py2.7.egg/pybamview/bam_alignment.py", line 133, in LoadGrid
    rep = ParseCigar(cigar, nucs)
  File "/stornext/General/tmpdata/system/bioinf-software/bioinfsoftware/python/python2.7/lib/python2.7/site-packages/pybamview-0.0.1-py2.7.egg/pybamview/bam_alignment.py", line 43, in ParseCigar
    for c in cigar:
TypeError: 'NoneType' object is not iterable
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=source.png HTTP/1.1" 200 -
10.1.17.246 - - [07/Feb/2014 13:51:07] "GET /?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
mgymrek commented 10 years ago

It looks like this is because the read doesn't have a CIGAR score set for some reason. I have added a check for this now to not display reads with no CIGAR with this commit. Can you pull this change and see if it fixes your problem?

trickytank commented 10 years ago

Hi Melissa, I've finally had a chance to try this out and it's now working all ok. Thanks for the fix.