biopython/biopython — pull request #184 by luizirber (2013-06-04 01:19:04+00:00)
Title: Fix for ScanProsite.read, works with Python 2 and 3

ScanProsite.read fails on Python 3, this fix is backwards compatible
with Python 2.

============================================================

Which operating system and hardware (32 bit or 64 bit) you are using:
Linux 3.9.4-1-ARCH #1 SMP PREEMPT Sat May 25 16:14:55 CEST 2013 x86_64 GNU/Linux

Python version:
Python 3.3.2 / Python 2.7.5

Biopython version
1.61

Traceback that occurs (the full error message):
Traceback (most recent call last):
File "prst.py", line 14, in
result = ScanProsite.read(handle)
File "/usr/lib/python3.3/site-packages/Bio/ExPASy/ScanProsite.py", line 54, in read
saxparser.parse(handle)
File "/usr/lib/python3.3/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python3.3/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python3.3/site-packages/Bio/ExPASy/ScanProsite.py", line 75, in feed
raise ValueError(data)
ValueError: b'\n\n \n USERSEQ1 428 436 PS00197 (-1)\n \n \n USERSEQ1 452 463 PS00022 (-1)\n \n \n USERSEQ1 463 471 PS00197 (-1)\n \n\n\n'

Example code that breaks:
https://github.com/luizirber/rosalind/blob/master/prst.py

A data file that causes the problem:
The sample dataset from http://rosalind.info/problems/prst/ can be used, but any valid search with ScanProsite will trigger the error.