comparison blast2html.py @ 122:5f104d05aa23

fix python 2.6 issue with array type codes
author Jan Kanis <jan.code@jankanis.nl>
date Thu, 31 Jul 2014 17:24:10 +0200
parents 2729c2326235
children 720efb818f1b
comparison
equal deleted inserted replaced
120:2729c2326235 122:5f104d05aa23
326 query_length = blastxml_len(result) 326 query_length = blastxml_len(result)
327 327
328 for hit in hits(result): 328 for hit in hits(result):
329 hsps = hit.Hit_hsps.Hsp 329 hsps = hit.Hit_hsps.Hsp
330 330
331 cover = array('B', [0]) * query_length 331 # In python 2.6 array doesn't accept unicode type codes, but in 3.4 it requires them
332 cover = array(str('B'), [0]) * query_length
332 for hsp in hsps: 333 for hsp in hsps:
333 cover[hsp['Hsp_query-from']-1 : int(hsp['Hsp_query-to'])] = array('B', [1]) * blastxml_len(hsp) 334 cover[hsp['Hsp_query-from']-1 : int(hsp['Hsp_query-to'])] = array(str('B'), [1]) * blastxml_len(hsp)
334 cover_count = cover.count(1) 335 cover_count = cover.count(1)
335 336
336 best_hsp = max(hsps, key=lambda h: h['Hsp_bit-score']) 337 best_hsp = max(hsps, key=lambda h: h['Hsp_bit-score'])
337 338
338 yield dict(hit = hit, 339 yield dict(hit = hit,