Selaa lähdekoodia

BLAST Analysis: Allows BLAST XML to not contain HSP info, for cases where summary information was loaded

Lacey Sanderson 13 vuotta sitten
vanhempi
commit
4fd020ca99

+ 14 - 3
extensions/tripal_analysis_blast/includes/parse_blast_XML.inc

@@ -598,10 +598,21 @@ function tripal_analysis_blast_get_result_object($xml_string,$db,$max,$feature_i
 		}
 		
 		$hits_array[$hit_count]['best_evalue'] = $best_evalue;
-		$percent_identity = number_format($best_identity/$best_len*100, 2);
-		$hits_array[$hit_count]['percent_identity'] = $percent_identity;
+		
+		if (!empty($best_len)) {
+  		$percent_identity = number_format($best_identity/$best_len*100, 2);
+  		$hits_array[$hit_count]['percent_identity'] = $percent_identity;
+  	}
+  	
 		$hits_array[$hit_count]['description'] = $description;
-		$hits_array[$hit_count]['hsp'] = $hsp_array;
+		
+		// if there is at least one HSP
+		if (!empty($hsp_array[0]['query_frame'])) {
+		  $hits_array[$hit_count]['hsp'] = $hsp_array;
+		} else {
+		  $hits_array[$hit_count]['hsp'] = array();
+		}
+		
 		$hit_count ++;
 		
 		// if we've hit the maximum number of hits then return

+ 21 - 19
extensions/tripal_analysis_blast/theme/tripal_feature/tripal_feature_blast_results.tpl.php

@@ -84,25 +84,27 @@ if(count($blast_results_list) > 0){
 			   <td nowrap><?php  print $hit['percent_identity']?></td>
 			   <td><?php print $hit['description']?></td>
 		   </tr>
-	      <tr class="<?php print $class ?>">
-		      <td colspan=5>
-			      <a class="blast-hit-arrow-icon" onclick="return tripal_blast_toggle_alignment(<?php print $analysis->analysis_id ?>,<?php print $i?>)"><img id="tripal_analysis_blast-info-toggle-image-<?php print $analysis->analysis_id ?>-<?php print $i?>" src=<?php print $hit['arrowr_url']?> align="top"> View Alignment</a>
-			      <div class="tripal_analysis_blast-info-hsp-title"></div>
-		      </td>
-	      </tr>
-	      <tr class="<?php print $class ?> tripal_analysis_blast-result-last-row">
-		      <td colspan=5>
-		      <?php 
-		      $hsps_array = $hit['hsp'];
-		      foreach ($hsps_array AS $hsp) { ?>
-			      <div class="tripal_analysis_blast-info-hsp-desc" id="tripal_analysis_blast-info-hsp-desc-<?php print $analysis->analysis_id ?>-<?php print $i?>">
-				      &nbsp;HSP <?php  print $hsp['hsp_num'] ?>
-				      <pre>Score: <?php print $hsp['bit_score'] ?> bits (<?php print $hsp['score'] ?>), Expect = <?php print $hsp['evalue'] ?><br>Identity = <?php print sprintf("%d/%d (%.2f%%)", $hsp['identity'], $hsp['align_len'], $hsp['identity']/$hsp['align_len']*100) ?>, Postives = <?php print sprintf("%d/%d (%.2f%%)", $hsp['positive'], $hsp['align_len'], $hsp['positive']/$hsp['align_len']*100)?>, Query Frame = <?php print $hsp['query_frame']?></a><br><br></a>Query: <?php print sprintf("%4d", $hsp['query_from'])?> <?php print $hsp['qseq'] ?> <?php print sprintf("%d", $hsp['query_to']); ?><br>            <?php print $hsp['midline'] ?><br>Sbjct: <?php print sprintf("%4d", $hsp['hit_from']) ?> <?php print $hsp['hseq']?> <?php print sprintf("%d",$hsp['hit_to']) ?></pre><br>
-			      </div>
-		      <?php } ?>
-		      </td>
-	      </tr>		
-         <?php $i++;
+		   <?php if (!empty($hit['hsp'])) { ?>
+          <tr class="<?php print $class ?>">
+            <td colspan=5>
+              <a class="blast-hit-arrow-icon" onclick="return tripal_blast_toggle_alignment(<?php print $analysis->analysis_id ?>,<?php print $i?>)"><img id="tripal_analysis_blast-info-toggle-image-<?php print $analysis->analysis_id ?>-<?php print $i?>" src=<?php print $hit['arrowr_url']?> align="top"> View Alignment</a>
+              <div class="tripal_analysis_blast-info-hsp-title"></div>
+            </td>
+          </tr>
+          <tr class="<?php print $class ?> tripal_analysis_blast-result-last-row">
+            <td colspan=5>
+            <?php 
+            $hsps_array = $hit['hsp'];
+            foreach ($hsps_array AS $hsp) { ?>
+              <div class="tripal_analysis_blast-info-hsp-desc" id="tripal_analysis_blast-info-hsp-desc-<?php print $analysis->analysis_id ?>-<?php print $i?>">
+                &nbsp;HSP <?php  print $hsp['hsp_num'] ?>
+                <pre>Score: <?php print $hsp['bit_score'] ?> bits (<?php print $hsp['score'] ?>), Expect = <?php print $hsp['evalue'] ?><br>Identity = <?php print sprintf("%d/%d (%.2f%%)", $hsp['identity'], $hsp['align_len'], $hsp['identity']/$hsp['align_len']*100) ?>, Postives = <?php print sprintf("%d/%d (%.2f%%)", $hsp['positive'], $hsp['align_len'], $hsp['positive']/$hsp['align_len']*100)?>, Query Frame = <?php print $hsp['query_frame']?></a><br><br></a>Query: <?php print sprintf("%4d", $hsp['query_from'])?> <?php print $hsp['qseq'] ?> <?php print sprintf("%d", $hsp['query_to']); ?><br>            <?php print $hsp['midline'] ?><br>Sbjct: <?php print sprintf("%4d", $hsp['hit_from']) ?> <?php print $hsp['hseq']?> <?php print sprintf("%d",$hsp['hit_to']) ?></pre><br>
+              </div>
+            <?php } ?>
+            </td>
+          </tr>		
+        <?php }
+        $i++;
 	   } ?>
 	</table>
 </div>