Browse Source

Add best hit homology report to the blast module.

ccheng 14 years ago
parent
commit
9a52649c1c

+ 32 - 0
theme_tripal/js/tripal_analysis_blast.js

@@ -148,4 +148,36 @@ if (Drupal.jsEnabled) {
 	        
      });
    }
+   
+   	//------------------------------------------------------------
+	// Update the blast best hit report for selected page and sorting
+	function tripal_update_best_hit_report(obj, analysis_id, sort, descending, per_page){
+		var page = obj.selectedIndex + 1;
+		var baseurl = location.href.substring(0,location.href.lastIndexOf('/tripal_blast_report/'));
+		var link = baseurl + '/tripal_blast_report/' + analysis_id + "/" + page + "/" + sort + "/" + descending + "/" + per_page;
+
+		tripal_startAjax();
+		$.ajax({
+			url: link,
+			dataType: 'html',
+			type: 'POST',
+			success: function(data){
+				var d = document.createElement('div');
+				d.innerHTML = data;
+				var divs = d.getElementsByTagName("div");
+				for (var i = 0; i < divs.length; i ++) {
+					if (divs[i].getAttribute('id') == 'blast-hits-report') {	
+						var report_table = document.getElementById('blast-hits-report');
+						report_table.innerHTML = divs[i].innerHTML;
+						var table_breport = document.getElementById('tripal_blast_report_table');
+						var sel = document.getElementById('tripal_blast_report_page_selector');
+						sel.options[page - 1].selected = true;
+						tripal_stopAjax();
+					}
+				}
+			}
+		});
+		
+		return false;
+	}
 }

+ 19 - 0
theme_tripal/node-chado_analysis_blast.tpl.php

@@ -56,6 +56,25 @@
                   ?>
               </td>
             </tr>
+            <tr><th>Report</th>
+            <?php
+            	$sql = "SELECT AFP.analysisfeature_id
+	                         FROM {analysisfeature} AF 
+	                         INNER JOIN {analysisfeatureprop} AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
+	                         WHERE analysis_id = %d
+	                         AND AFP.type_id = (SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal'))";
+            	$previous_db = db_set_active('chado');
+            	$exists = db_result(db_query($sql, $node->analysis_id, 'analysis_blast_besthit_query'));
+            	db_set_active($previous_db);
+            	if ($exists) {
+                   $report_url = url("tripal_blast_report/".$node->analysis_id."/1/0/0/20");
+                   print "<td><a href=$report_url>View the best hit homology report</a></td>";
+            	} else {
+            		print "<td>The homology report is not available. Please submit a job to parse the best hit first.</td>";
+            	}
+             ?>
+            
+            </tr>
          </table>
       <!-- End of tripal_analysis_blast theme-->
 	  </div>