Menu

#12 SequenceWithQualities does not handle qualstr=None

v1.0_(example)
open
nobody
None
7
2014-04-07
2013-06-12
No

Reading a BAM with a "*" in the quality causes SequenceWithQualities to throw an exception: object of type 'NoneType' has no len() in init() on the line:

:::python
if len( seq ) != len( qualstr ):

According to pysam:

http://www.cgat.org/~andreas/documentation/pysam/api.html#pysam.AlignedRead

The "qual" field can be None if not present (ie a "*" in the SAM)

Thus the fix should be (I think) from:

:::python
if read.qual != "*":
         seq = SequenceWithQualities( read.seq, read.qname, read.qual )

to:

:::python
if read.qual is not None and read.qual != "*":
         seq = SequenceWithQualities( read.seq, read.qname, read.qual )

Discussion


Log in to post a comment.

MongoDB Logo MongoDB