tripal_feature_featurelocs.tpl.php 4.9 KB

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