Mercurial > repos > jankanis > blast2html
changeset 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 |
files | blast2html.py test-data/blast xml example1.html test-data/blast xml example3.html test-data/blast xml example4.html |
diffstat | 4 files changed, 62 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/blast2html.py Tue Jun 17 18:07:02 2014 +0200 +++ b/blast2html.py Wed Jun 18 12:25:37 2014 +0200 @@ -83,6 +83,8 @@ @filter def alignment_pre(hsp): + """Create the preformatted alignment blocks""" + step = 60 def split(txt): @@ -99,9 +101,9 @@ offset = 0 for qs, mid, hs, offset in zip(split(qseq), split(midline), split(hseq), range(0, len(qseq), step)): yield ( - "Query {:>7} {} {}\n".format(qfrom+offset, qs, qfrom+len(qs)-1) + + "Query {:>7} {} {}\n".format(qfrom+offset, qs, qfrom+offset+len(qs)-1) + " {:7} {}\n".format('', mid) + - "Subject{:>7} {} {}".format(hfrom+offset, hs, hfrom+len(hs)-1) + "Subject{:>7} {} {}".format(hfrom+offset, hs, hfrom+offset+len(hs)-1) ) if qfrom+len(qseq)-1 != qto:
--- a/test-data/blast xml example1.html Tue Jun 17 18:07:02 2014 +0200 +++ b/test-data/blast xml example1.html Wed Jun 18 12:25:37 2014 +0200 @@ -6667,7 +6667,7 @@ <pre class=alignmentgraphic>Query 2 GTCCGTCG 9 |||||||| -Subject 177 GTCCGTCG 170</pre> +Subject 177 GTCCGTCG 184</pre> </div> <div class=hotspot id=hotspot1-26-3> <p class=range> @@ -6715,7 +6715,7 @@ <pre class=alignmentgraphic>Query 2 GTCCGTC 8 ||||||| -Subject 2048 GTCCGTC 2042</pre> +Subject 2048 GTCCGTC 2054</pre> </div> <div class=hotspot id=hotspot1-26-5> <p class=range> @@ -6853,7 +6853,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1634 CGTGAAGA 1627</pre> +Subject 1634 CGTGAAGA 1641</pre> </div> <div class=hotspot id=hotspot1-28-3> <p class=range> @@ -6994,7 +6994,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1634 CGTGAAGA 1627</pre> +Subject 1634 CGTGAAGA 1641</pre> </div> <div class=hotspot id=hotspot1-29-3> <p class=range> @@ -7111,7 +7111,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 298 TCGTGAAGA 290</pre> +Subject 298 TCGTGAAGA 306</pre> </div> <div class=hotspot id=hotspot1-31-2> <p class=range> @@ -7672,7 +7672,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-37-2> <p class=range> @@ -7813,7 +7813,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1569 TGAAGAG 1563</pre> +Subject 1569 TGAAGAG 1575</pre> </div> </div> @@ -7924,7 +7924,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1569 TGAAGAG 1563</pre> +Subject 1569 TGAAGAG 1575</pre> </div> </div> @@ -8392,7 +8392,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1634 CGTGAAGA 1627</pre> +Subject 1634 CGTGAAGA 1641</pre> </div> <div class=hotspot id=hotspot1-45-3> <p class=range> @@ -8551,7 +8551,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1634 CGTGAAGA 1627</pre> +Subject 1634 CGTGAAGA 1641</pre> </div> <div class=hotspot id=hotspot1-46-3> <p class=range> @@ -8716,7 +8716,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1569 TGAAGAG 1563</pre> +Subject 1569 TGAAGAG 1575</pre> </div> </div> @@ -8809,7 +8809,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1569 TGAAGAG 1563</pre> +Subject 1569 TGAAGAG 1575</pre> </div> </div> @@ -8878,7 +8878,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1634 CGTGAAGA 1627</pre> +Subject 1634 CGTGAAGA 1641</pre> </div> <div class=hotspot id=hotspot1-49-3> <p class=range> @@ -9043,7 +9043,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1569 TGAAGAG 1563</pre> +Subject 1569 TGAAGAG 1575</pre> </div> </div> @@ -9088,7 +9088,7 @@ <pre class=alignmentgraphic>Query 4 CCGTCGTGA 12 ||||||||| -Subject 19 CCGTCGTGA 11</pre> +Subject 19 CCGTCGTGA 27</pre> </div> </div> @@ -9178,7 +9178,7 @@ <pre class=alignmentgraphic>Query 4 CCGTCGTGA 12 ||||||||| -Subject 19 CCGTCGTGA 11</pre> +Subject 19 CCGTCGTGA 27</pre> </div> </div> @@ -9268,7 +9268,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-55-2> <p class=range> @@ -9385,7 +9385,7 @@ <pre class=alignmentgraphic>Query 8 CGTGAAGA 15 |||||||| -Subject 1587 CGTGAAGA 1580</pre> +Subject 1587 CGTGAAGA 1594</pre> </div> <div class=hotspot id=hotspot1-56-3> <p class=range> @@ -9550,7 +9550,7 @@ <pre class=alignmentgraphic>Query 10 TGAAGAG 16 ||||||| -Subject 1533 TGAAGAG 1527</pre> +Subject 1533 TGAAGAG 1539</pre> </div> </div> @@ -9814,7 +9814,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-61-2> <p class=range> @@ -9907,7 +9907,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-62-2> <p class=range> @@ -10000,7 +10000,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-63-2> <p class=range> @@ -10093,7 +10093,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-64-2> <p class=range> @@ -10186,7 +10186,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-65-2> <p class=range> @@ -10279,7 +10279,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-66-2> <p class=range> @@ -10348,7 +10348,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-67-2> <p class=range> @@ -10441,7 +10441,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-68-2> <p class=range> @@ -10534,7 +10534,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-69-2> <p class=range> @@ -10627,7 +10627,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-70-2> <p class=range> @@ -10768,7 +10768,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-71-2> <p class=range> @@ -11263,7 +11263,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-76-2> <p class=range> @@ -11380,7 +11380,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-77-2> <p class=range> @@ -11473,7 +11473,7 @@ <pre class=alignmentgraphic>Query 7 TCGTGAAGA 15 ||||||||| -Subject 305 TCGTGAAGA 297</pre> +Subject 305 TCGTGAAGA 313</pre> </div> <div class=hotspot id=hotspot1-78-2> <p class=range> @@ -12961,7 +12961,7 @@ <pre class=alignmentgraphic>Query 5 CGTCGTGA 12 |||||||| -Subject 52 CGTCGTGA 45</pre> +Subject 52 CGTCGTGA 59</pre> </div> </div>
--- a/test-data/blast xml example3.html Tue Jun 17 18:07:02 2014 +0200 +++ b/test-data/blast xml example3.html Wed Jun 18 12:25:37 2014 +0200 @@ -3321,9 +3321,12 @@ </tr> </table> - <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTGTTCGCAGTCCAGAA 74 - ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | ||||| |||||||| -Subject 1516 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTCTTCGCCGTCCAGAA 1589</pre> + <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTG 60 + ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | +Subject 1516 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTC 1575</pre> + <pre class=alignmentgraphic>Query 61 TTCGCAGTCCAGAA 74 + ||||| |||||||| +Subject 1576 TTCGCCGTCCAGAA 1589</pre> </div> </div> @@ -3509,9 +3512,12 @@ </tr> </table> - <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTGTTCGCAGTCCAGAA 74 - ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | ||||| |||||||| -Subject 2319 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTCTTCGCCGTCCAGAA 2392</pre> + <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTG 60 + ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | +Subject 2319 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTC 2378</pre> + <pre class=alignmentgraphic>Query 61 TTCGCAGTCCAGAA 74 + ||||| |||||||| +Subject 2379 TTCGCCGTCCAGAA 2392</pre> </div> </div>
--- a/test-data/blast xml example4.html Tue Jun 17 18:07:02 2014 +0200 +++ b/test-data/blast xml example4.html Wed Jun 18 12:25:37 2014 +0200 @@ -1540,9 +1540,12 @@ </tr> </table> - <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTGTTCGCAGTCCAGAA 74 - ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | ||||| |||||||| -Subject 2319 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTCTTCGCCGTCCAGAA 2392</pre> + <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTG 60 + ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | +Subject 2319 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTC 2378</pre> + <pre class=alignmentgraphic>Query 61 TTCGCAGTCCAGAA 74 + ||||| |||||||| +Subject 2379 TTCGCCGTCCAGAA 2392</pre> </div> </div> @@ -1585,9 +1588,12 @@ </tr> </table> - <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTGTTCGCAGTCCAGAA 74 - ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | ||||| |||||||| -Subject 1516 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTCTTCGCCGTCCAGAA 1589</pre> + <pre class=alignmentgraphic>Query 1 GAGGAAATGCGTATTCAATTCAACGACATGAACAGCGCCTTGACCACAGCTATCCCATTG 60 + ||||| ||||| || || ||||||||||||||||||||| ||||||| || |||||| | +Subject 1516 GAGGAGATGCGCATCCAGTTCAACGACATGAACAGCGCCCTGACCACCGCCATCCCACTC 1575</pre> + <pre class=alignmentgraphic>Query 61 TTCGCAGTCCAGAA 74 + ||||| |||||||| +Subject 1576 TTCGCCGTCCAGAA 1589</pre> </div> </div>