feature.views.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the feature table, it's fields and any joins between it and other tables
  5. * @see tripal_feature_views_data() --in tripal_feature.views.inc
  6. *
  7. * @todo Add better handler for is_analysis, is_obsolete: something which changes the t/f to a true boolean
  8. * @todo Add support for the following tables: featureprop, featureloc, featurepos, feature_synonym, feature_relationship
  9. * @todo Add join to node table within if <chado/drupal same db>; also addd if not around nid field
  10. *
  11. * BASE TABLE: feature
  12. * @code
  13. * create table feature (
  14. * feature_id serial not null,
  15. * primary key (feature_id),
  16. * dbxref_id int,
  17. * foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED,
  18. * organism_id int not null,
  19. * foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED,
  20. * name varchar(255),
  21. * uniquename text not null,
  22. * residues text,
  23. * seqlen int,
  24. * md5checksum char(32),
  25. * type_id int not null,
  26. * foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  27. * is_analysis boolean not null default 'false',
  28. * is_obsolete boolean not null default 'false',
  29. * timeaccessioned timestamp not null default current_timestamp,
  30. * timelastmodified timestamp not null default current_timestamp,
  31. * constraint feature_c1 unique (organism_id,uniquename,type_id)
  32. * );
  33. * @endcode
  34. */
  35. function retrieve_feature_views_data() {
  36. // Basic table definition
  37. $data['feature']['table']['group'] = 'Chado Feature';
  38. $data['feature']['table']['base'] = array(
  39. 'field' => 'feature_id',
  40. 'title' => 'Chado Features',
  41. 'help' => 'Features are Sequence Data Records in Chado.',
  42. 'database' => 'chado'
  43. );
  44. // Table Field Definitions----------------------
  45. // Field: feature_id (primary key)
  46. $data['feature']['feature_id'] = array(
  47. 'title' => 'Feature ID',
  48. 'help' => 'The primary key of a feature',
  49. 'field' => array(
  50. 'handler' => 'views_handler_field_numeric',
  51. 'click sortable' => TRUE,
  52. ),
  53. 'filter' => array(
  54. 'handler' => 'views_handler_filter_numeric',
  55. ),
  56. 'sort' => array(
  57. 'handler' => 'views_handler_sort',
  58. ),
  59. );
  60. // Calculated Field: Node ID
  61. // use custom field handler to query drupal for the node ID
  62. // this is only needed if chado is in a separate database from drupal
  63. $data['feature']['feature_nid'] = array(
  64. 'title' => 'Node ID',
  65. 'help' => 'This is the node ID of this feature. It can be used as a link to the node.',
  66. 'field' => array(
  67. 'handler' => 'views_handler_field_computed_feature_nid',
  68. ),
  69. );
  70. // Field: organism_id (forgeign key)
  71. // join between organism table and this one in tripal_organism/views/organism.views.inc
  72. // Field: dbxref_id (forgeign key)
  73. // join between dbxref table and this one in tripal_db/views/dbxref.views.inc
  74. // Field: type_id (forgeign key)
  75. // join between cvterm table and this one in tripal_cv/views/cvterm.views.inc
  76. // Field: name (varchar 255)
  77. $data['feature']['name'] = array(
  78. 'title' => 'Name',
  79. 'help' => 'The human-readable, non-unique name of a feature.',
  80. 'field' => array(
  81. 'handler' => 'views_handler_field',
  82. 'click sortable' => TRUE,
  83. ),
  84. 'sort' => array(
  85. 'handler' => 'views_handler_sort',
  86. ),
  87. 'filter' => array(
  88. 'handler' => 'views_handler_filter_string',
  89. ),
  90. 'argument' => array(
  91. 'handler' => 'views_handler_argument_string',
  92. ),
  93. );
  94. // Field: unique name (text)
  95. $data['feature']['uniquename'] = array(
  96. 'title' => 'Unique Name',
  97. 'help' => 'The unique name of a feature.',
  98. 'field' => array(
  99. 'handler' => 'views_handler_field',
  100. 'click sortable' => TRUE,
  101. ),
  102. 'sort' => array(
  103. 'handler' => 'views_handler_sort',
  104. ),
  105. 'filter' => array(
  106. 'handler' => 'views_handler_filter_string',
  107. ),
  108. 'argument' => array(
  109. 'handler' => 'views_handler_argument_string',
  110. ),
  111. );
  112. // Field: residues (text)
  113. $data['feature']['residues'] = array(
  114. 'title' => 'Residues',
  115. 'help' => 'The sequence of a feature.',
  116. 'field' => array(
  117. 'handler' => 'views_handler_field',
  118. 'click sortable' => TRUE,
  119. ),
  120. 'sort' => array(
  121. 'handler' => 'views_handler_sort',
  122. ),
  123. 'filter' => array(
  124. 'handler' => 'views_handler_filter_string',
  125. ),
  126. 'argument' => array(
  127. 'handler' => 'views_handler_argument_string',
  128. ),
  129. );
  130. // Field: sequence length (integer)
  131. $data['feature']['seqlen'] = array(
  132. 'title' => 'Sequence Length',
  133. 'help' => 'The length of the sequence',
  134. 'field' => array(
  135. 'handler' => 'views_handler_field_numeric',
  136. 'click sortable' => TRUE,
  137. ),
  138. 'filter' => array(
  139. 'handler' => 'views_handler_filter_numeric',
  140. ),
  141. 'sort' => array(
  142. 'handler' => 'views_handler_sort',
  143. ),
  144. );
  145. // Field: is analysis (boolean -t/f)
  146. $data['feature']['is_analysis'] = array(
  147. 'title' => 'Is Analysis',
  148. 'help' => 'A boolean indicating whether this feature was annotated by means of automated analysis.',
  149. 'field' => array(
  150. 'handler' => 'views_handler_field',
  151. 'click sortable' => TRUE,
  152. ),
  153. 'filter' => array(
  154. 'handler' => 'views_handler_filter',
  155. ),
  156. 'sort' => array(
  157. 'handler' => 'views_handler_sort',
  158. ),
  159. );
  160. // Field: is obsolete (boolean -t/f)
  161. $data['feature']['is_obsolete'] = array(
  162. 'title' => 'Is Obsolete',
  163. 'help' => 'A boolean indicating whether this feature is obsolete.',
  164. 'field' => array(
  165. 'handler' => 'views_handler_field',
  166. 'click sortable' => TRUE,
  167. ),
  168. 'filter' => array(
  169. 'handler' => 'views_handler_filter',
  170. ),
  171. 'sort' => array(
  172. 'handler' => 'views_handler_sort',
  173. ),
  174. );
  175. // Field: time accessioned (datetime)
  176. $data['feature']['timeaccessioned'] = array(
  177. 'title' => 'Time Accessioned',
  178. 'help' => 'The date & time when this feature was accessioned (added into the database)',
  179. 'field' => array(
  180. 'handler' => 'views_handler_field_readable_date',
  181. 'click sortable' => TRUE,
  182. ),
  183. 'sort' => array(
  184. 'handler' => 'views_handler_sort_date',
  185. ),
  186. );
  187. // Field: time last modified (datetime)
  188. $data['feature']['timelastmodified'] = array(
  189. 'title' => 'Time Last Modified',
  190. 'help' => 'The date & time when this feature was last modified.',
  191. 'field' => array(
  192. 'handler' => 'views_handler_field_readable_date',
  193. 'click sortable' => TRUE,
  194. ),
  195. 'sort' => array(
  196. 'handler' => 'views_handler_sort_date',
  197. ),
  198. );
  199. return $data;
  200. }