blast_report.tpl.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. ?>
  3. <script type="text/javascript">
  4. $(document).ready(function(){
  5. $("#blast_report tr:not(.result-summary)").hide();
  6. $("#blast_report tr:first-child").show();
  7. $("#blast_report tr.result-summary").click(function(){
  8. $(this).next("tr").toggle();
  9. $(this).find(".arrow").toggleClass("up");
  10. });
  11. });
  12. </script>
  13. <?php
  14. //Load the XML file
  15. $path = current_path();
  16. if (preg_match('%blast/report/([\w\.]+)%',$path,$matches)) {
  17. $filename = 'sites/default/files/' . $matches[1];
  18. $xml=simplexml_load_file($filename);
  19. }
  20. $header = array(
  21. 'number' => array('data' => '#', 'class' => array('number')),
  22. 'query' => array('data' => 'Query Name', 'class' => array('query')),
  23. 'hit' => array('data' => 'Hit Name', 'class' => array('hit')),
  24. 'evalue' => array('data' => 'E-Value', 'class' => array('evalue')),
  25. 'arrow-col' => array('data' => '', 'class' => array('arrow-col'))
  26. );
  27. $rows = array();
  28. $count = 0;
  29. foreach($xml->{'BlastOutput_iterations'}->children() as $iteration) {
  30. foreach($iteration->{'Iteration_hits'}->children() as $hit) {
  31. if (is_object($hit)) {
  32. $count +=1;
  33. $zebra_class = ($count % 2 == 0) ? 'even' : 'odd';
  34. // SIMPLY SUMMARY ROW
  35. $hit_name = $hit->Hit_def;
  36. if (preg_match('/(\w+)/', $hit_name, $matches)) {
  37. $hit_name = $matches[1];
  38. }
  39. $score = $hit->Hit_hsps->Hsp->Hsp_score;
  40. $evalue = $hit->Hit_hsps->Hsp->Hsp_evalue;
  41. $query_name = $iteration->{'Iteration_query-def'};
  42. $row = array(
  43. 'data' => array(
  44. 'number' => array('data' => $count, 'class' => array('number')),
  45. 'query' => array('data' => $query_name, 'class' => array('query')),
  46. 'hit' => array('data' => l($hit_name,''), 'class' => array('hit')),
  47. 'evalue' => array('data' => $evalue, 'class' => array('evalue')),
  48. 'arrow-col' => array('data' => '<div class="arrow"></div>', 'class' => array('arrow-col'))
  49. ),
  50. 'class' => array('result-summary')
  51. );
  52. $rows[] = $row;
  53. // ALIGNMENT ROW (collapsed by default)
  54. // Process HSPs
  55. $HSPs = array();
  56. foreach ($hit->{'Hit_hsps'}->children() as $hsp_xml) {
  57. $HSPs[] = (array) $hsp_xml;
  58. }
  59. $row = array(
  60. 'data' => array(
  61. 'number' => '',
  62. 'query' => array(
  63. 'data' => theme('blast_report_alignment_row', array('HSPs' => $HSPs)),
  64. 'colspan' => 4,
  65. )
  66. ),
  67. 'class' => array('alignment-row', $zebra_class),
  68. 'no_striping' => TRUE
  69. );
  70. $rows[] = $row;
  71. }
  72. }
  73. }
  74. print theme('table', array(
  75. 'header' => $header,
  76. 'rows' => $rows,
  77. 'attributes' => array('id' => 'blast_report'),
  78. ));
  79. ?>