tripal_feature_phenotypes.tpl.php

  1. 2.x tripal_phenotype/theme/templates/tripal_feature_phenotypes.tpl.php
  2. 3.x legacy/tripal_phenotype/theme/templates/tripal_feature_phenotypes.tpl.php
1 theme call to tripal_feature_phenotypes.tpl.php

File

tripal_phenotype/theme/templates/tripal_feature_phenotypes.tpl.php
View source
  1. <?php
  2. // expand the feature object to include the phenotypes from the feature_phenotypes table in chado.
  3. $feature = $variables['node']->feature;
  4. $options = array(
  5. 'return_array' => 1,
  6. 'include_fk' => array(
  7. 'phenotype_id' => array(
  8. 'attr_id' => 1,
  9. 'cvalue_id' => 1,
  10. 'assay_id' => 1,
  11. 'observable_id' => 1,
  12. )
  13. )
  14. );
  15. $feature = chado_expand_var($feature, 'table', 'feature_phenotype', $options);
  16. $feature_phenotypes = $feature->feature_phenotype;
  17. if(count($feature_phenotypes) > 0){ ?>
  18. <div class="tripal_feature-data-block-desc tripal-data-block-desc">The feature is associated with the following phenotypes</div><?php
  19. // the $headers array is an array of fields to use as the colum headers.
  20. // additional documentation can be found here
  21. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  22. $headers = array('Attribute', 'Observed Unit', 'Value', 'Evidence Type');
  23. // the $rows array contains an array of rows where each row is an array
  24. // of values for each column of the table in that row. Additional documentation
  25. // can be found here:
  26. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  27. $rows = array();
  28. // iterate through the feature_phenotype records
  29. foreach ($feature_phenotypes as $feature_phenotype){
  30. $phenotype = $feature_phenotype->phenotype_id;
  31. // expand the text fields
  32. $options = array('return_array' => 1);
  33. $phenotype = chado_expand_var($phenotype, 'field', 'phenotype.value', $options);
  34. $phenotype = chado_expand_var($phenotype, 'field', 'phenotype.uniquename', $options);
  35. $phenotype = chado_expand_var($phenotype, 'field', 'phenotype.name', $options);
  36. // get the phenotype value. If the value is qualitative the cvalue_id will link to a type.
  37. // If quantitative we use the value column
  38. $phen_value = $phenotype->value . '<br>';
  39. if ($phenotype->cvalue_id) {
  40. $phen_value .= ucwords(preg_replace('/_/', ' ', $phenotype->cvalue_id->name)) . '<br>';
  41. }
  42. $phen_value = $phenotype->cvalue_id ? $phenotype->cvalue_id->name : $phenotype->value;
  43. $phenotype = $feature_phenotype->phenotype_id;
  44. $rows[] = array(
  45. $phenotype->attr_id->name,
  46. $phenotype->observable_id->name,
  47. $phen_value,
  48. $phenotype->assay_id->name
  49. );
  50. }
  51. // the $table array contains the headers and rows array as well as other
  52. // options for controlling the display of the table. Additional
  53. // documentation can be found here:
  54. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  55. $table = array(
  56. 'header' => $headers,
  57. 'rows' => $rows,
  58. 'attributes' => array(
  59. 'id' => 'tripal_feature-table-phenotypes',
  60. 'class' => 'tripal-data-table'
  61. ),
  62. 'sticky' => FALSE,
  63. 'caption' => '',
  64. 'colgroups' => array(),
  65. 'empty' => '',
  66. );
  67. // once we have our table array structure defined, we call Drupal's theme_table()
  68. // function to generate the table.
  69. print theme_table($table);
  70. }