tripal_feature_featurelocs.tpl.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. $feature = $variables['node']->feature;
  3. // get the featurelocs. if only one featureloc exists then we want to convert
  4. // the object into an array, otherwise the value is an array
  5. $ffeaturelocs = $feature->featureloc->feature_id;
  6. if (!$ffeaturelocs) {
  7. $ffeaturelocs = array();
  8. } elseif (!is_array($ffeaturelocs)) {
  9. $ffeaturelocs = array($ffeaturelocs);
  10. }
  11. $sfeaturelocs = $feature->featureloc->srcfeature_id;
  12. if (!$sfeaturelocs) {
  13. $sfeaturelocs = array();
  14. } elseif (!is_array($sfeaturelocs)) {
  15. $sfeaturelocs = array($sfeaturelocs);
  16. }
  17. ?>
  18. <div id="tripal_feature-featurelocs_as_child-box" class="tripal_feature-info-box tripal-info-box">
  19. <div class="tripal_feature-info-box-title tripal-info-box-title">Alignments</div>
  20. <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php print $feature->name;?> is aligined to the following</div>
  21. <?php if(count($ffeaturelocs) > 0){ ?>
  22. <table id="tripal_feature-featurelocs_as_child-table" class="tripal_feature-table tripal-table tripal-table-horz">
  23. <tr>
  24. <th>Name</th>
  25. <th>Type</th>
  26. <th>Location</th>
  27. <th>Phase</th>
  28. <th>Direction</th>
  29. </tr>
  30. <?php
  31. $i = 0;
  32. foreach ($ffeaturelocs as $featureloc){
  33. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  34. if($i % 2 == 0 ){
  35. $class = 'tripal_feature-table-odd-row tripal-table-even-row';
  36. }
  37. $location = $featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax;
  38. if($location->srcfeature_id->nid){
  39. $location = "<a href=\"" . url("node/$location->srcfeature_id->nid") . "\">".$featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax ."</a> ";
  40. }
  41. ?>
  42. <tr class="<?php print $class ?>">
  43. <td><?php
  44. if($featureloc->feature_id->nid){
  45. print "<a href=\"" . url("node/".$featureloc->feature_id->name) . "\">".$featureloc->feature_id->name."</a>";
  46. } else {
  47. print $featureloc->feature_id->name;
  48. }?>
  49. </td>
  50. <td><?php print $featureloc->feature_id->type_id->name ?></td>
  51. <td><?php print $location ?></td>
  52. <td><?php print $featureloc->phase ?></td>
  53. <td><?php
  54. if($featureloc->strand == -1){
  55. print "reverse";
  56. }
  57. elseif($featureloc->strand == 1){
  58. print "forward";
  59. }
  60. elseif($featureloc->strand == 0){
  61. print "N/A";
  62. }
  63. else {
  64. print $featureloc->strand;
  65. }?>
  66. </td>
  67. </tr>
  68. <?php
  69. $i++;
  70. } ?>
  71. </table>
  72. <?php } else { ?>
  73. <div class="tripal-no-results">There are no alignments</div>
  74. <?php }?>
  75. <br><br><div class="tripal_feature-info-box-desc tripal-info-box-desc">The following are aligned to <?php print $feature->name;?></div>
  76. <?php if(count($sfeaturelocs) > 0){ ?>
  77. <table id="tripal_feature-featurelocs_as_child-table" class="tripal_feature-table tripal-table tripal-table-horz">
  78. <tr>
  79. <th>Name</th>
  80. <th>Type</th>
  81. <th>Location</th>
  82. <th>Phase</th>
  83. <th>Direction</th>
  84. </tr>
  85. <?php
  86. $i = 0;
  87. foreach ($sfeaturelocs as $featureloc){
  88. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  89. if($i % 2 == 0 ){
  90. $class = 'tripal_feature-table-odd-row tripal-table-even-row';
  91. }
  92. $location = $featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax;
  93. if($location->srcfeature_id->nid){
  94. $location = "<a href=\"" . url("node/$location->srcfeature_id->nid") . "\">".$featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax ."</a> ";
  95. }
  96. ?>
  97. <tr class="<?php print $class ?>">
  98. <td><?php
  99. if($featureloc->feature_id->nid){
  100. print "<a href=\"" . url("node/".$featureloc->feature_id->name) . "\">".$featureloc->feature_id->name."</a>";
  101. } else {
  102. print $featureloc->feature_id->name;
  103. }?>
  104. </td>
  105. <td><?php print $featureloc->feature_id->type_id->name ?></td>
  106. <td><?php print $location ?></td>
  107. <td><?php print $featureloc->phase ?></td>
  108. <td><?php
  109. if($featureloc->strand == -1){
  110. print "reverse";
  111. }
  112. elseif($featureloc->strand == 1){
  113. print "forward";
  114. }
  115. elseif($featureloc->strand == 0){
  116. print "N/A";
  117. }
  118. else {
  119. print $featureloc->strand;
  120. }?>
  121. </td>
  122. </tr>
  123. <?php
  124. $i++;
  125. } ?>
  126. </table>
  127. <?php } else { ?>
  128. <div class="tripal-no-results">There are no alignments</div>
  129. <?php }?>
  130. </div>