tripal_feature_references.tpl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. $feature = $variables['node']->feature;
  3. $references = array();
  4. // First, get the dbxref record from feature recrod itself if one exists
  5. if ($feature->dbxref_id) {
  6. $feature->dbxref_id->is_primary = 1; // add this new property so we know it's the primary reference
  7. $references[] = $feature->dbxref_id;
  8. }
  9. // Second, expand the feature object to include the records from the feature_dbxref table
  10. $options = array('return_array' => 1);
  11. $feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_dbxref', $options);
  12. $feature_dbxrefs = $feature->feature_dbxref;
  13. if (count($feature_dbxrefs) > 0 ) {
  14. foreach ($feature_dbxrefs as $feature_dbxref) {
  15. if($feature_dbxref->dbxref_id->db_id->name == 'GFF_source'){
  16. // check to see if the reference 'GFF_source' is there. This reference is
  17. // used to if the Chado Perl GFF loader was used to load the features
  18. }
  19. else {
  20. $references[] = $feature_dbxref->dbxref_id;
  21. }
  22. }
  23. }
  24. if(count($references) > 0){ ?>
  25. <div id="tripal_feature-references-box" class="tripal_feature-info-box tripal-info-box">
  26. <div class="tripal_feature-info-box-title tripal-info-box-title">Cross References</div>
  27. <div class="tripal_feature-info-box-desc tripal-info-box-desc">External references for this <?php print $feature->type_id->name ?></div>
  28. <table id="tripal_feature-references-table" class="tripal_feature-table tripal-table tripal-table-horz">
  29. <tr>
  30. <th>Dababase</th>
  31. <th>Accession</th>
  32. </tr> <?php
  33. $i = 0;
  34. foreach ($references as $dbxref){
  35. if($dbxref_id->db_id->name == 'GFF_source'){
  36. continue; // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
  37. }
  38. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  39. if($i % 2 == 0 ){
  40. $class = 'tripal_feature-table-even-row tripal-table-even-row';
  41. } ?>
  42. <tr class="<?php print $class ?>">
  43. <td> <?php
  44. if ($dbxref->db_id->url) {
  45. print l($dbxref->db_id->name, $dbxref->db_id->url);
  46. }
  47. else {
  48. print $dbxref->db_id->name;
  49. } ?>
  50. </td>
  51. <td> <?php
  52. if ($dbxref->db_id->urlprefix) {
  53. print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
  54. }
  55. else {
  56. print $dbxref->accession;
  57. }
  58. if ($dbxref->is_primary) {
  59. print " <i>(primary cross-reference)</i>";
  60. } ?>
  61. </td>
  62. </tr> <?php
  63. $i++;
  64. } ?>
  65. </table>
  66. </div><?php
  67. }?>