changeset 119:591dc9c24824

tentative fix for Rikilt issue 10: don't sort hits ourselves but use blastxml ordering
author Jan Kanis <jan.code@jankanis.nl>
date Thu, 31 Jul 2014 13:26:34 +0200
parents 7f3f8c10f44b
children 2729c2326235
files blast2html.py test-data/blast xml example1.html
diffstat 2 files changed, 182 insertions(+), 184 deletions(-) [+]
line wrap: on
line diff
--- a/blast2html.py	Thu Jul 31 13:09:30 2014 +0200
+++ b/blast2html.py	Thu Jul 31 13:26:34 2014 +0200
@@ -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):
--- 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
@@ -757,32 +757,6 @@
                 </a>
 
                 <a class=matchresult
-                   href="#hit1-30"
-                   onmouseover='document.getElementById("defline1").innerHTML="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"'
-                   onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
-                   title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)">
-                  <div class="matchrow graphicrow">
-                    <div class="matchitem graphicitem"
-                         style="background-color: black; width: 81.25%"></div>
-                    <div class="matchitem graphicitem"
-                         style="background-color: transparent; width: 18.75%"></div>
-                  </div>
-                </a>
-
-                <a class=matchresult
-                   href="#hit1-35"
-                   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)"'
-                   onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
-                   title="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)">
-                  <div class="matchrow graphicrow">
-                    <div class="matchitem graphicitem"
-                         style="background-color: black; width: 81.25%"></div>
-                    <div class="matchitem graphicitem"
-                         style="background-color: transparent; width: 18.75%"></div>
-                  </div>
-                </a>
-
-                <a class=matchresult
                    href="#hit1-26"
                    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"'
                    onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
@@ -837,6 +811,19 @@
                 </a>
 
                 <a class=matchresult
+                   href="#hit1-30"
+                   onmouseover='document.getElementById("defline1").innerHTML="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"'
+                   onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
+                   title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)">
+                  <div class="matchrow graphicrow">
+                    <div class="matchitem graphicitem"
+                         style="background-color: black; width: 81.25%"></div>
+                    <div class="matchitem graphicitem"
+                         style="background-color: transparent; width: 18.75%"></div>
+                  </div>
+                </a>
+
+                <a class=matchresult
                    href="#hit1-31"
                    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"'
                    onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
@@ -887,6 +874,19 @@
                 </a>
 
                 <a class=matchresult
+                   href="#hit1-35"
+                   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)"'
+                   onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
+                   title="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)">
+                  <div class="matchrow graphicrow">
+                    <div class="matchitem graphicitem"
+                         style="background-color: black; width: 81.25%"></div>
+                    <div class="matchitem graphicitem"
+                         style="background-color: transparent; width: 18.75%"></div>
+                  </div>
+                </a>
+
+                <a class=matchresult
                    href="#hit1-36"
                    onmouseover='document.getElementById("defline1").innerHTML="Chain 0, Crystal Structure Of Enhanced Macrolide Bound To 50s Ribosomal Subunit"'
                    onmouseout='document.getElementById("defline1").innerHTML="Mouse-over to show defline and scores, click to show alignments"'
@@ -2183,32 +2183,6 @@
                   <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/1C2W_B?report=genbank&amp;log$=nuclalign">1C2W_B</a></td>
                 </tr>
                 <tr>
-                  <td><div><a href="#hit1-30"
-                              title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"
-                              id="description1-30">
-                        Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)
-                  </a></div></td>
-                  <td>18.3</td>
-                  <td>36.7</td>
-                  <td>81%</td>
-                  <td>11.9</td>
-                  <td>92%</td>
-                  <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">3J44_1</a></td>
-                </tr>
-                <tr>
-                  <td><div><a href="#hit1-35"
-                              title="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)"
-                              id="description1-35">
-                        Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)
-                  </a></div></td>
-                  <td>18.3</td>
-                  <td>36.7</td>
-                  <td>81%</td>
-                  <td>11.9</td>
-                  <td>92%</td>
-                  <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">3J2L_1</a></td>
-                </tr>
-                <tr>
                   <td><div><a href="#hit1-26"
                               title="Chain a, Model Of The Large Subunit Rna Based On A 5.5 A Cryo-em Map Of Triticum Aestivum Translating 80s Ribosome"
                               id="description1-26">
@@ -2261,6 +2235,19 @@
                   <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/4BYW_5?report=genbank&amp;log$=nuclalign">4BYW_5</a></td>
                 </tr>
                 <tr>
+                  <td><div><a href="#hit1-30"
+                              title="Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)"
+                              id="description1-30">
+                        Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)
+                  </a></div></td>
+                  <td>18.3</td>
+                  <td>36.7</td>
+                  <td>81%</td>
+                  <td>11.9</td>
+                  <td>92%</td>
+                  <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">3J44_1</a></td>
+                </tr>
+                <tr>
                   <td><div><a href="#hit1-31"
                               title="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"
                               id="description1-31">
@@ -2313,6 +2300,19 @@
                   <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3ZEX_B?report=genbank&amp;log$=nuclalign">3ZEX_B</a></td>
                 </tr>
                 <tr>
+                  <td><div><a href="#hit1-35"
+                              title="Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)"
+                              id="description1-35">
+                        Chain 1, Promiscuous Behavior Of Proteins In Archaeal Ribosomes Revealed By Cryo-em: Implications For Evolution Of Eukaryotic Ribosomes (50s Ribosomal Rna)
+                  </a></div></td>
+                  <td>18.3</td>
+                  <td>36.7</td>
+                  <td>81%</td>
+                  <td>11.9</td>
+                  <td>92%</td>
+                  <td><a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">3J2L_1</a></td>
+                </tr>
+                <tr>
                   <td><div><a href="#hit1-36"
                               title="Chain 0, Crystal Structure Of Enhanced Macrolide Bound To 50s Ribosomal Subunit"
                               id="description1-36">
@@ -6266,134 +6266,6 @@
 
               </div>
 
-              <div class=alignment id=hit1-30>
-
-                <div class=linkheader>
-                  <div class=right><a href="#description1-30">Descriptions</a></div>
-                  <a class="linkheader" target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">Gene Bank</a>
-                </div>
-
-                <div class=title>
-                  <p class=hittitle>Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)</p>
-                  <p class=titleinfo>
-                    <span class=b>Sequence ID:</span> <a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">gi|551701574|pdb|3J44|1</a>
-                    <span class=b>Length:</span> 3049
-                    <span class=b>Number of Matches:</span> 2
-                  </p>
-                </div>
-
-
-                <div class=hotspot id=hotspot1-30-1>
-                  <p class=range>
-                    <span class=range>Range 1: 651 to 663</span>
-                  </p>
-
-                  <table class=hotspotstable>
-                    <tr>
-                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
-                    </tr>
-                    <tr>
-                      <td>18.3341 bits (9)</td>
-                      <td>11.9013</td>
-                      <td>12/13 (92%)</td>
-                      <td>0/13 (0%)</td>
-                      <td>Plus/Plus</td>
-                    </tr>
-                  </table>
-
-                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13
-                |||||||| ||||
-Subject    651  CGTCCGTCTTGAA  663</pre>
-                </div>
-                <div class=hotspot id=hotspot1-30-2>
-                  <p class=range>
-                    <span class=range>Range 2: 2705 to 2713</span>
-                  </p>
-
-                  <table class=hotspotstable>
-                    <tr>
-                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
-                    </tr>
-                    <tr>
-                      <td>18.3341 bits (9)</td>
-                      <td>11.9013</td>
-                      <td>9/9 (100%)</td>
-                      <td>0/9 (0%)</td>
-                      <td>Plus/Plus</td>
-                    </tr>
-                  </table>
-
-                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12
-                |||||||||
-Subject   2705  CCGTCGTGA  2713</pre>
-                </div>
-
-              </div>
-
-              <div class=alignment id=hit1-35>
-
-                <div class=linkheader>
-                  <div class=right><a href="#description1-35">Descriptions</a></div>
-                  <a class="linkheader" target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">Gene Bank</a>
-                </div>
-
-                <div class=title>
-                  <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>
-                  <p class=titleinfo>
-                    <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>
-                    <span class=b>Length:</span> 3049
-                    <span class=b>Number of Matches:</span> 2
-                  </p>
-                </div>
-
-
-                <div class=hotspot id=hotspot1-35-1>
-                  <p class=range>
-                    <span class=range>Range 1: 651 to 663</span>
-                  </p>
-
-                  <table class=hotspotstable>
-                    <tr>
-                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
-                    </tr>
-                    <tr>
-                      <td>18.3341 bits (9)</td>
-                      <td>11.9013</td>
-                      <td>12/13 (92%)</td>
-                      <td>0/13 (0%)</td>
-                      <td>Plus/Plus</td>
-                    </tr>
-                  </table>
-
-                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13
-                |||||||| ||||
-Subject    651  CGTCCGTCTTGAA  663</pre>
-                </div>
-                <div class=hotspot id=hotspot1-35-2>
-                  <p class=range>
-                    <span class=range>Range 2: 2705 to 2713</span>
-                  </p>
-
-                  <table class=hotspotstable>
-                    <tr>
-                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
-                    </tr>
-                    <tr>
-                      <td>18.3341 bits (9)</td>
-                      <td>11.9013</td>
-                      <td>9/9 (100%)</td>
-                      <td>0/9 (0%)</td>
-                      <td>Plus/Plus</td>
-                    </tr>
-                  </table>
-
-                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12
-                |||||||||
-Subject   2705  CCGTCGTGA  2713</pre>
-                </div>
-
-              </div>
-
               <div class=alignment id=hit1-26>
 
                 <div class=linkheader>
@@ -6826,6 +6698,70 @@
 
               </div>
 
+              <div class=alignment id=hit1-30>
+
+                <div class=linkheader>
+                  <div class=right><a href="#description1-30">Descriptions</a></div>
+                  <a class="linkheader" target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">Gene Bank</a>
+                </div>
+
+                <div class=title>
+                  <p class=hittitle>Chain 1, Structure Of The Methanococcus Jannaschii Ribosome-secyebeta Channel Complex (50s Ribosomal Subunit)</p>
+                  <p class=titleinfo>
+                    <span class=b>Sequence ID:</span> <a target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J44_1?report=genbank&amp;log$=nuclalign">gi|551701574|pdb|3J44|1</a>
+                    <span class=b>Length:</span> 3049
+                    <span class=b>Number of Matches:</span> 2
+                  </p>
+                </div>
+
+
+                <div class=hotspot id=hotspot1-30-1>
+                  <p class=range>
+                    <span class=range>Range 1: 651 to 663</span>
+                  </p>
+
+                  <table class=hotspotstable>
+                    <tr>
+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
+                    </tr>
+                    <tr>
+                      <td>18.3341 bits (9)</td>
+                      <td>11.9013</td>
+                      <td>12/13 (92%)</td>
+                      <td>0/13 (0%)</td>
+                      <td>Plus/Plus</td>
+                    </tr>
+                  </table>
+
+                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13
+                |||||||| ||||
+Subject    651  CGTCCGTCTTGAA  663</pre>
+                </div>
+                <div class=hotspot id=hotspot1-30-2>
+                  <p class=range>
+                    <span class=range>Range 2: 2705 to 2713</span>
+                  </p>
+
+                  <table class=hotspotstable>
+                    <tr>
+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
+                    </tr>
+                    <tr>
+                      <td>18.3341 bits (9)</td>
+                      <td>11.9013</td>
+                      <td>9/9 (100%)</td>
+                      <td>0/9 (0%)</td>
+                      <td>Plus/Plus</td>
+                    </tr>
+                  </table>
+
+                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12
+                |||||||||
+Subject   2705  CCGTCGTGA  2713</pre>
+                </div>
+
+              </div>
+
               <div class=alignment id=hit1-31>
 
                 <div class=linkheader>
@@ -7280,6 +7216,70 @@
 
               </div>
 
+              <div class=alignment id=hit1-35>
+
+                <div class=linkheader>
+                  <div class=right><a href="#description1-35">Descriptions</a></div>
+                  <a class="linkheader" target="_top" href="http://www.ncbi.nlm.nih.gov/nucleotide/3J2L_1?report=genbank&amp;log$=nuclalign">Gene Bank</a>
+                </div>
+
+                <div class=title>
+                  <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>
+                  <p class=titleinfo>
+                    <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>
+                    <span class=b>Length:</span> 3049
+                    <span class=b>Number of Matches:</span> 2
+                  </p>
+                </div>
+
+
+                <div class=hotspot id=hotspot1-35-1>
+                  <p class=range>
+                    <span class=range>Range 1: 651 to 663</span>
+                  </p>
+
+                  <table class=hotspotstable>
+                    <tr>
+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
+                    </tr>
+                    <tr>
+                      <td>18.3341 bits (9)</td>
+                      <td>11.9013</td>
+                      <td>12/13 (92%)</td>
+                      <td>0/13 (0%)</td>
+                      <td>Plus/Plus</td>
+                    </tr>
+                  </table>
+
+                  <pre class=alignmentgraphic>Query        1  CGTCCGTCGTGAA  13
+                |||||||| ||||
+Subject    651  CGTCCGTCTTGAA  663</pre>
+                </div>
+                <div class=hotspot id=hotspot1-35-2>
+                  <p class=range>
+                    <span class=range>Range 2: 2705 to 2713</span>
+                  </p>
+
+                  <table class=hotspotstable>
+                    <tr>
+                      <th>Score</th><th>Expect</th><th>Identities</th><th>Gaps</th><th>Strand</th>
+                    </tr>
+                    <tr>
+                      <td>18.3341 bits (9)</td>
+                      <td>11.9013</td>
+                      <td>9/9 (100%)</td>
+                      <td>0/9 (0%)</td>
+                      <td>Plus/Plus</td>
+                    </tr>
+                  </table>
+
+                  <pre class=alignmentgraphic>Query        4  CCGTCGTGA  12
+                |||||||||
+Subject   2705  CCGTCGTGA  2713</pre>
+                </div>
+
+              </div>
+
               <div class=alignment id=hit1-36>
 
                 <div class=linkheader>