Mercurial > repos > jankanis > blast2html
comparison blast2html.py @ 68:fa8a93bdefd7
fix bug in calculations of alignment end
author | Jan Kanis <jan.code@jankanis.nl> |
---|---|
date | Wed, 18 Jun 2014 12:25:37 +0200 |
parents | 19c48f2ec775 |
children | 0c4ac210068b |
comparison
equal
deleted
inserted
replaced
67:19c48f2ec775 | 68:fa8a93bdefd7 |
---|---|
81 return hitid | 81 return hitid |
82 | 82 |
83 | 83 |
84 @filter | 84 @filter |
85 def alignment_pre(hsp): | 85 def alignment_pre(hsp): |
86 """Create the preformatted alignment blocks""" | |
87 | |
86 step = 60 | 88 step = 60 |
87 | 89 |
88 def split(txt): | 90 def split(txt): |
89 return [txt[i:i+step] for i in range(0, len(txt), step)] | 91 return [txt[i:i+step] for i in range(0, len(txt), step)] |
90 | 92 |
97 hseq = hsp.Hsp_hseq.text | 99 hseq = hsp.Hsp_hseq.text |
98 | 100 |
99 offset = 0 | 101 offset = 0 |
100 for qs, mid, hs, offset in zip(split(qseq), split(midline), split(hseq), range(0, len(qseq), step)): | 102 for qs, mid, hs, offset in zip(split(qseq), split(midline), split(hseq), range(0, len(qseq), step)): |
101 yield ( | 103 yield ( |
102 "Query {:>7} {} {}\n".format(qfrom+offset, qs, qfrom+len(qs)-1) + | 104 "Query {:>7} {} {}\n".format(qfrom+offset, qs, qfrom+offset+len(qs)-1) + |
103 " {:7} {}\n".format('', mid) + | 105 " {:7} {}\n".format('', mid) + |
104 "Subject{:>7} {} {}".format(hfrom+offset, hs, hfrom+len(hs)-1) | 106 "Subject{:>7} {} {}".format(hfrom+offset, hs, hfrom+offset+len(hs)-1) |
105 ) | 107 ) |
106 | 108 |
107 if qfrom+len(qseq)-1 != qto: | 109 if qfrom+len(qseq)-1 != qto: |
108 warnings.warn("Error in BlastXML input: Hsp node {} qseq length mismatch: from {} to {} length {}".format( | 110 warnings.warn("Error in BlastXML input: Hsp node {} qseq length mismatch: from {} to {} length {}".format( |
109 nodeid(hsp), qfrom, qto, len(qseq))) | 111 nodeid(hsp), qfrom, qto, len(qseq))) |