tripal_featuremap_featurepos.tpl.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. $featuremap = $variables['node']->featuremap;
  3. $feature_positions = array();
  4. // expand the featuremap object to include the records from the featurepos table
  5. // specify the number of features to show by default and the unique pager ID
  6. $num_results_per_page = 25;
  7. $featurepos_pager_id = 0;
  8. // get the features aligned on this map
  9. $options = array(
  10. 'return_array' => 1,
  11. 'order_by' => array('map_feature_id' => 'ASC'),
  12. 'pager' => array('limit' => $num_results_per_page, 'element' => $featurepos_pager_id),
  13. 'include_fk' => array(
  14. 'map_feature_id' => array(
  15. 'type_id' => 1,
  16. 'organism_id' => 1,
  17. ),
  18. 'feature_id' => array(
  19. 'type_id' => 1,
  20. ),
  21. 'featuremap_id' => array(
  22. 'unittype_id' => 1,
  23. ),
  24. ),
  25. );
  26. $featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featurepos', $options);
  27. $feature_positions = $featuremap->featurepos;
  28. // create the pager.
  29. global $pager_total_items;
  30. $featurepos_pager = theme('pager', array(), $num_results_per_page, $featurepos_pager_id, array('block' => 'featurepos'));
  31. $total_features = $pager_total_items[$featurepos_pager_id];
  32. if(count($feature_positions) > 0){ ?>
  33. <div id="tripal_featuremap-featurepos-box" class="tripal_featuremap-info-box tripal-info-box">
  34. <div class="tripal_featuremap-info-box-title tripal-info-box-title">Map Features</div>
  35. <div class="tripal_featuremap-info-box-desc tripal-info-box-desc">This Map contains <?php print number_format($total_features) ?> features:</div>
  36. <table id="tripal_featuremap-featurepos-table" class="tripal_featuremap-table tripal-table tripal-table-horz">
  37. <tr>
  38. <th>Landmark</th>
  39. <th>Type</th>
  40. <th>Organism</th>
  41. <th>Feature Name</th>
  42. <th>Type</th>
  43. <th>Position</th>
  44. </tr> <?php
  45. $i = 0;
  46. foreach ($feature_positions as $position){
  47. $map_feature = $position->map_feature_id;
  48. $feature = $position->feature_id;
  49. $organism = $map_feature->organism_id;
  50. // check if there are any values in the featureposprop table for the start and stop
  51. $mappos = $position->mappos;
  52. $options = array(
  53. 'return_array' => 1,
  54. 'include_fk' => array(
  55. 'type_id' => 1,
  56. ),
  57. );
  58. $position = tripal_core_expand_chado_vars($position, 'table', 'featureposprop', $options);
  59. $featureposprop = $position->featureposprop;
  60. if (is_array($featureposprop)) {
  61. foreach ($featureposprop as $index => $property) {
  62. if ($property->type_id->name == 'start') {
  63. $start = $property->value;
  64. }
  65. if ($property->type_id->name == 'stop') {
  66. $stop = $property->value;
  67. }
  68. }
  69. }
  70. if ($start and $stop and $start != $stop) {
  71. $mappos = "$start-$stop";
  72. }
  73. if ($start and !$stop) {
  74. $mappos = $start;
  75. }
  76. if ($start and $stop and $start == $stop) {
  77. $mappos = $start;
  78. }
  79. $class = 'tripal_featuremap-table-odd-row tripal-table-odd-row';
  80. if($i % 2 == 0 ){
  81. $class = 'tripal_featuremap-table-even-row tripal-table-even-row';
  82. } ?>
  83. <tr class="<?php print $class ?>">
  84. <td> <?php
  85. if ($map_feature->nid) {
  86. print l($map_feature->name, 'node/' . $map_feature->nid, array('attributes' => array('target' => '_blank')));
  87. }
  88. else {
  89. print $map_feature->name;
  90. } ?>
  91. </td>
  92. <td><?php print $map_feature->type_id->name ?></td>
  93. <td><?php
  94. if ($organism->nid) {
  95. print l($organism->genus . ' ' . $organism->species, 'node/' . $organism->nid, array('attributes' => array('target' => '_blank')));
  96. }
  97. else {
  98. print $organism->genus . ' ' . $organism->species;
  99. } ?>
  100. </td>
  101. <td> <?php
  102. if ($feature->nid) {
  103. print l($feature->name, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
  104. }
  105. else {
  106. print $feature->name;
  107. } ?>
  108. </td>
  109. <td><?php print $feature->type_id->name ?></td>
  110. <td><?php print $mappos ?>&nbsp;<?php print $position->featuremap_id->unittype_id->name ?> </td>
  111. </tr> <?php
  112. $i++;
  113. } ?>
  114. </table> <?php
  115. print $featurepos_pager ?>
  116. </div><?php
  117. }?>