Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Hack for Bio.SearchIO blast-xml encoding

BLAST XML files do not specify its encoding, which may be problematic in some
Python versions. This commit forces a 'utf-8' encoding for all BLAST XML files
opened through Bio.SearchIO.
  • Loading branch information...
commit 06cb6da1e0bb5b727f59d51b0ee4c896784cfaa5 1 parent 820677c
@bow bow authored peterjc committed
Showing with 8 additions and 1 deletion.
  1. +8 −1 Bio/SearchIO/
9 Bio/SearchIO/
@@ -299,8 +299,15 @@ def parse(handle, format=None, **kwargs):
# get the iterator object and do error checking
iterator = get_processor(format, _ITERATOR_MAP)
+ # HACK: force BLAST xml files to be opened using utf-8 encoding
+ # BLAST XML files do not specify this, which may lead to problems
+ # in some python versions
+ handle_kwargs = {}
+ if format == 'blast-xml':
+ handle_kwargs['encoding'] = 'utf-8'
# and start iterating
- with as_handle(handle, 'rU') as source_file:
+ with as_handle(handle, 'rU', **handle_kwargs) as source_file:
generator = iterator(source_file, **kwargs)
for qresult in generator:

0 comments on commit 06cb6da

Please sign in to comment.
Something went wrong with that request. Please try again.