Repository 'blast2html'
hg clone https://toolshed.g2.bx.psu.edu/repos/jankanis/blast2html

Changeset 119:591dc9c24824 (2014-07-31)
Previous changeset 118:7f3f8c10f44b (2014-07-31) Next changeset 120:2729c2326235 (2014-07-31)
Commit message:
tentative fix for Rikilt issue 10: don't sort hits ourselves but use blastxml ordering
modified:
blast2html.py
test-data/blast xml example1.html
b
diff -r 7f3f8c10f44b -r 591dc9c24824 blast2html.py
--- a/blast2html.py Thu Jul 31 13:09:30 2014 +0200
+++ b/blast2html.py Thu Jul 31 13:26:34 2014 +0200
b
@@ -219,10 +219,8 @@
 
 @filter
 def hits(result):
-    # sort hits by longest hotspot first
-    return sorted(result.Iteration_hits.findall('Hit'),
-                  key=lambda h: max(blastxml_len(hsp) for hsp in h.Hit_hsps.Hsp),
-                  reverse=True)
+    # Use findall so we get an empty list if there are no Hit elements at all
+    return result.Iteration_hits.findall('Hit')
 
 @filter('params')
 def result_params(iteration):
b
diff -r 7f3f8c10f44b -r 591dc9c24824 test-data/blast xml example1.html
--- a/test-data/blast xml example1.html Thu Jul 31 13:09:30 2014 +0200
+++ b/test-data/blast xml example1.html Thu Jul 31 13:26:34 2014 +0200
b
b'@@ -757,32 +757,6 @@\n                 </a>\n \n                 <a class=matchresult\n-                   href="#hit1-30"\n-                   onmouseover=\'document.getElementById("defline1").innerHTML="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"\'\n-                   onmouseout=\'document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"\'\n-                   title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)">\n-                  <div class="matchrow graphicrow">\n-                    <div class="matchitem graphicitem"\n-                         style="background-color: black; width: 81.25%"></div>\n-                    <div class="matchitem graphicitem"\n-                         style="background-color: transparent; width: 18.75%"></div>\n-                  </div>\n-                </a>\n-\n-                <a class=matchresult\n-                   href="#hit1-35"\n-                   onmouseover=\'document.getElementById("defline1").innerHTML="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)"\'\n-                   onmouseout=\'document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"\'\n-                   title="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)">\n-                  <div class="matchrow graphicrow">\n-                    <div class="matchitem graphicitem"\n-                         style="background-color: black; width: 81.25%"></div>\n-                    <div class="matchitem graphicitem"\n-                         style="background-color: transparent; width: 18.75%"></div>\n-                  </div>\n-                </a>\n-\n-                <a class=matchresult\n                    href="#hit1-26"\n                    onmouseover=\'document.getElementById("defline1").innerHTML="Chain a, Model Of The Large Subunit Rna Based On A 5.5 A Cryo-em Map Of Triticum Aestivum Translating 80s Ribosome"\'\n                    onmouseout=\'document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"\'\n@@ -837,6 +811,19 @@\n                 </a>\n \n                 <a class=matchresult\n+                   href="#hit1-30"\n+                   onmouseover=\'document.getElementById("defline1").innerHTML="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"\'\n+                   onmouseout=\'document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"\'\n+                   title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)">\n+                  <div class="matchrow graphicrow">\n+                    <div class="matchitem graphicitem"\n+                         style="background-color: black; width: 81.25%"></div>\n+                    <div class="matchitem graphicitem"\n+                         style="background-color: transparent; width: 18.75%"></div>\n+                  </div>\n+                </a>\n+\n+                <a class=matchresult\n                    href="#hit1-31"\n                    onmouseover=\'document.getElementById("defline1").innerHTML="Chain 0, The Re-refined Crystal Structure Of The Haloarcula Marismortui Large Ribosomal Subunit At 2.4 Angstrom Resolution: More Complete Structure Of The L7/l12 And L1 Stalk, L5 And Lx Proteins"\'\n                    onmouseout=\'document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"\'\n@@ -887,6 +874,19 @@\n                 </a>\n \n                 <a class=matchresult\n+                   href="#hi'..b'                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13\n+                |||||||| ||||\n+Subject    651  CGTCCGTCTTGAA  663</pre>\n+                </div>\n+                <div class=hotspot id=hotspot1-30-2>\n+                  <p class=range>\n+                    <span class=range>Range 2: 2705 to 2713</span>\n+                  </p>\n+\n+                  <table class=hotspotstable>\n+                    <tr>\n+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>\n+                    </tr>\n+                    <tr>\n+                      <td>18.3341 bits (9)</td>\n+                      <td>11.9013</td>\n+                      <td>9/9 (100%)</td>\n+                      <td>0/9 (0%)</td>\n+                      <td>Plus/Plus</td>\n+                    </tr>\n+                  </table>\n+\n+                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12\n+                |||||||||\n+Subject   2705  CCGTCGTGA  2713</pre>\n+                </div>\n+\n+              </div>\n+\n               <div class=alignment id=hit1-31>\n \n                 <div class=linkheader>\n@@ -7280,6 +7216,70 @@\n \n               </div>\n \n+              <div class=alignment id=hit1-35>\n+\n+                <div class=linkheader>\n+                  <div class=right><a href="#description1-35">Descriptions</a></div>\n+                  <a class="linkheader" target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">Gene Bank</a>\n+                </div>\n+\n+                <div class=title>\n+                  <p class=hittitle>Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)</p>\n+                  <p class=titleinfo>\n+                    <span class=b>Sequence ID:</span> <a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">gi|428697991|pdb|3J2L|1</a>\n+                    <span class=b>Length:</span> 3049\n+                    <span class=b>Number of Matches:</span> 2\n+                  </p>\n+                </div>\n+\n+\n+                <div class=hotspot id=hotspot1-35-1>\n+                  <p class=range>\n+                    <span class=range>Range 1: 651 to 663</span>\n+                  </p>\n+\n+                  <table class=hotspotstable>\n+                    <tr>\n+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>\n+                    </tr>\n+                    <tr>\n+                      <td>18.3341 bits (9)</td>\n+                      <td>11.9013</td>\n+                      <td>12/13 (92%)</td>\n+                      <td>0/13 (0%)</td>\n+                      <td>Plus/Plus</td>\n+                    </tr>\n+                  </table>\n+\n+                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13\n+                |||||||| ||||\n+Subject    651  CGTCCGTCTTGAA  663</pre>\n+                </div>\n+                <div class=hotspot id=hotspot1-35-2>\n+                  <p class=range>\n+                    <span class=range>Range 2: 2705 to 2713</span>\n+                  </p>\n+\n+                  <table class=hotspotstable>\n+                    <tr>\n+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>\n+                    </tr>\n+                    <tr>\n+                      <td>18.3341 bits (9)</td>\n+                      <td>11.9013</td>\n+                      <td>9/9 (100%)</td>\n+                      <td>0/9 (0%)</td>\n+                      <td>Plus/Plus</td>\n+                    </tr>\n+                  </table>\n+\n+                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12\n+                |||||||||\n+Subject   2705  CCGTCGTGA  2713</pre>\n+                </div>\n+\n+              </div>\n+\n               <div class=alignment id=hit1-36>\n \n                 <div class=linkheader>\n'