tripal_phenotype.views.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal_phenotype tables. Supplementary functions can be found in
  6. * ./views/
  7. *
  8. * Documentation on views integration can be found at
  9. * http://views2.logrus.com/doc/html/index.html.
  10. */
  11. /*************************************************************************
  12. * Implements hook_views_data()
  13. * Purpose: Describe chado/tripal tables & fields to views
  14. *
  15. * @return: a data array which follows the structure outlined in the
  16. * views2 documentation for this hook. Essentially, it's an array of table
  17. * definitions keyed by chado/tripal table name. Each table definition
  18. * includes basic details about the table, fields in that table and
  19. * relationships between that table and others (joins)
  20. */
  21. function tripal_phenotype_views_data() {
  22. $data = array();
  23. if (module_exists('tripal_views')) {
  24. $tables = array(
  25. 'phenotype'
  26. );
  27. foreach ($tables as $tablename) {
  28. $priority = 9;
  29. // check to see if the table is integrated. If it is then integrate it's
  30. // corresponding 'chado_[table]' table.
  31. if (!tripal_views_is_integrated($tablename, $priority)) {
  32. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
  33. // Add specialty handlers
  34. switch ($tablename) {
  35. case 'phenotype':
  36. $table_integration_array['fields']['attr_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
  37. $table_integration_array['fields']['assay_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
  38. $table_integration_array['fields']['cvalue_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
  39. $table_integration_array['fields']['observable_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
  40. break;
  41. }
  42. tripal_views_integration_add_entry($table_integration_array);
  43. }
  44. }
  45. $tables = array(
  46. 'feature_phenotype',
  47. 'phenotype_cvterm'
  48. );
  49. foreach ($tables as $tablename) {
  50. $priority = 9;
  51. if (!tripal_views_is_integrated($tablename, $priority)) {
  52. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
  53. tripal_views_integration_add_entry($table_integration_array);
  54. }
  55. }
  56. }
  57. return $data;
  58. }
  59. /*************************************************************************
  60. * Implements hook_views_handlers()
  61. * Purpose: Register all custom handlers with views
  62. * where a handler describes either "the type of field",
  63. * "how a field should be filtered", "how a field should be sorted"
  64. *
  65. * @return: An array of handler definitions
  66. */
  67. function tripal_phenotype_views_handlers() {
  68. return array(
  69. 'info' => array(
  70. 'path' => drupal_get_path('module', 'tripal_phenotype') . '/views/handlers',
  71. ),
  72. 'handlers' => array(
  73. ),
  74. );
  75. }
  76. /**
  77. *
  78. * @ingroup tripal_feature_views
  79. */
  80. function tripal_phenotype_views_default_views() {
  81. $views = array();
  82. if (!module_exists('tripal_views')) {
  83. return $views;
  84. }
  85. // Main default view
  86. $view = new view;
  87. $view->name = 'phenotype_listing';
  88. $view->description = 'A listing of chado phenotypes';
  89. $view->tag = 'chado default';
  90. $view->base_table = 'phenotype';
  91. $view->core = 6;
  92. $view->api_version = '2';
  93. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  94. $handler = $view->new_display('default', 'Defaults', 'default');
  95. $handler->override_option('relationships', array(
  96. 'assay_id' => array(
  97. 'label' => 'assay_id to cvterm',
  98. 'required' => 0,
  99. 'id' => 'assay_id',
  100. 'table' => 'phenotype',
  101. 'field' => 'assay_id',
  102. 'relationship' => 'none',
  103. ),
  104. 'attr_id' => array(
  105. 'label' => 'attr_id to cvterm',
  106. 'required' => 0,
  107. 'id' => 'attr_id',
  108. 'table' => 'phenotype',
  109. 'field' => 'attr_id',
  110. 'relationship' => 'none',
  111. ),
  112. 'cvalue_id' => array(
  113. 'label' => 'cvalue_id to cvterm',
  114. 'required' => 0,
  115. 'id' => 'cvalue_id',
  116. 'table' => 'phenotype',
  117. 'field' => 'cvalue_id',
  118. 'relationship' => 'none',
  119. ),
  120. 'observable_id' => array(
  121. 'label' => 'observable_id to cvterm',
  122. 'required' => 0,
  123. 'id' => 'observable_id',
  124. 'table' => 'phenotype',
  125. 'field' => 'observable_id',
  126. 'relationship' => 'none',
  127. ),
  128. ));
  129. $handler->override_option('fields', array(
  130. 'uniquename' => array(
  131. 'label' => 'Unique Name',
  132. 'alter' => array(
  133. 'alter_text' => 0,
  134. 'text' => '',
  135. 'make_link' => 0,
  136. 'path' => '',
  137. 'absolute' => 0,
  138. 'link_class' => '',
  139. 'alt' => '',
  140. 'rel' => '',
  141. 'prefix' => '',
  142. 'suffix' => '',
  143. 'target' => '',
  144. 'help' => '',
  145. 'trim' => 0,
  146. 'max_length' => '',
  147. 'word_boundary' => 1,
  148. 'ellipsis' => 1,
  149. 'html' => 0,
  150. 'strip_tags' => 0,
  151. ),
  152. 'empty' => '',
  153. 'hide_empty' => 0,
  154. 'empty_zero' => 0,
  155. 'hide_alter_empty' => 1,
  156. 'type' => 'separator',
  157. 'separator' => ', ',
  158. 'exclude' => 0,
  159. 'id' => 'uniquename',
  160. 'table' => 'phenotype',
  161. 'field' => 'uniquename',
  162. 'relationship' => 'none',
  163. ),
  164. 'name_1' => array(
  165. 'label' => 'Phenotypic Attribute',
  166. 'alter' => array(
  167. 'alter_text' => 0,
  168. 'text' => '',
  169. 'make_link' => 0,
  170. 'path' => '',
  171. 'absolute' => 0,
  172. 'link_class' => '',
  173. 'alt' => '',
  174. 'rel' => '',
  175. 'prefix' => '',
  176. 'suffix' => '',
  177. 'target' => '',
  178. 'help' => '',
  179. 'trim' => 0,
  180. 'max_length' => '',
  181. 'word_boundary' => 1,
  182. 'ellipsis' => 1,
  183. 'html' => 0,
  184. 'strip_tags' => 0,
  185. ),
  186. 'empty' => '',
  187. 'hide_empty' => 0,
  188. 'empty_zero' => 0,
  189. 'hide_alter_empty' => 1,
  190. 'type' => 'separator',
  191. 'separator' => ', ',
  192. 'exclude' => 0,
  193. 'id' => 'name_1',
  194. 'table' => 'cvterm',
  195. 'field' => 'name',
  196. 'relationship' => 'attr_id',
  197. ),
  198. 'name_3' => array(
  199. 'label' => 'Controlled Value',
  200. 'alter' => array(
  201. 'alter_text' => 0,
  202. 'text' => '',
  203. 'make_link' => 0,
  204. 'path' => '',
  205. 'absolute' => 0,
  206. 'link_class' => '',
  207. 'alt' => '',
  208. 'rel' => '',
  209. 'prefix' => '',
  210. 'suffix' => '',
  211. 'target' => '',
  212. 'help' => '',
  213. 'trim' => 0,
  214. 'max_length' => '',
  215. 'word_boundary' => 1,
  216. 'ellipsis' => 1,
  217. 'html' => 0,
  218. 'strip_tags' => 0,
  219. ),
  220. 'empty' => '',
  221. 'hide_empty' => 0,
  222. 'empty_zero' => 0,
  223. 'hide_alter_empty' => 1,
  224. 'type' => 'separator',
  225. 'separator' => ', ',
  226. 'exclude' => 0,
  227. 'id' => 'name_3',
  228. 'table' => 'cvterm',
  229. 'field' => 'name',
  230. 'relationship' => 'cvalue_id',
  231. ),
  232. 'value' => array(
  233. 'label' => 'Value',
  234. 'alter' => array(
  235. 'alter_text' => 0,
  236. 'text' => '',
  237. 'make_link' => 0,
  238. 'path' => '',
  239. 'absolute' => 0,
  240. 'link_class' => '',
  241. 'alt' => '',
  242. 'rel' => '',
  243. 'prefix' => '',
  244. 'suffix' => '',
  245. 'target' => '',
  246. 'help' => '',
  247. 'trim' => 0,
  248. 'max_length' => '',
  249. 'word_boundary' => 1,
  250. 'ellipsis' => 1,
  251. 'html' => 0,
  252. 'strip_tags' => 0,
  253. ),
  254. 'empty' => '',
  255. 'hide_empty' => 0,
  256. 'empty_zero' => 0,
  257. 'hide_alter_empty' => 1,
  258. 'type' => 'separator',
  259. 'separator' => ', ',
  260. 'exclude' => 0,
  261. 'id' => 'value',
  262. 'table' => 'phenotype',
  263. 'field' => 'value',
  264. 'relationship' => 'none',
  265. ),
  266. 'name_2' => array(
  267. 'label' => 'Observation Type',
  268. 'alter' => array(
  269. 'alter_text' => 0,
  270. 'text' => '',
  271. 'make_link' => 0,
  272. 'path' => '',
  273. 'absolute' => 0,
  274. 'link_class' => '',
  275. 'alt' => '',
  276. 'rel' => '',
  277. 'prefix' => '',
  278. 'suffix' => '',
  279. 'target' => '',
  280. 'help' => '',
  281. 'trim' => 0,
  282. 'max_length' => '',
  283. 'word_boundary' => 1,
  284. 'ellipsis' => 1,
  285. 'html' => 0,
  286. 'strip_tags' => 0,
  287. ),
  288. 'empty' => '',
  289. 'hide_empty' => 0,
  290. 'empty_zero' => 0,
  291. 'hide_alter_empty' => 1,
  292. 'type' => 'separator',
  293. 'separator' => ', ',
  294. 'exclude' => 0,
  295. 'id' => 'name_2',
  296. 'table' => 'cvterm',
  297. 'field' => 'name',
  298. 'relationship' => 'observable_id',
  299. ),
  300. 'name' => array(
  301. 'label' => 'Evidence Type',
  302. 'alter' => array(
  303. 'alter_text' => 0,
  304. 'text' => '',
  305. 'make_link' => 0,
  306. 'path' => '',
  307. 'absolute' => 0,
  308. 'link_class' => '',
  309. 'alt' => '',
  310. 'rel' => '',
  311. 'prefix' => '',
  312. 'suffix' => '',
  313. 'target' => '',
  314. 'help' => '',
  315. 'trim' => 0,
  316. 'max_length' => '',
  317. 'word_boundary' => 1,
  318. 'ellipsis' => 1,
  319. 'html' => 0,
  320. 'strip_tags' => 0,
  321. ),
  322. 'empty' => '',
  323. 'hide_empty' => 0,
  324. 'empty_zero' => 0,
  325. 'hide_alter_empty' => 1,
  326. 'type' => 'separator',
  327. 'separator' => ', ',
  328. 'exclude' => 0,
  329. 'id' => 'name',
  330. 'table' => 'cvterm',
  331. 'field' => 'name',
  332. 'relationship' => 'assay_id',
  333. ),
  334. ));
  335. $handler->override_option('filters', array(
  336. 'search_results' => array(
  337. 'operator' => '=',
  338. 'value' => '',
  339. 'group' => '0',
  340. 'exposed' => FALSE,
  341. 'expose' => array(
  342. 'operator' => FALSE,
  343. 'label' => '',
  344. ),
  345. 'id' => 'search_results',
  346. 'table' => 'views',
  347. 'field' => 'search_results',
  348. 'relationship' => 'none',
  349. 'apply_button' => 'Show',
  350. 'no_results_text' => 'Click "Show" to see a list of all phenotypes matching the entered criteria. If you leave a any of the criteria blank then the phenotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all phenotypes will be listed.',
  351. ),
  352. 'attr_id' => array(
  353. 'operator' => '=',
  354. 'value' => '',
  355. 'group' => '0',
  356. 'exposed' => TRUE,
  357. 'expose' => array(
  358. 'use_operator' => 0,
  359. 'operator' => 'attr_id_op',
  360. 'identifier' => 'attr_id',
  361. 'label' => 'Phenotypic Attribute',
  362. 'remember' => 0,
  363. ),
  364. 'case' => 1,
  365. 'id' => 'attr_id',
  366. 'table' => 'phenotype',
  367. 'field' => 'attr_id',
  368. 'relationship' => 'none',
  369. 'agg' => array(
  370. 'records_with' => 1,
  371. 'aggregates_with' => 1,
  372. ),
  373. 'values_form_type' => 'select',
  374. 'multiple' => 1,
  375. 'optional' => 0,
  376. 'show_all' => 0,
  377. ),
  378. 'cvalue_id' => array(
  379. 'operator' => '=',
  380. 'value' => '',
  381. 'group' => '0',
  382. 'exposed' => TRUE,
  383. 'expose' => array(
  384. 'use_operator' => 0,
  385. 'operator' => 'cvalue_id_op',
  386. 'identifier' => 'cvalue_id',
  387. 'label' => 'Controlled Value',
  388. 'remember' => 0,
  389. ),
  390. 'case' => 1,
  391. 'id' => 'cvalue_id',
  392. 'table' => 'phenotype',
  393. 'field' => 'cvalue_id',
  394. 'relationship' => 'none',
  395. 'agg' => array(
  396. 'records_with' => 1,
  397. 'aggregates_with' => 1,
  398. ),
  399. 'values_form_type' => 'select',
  400. 'multiple' => 1,
  401. 'optional' => 0,
  402. 'show_all' => 0,
  403. ),
  404. 'observable_id' => array(
  405. 'operator' => '=',
  406. 'value' => '',
  407. 'group' => '0',
  408. 'exposed' => TRUE,
  409. 'expose' => array(
  410. 'use_operator' => 0,
  411. 'operator' => 'observable_id_op',
  412. 'identifier' => 'observable_id',
  413. 'label' => 'Observation Type',
  414. 'remember' => 0,
  415. ),
  416. 'case' => 1,
  417. 'id' => 'observable_id',
  418. 'table' => 'phenotype',
  419. 'field' => 'observable_id',
  420. 'relationship' => 'none',
  421. 'agg' => array(
  422. 'records_with' => 1,
  423. 'aggregates_with' => 1,
  424. ),
  425. 'values_form_type' => 'select',
  426. 'multiple' => 1,
  427. 'optional' => 0,
  428. 'show_all' => 0,
  429. ),
  430. 'assay_id' => array(
  431. 'operator' => '=',
  432. 'value' => '',
  433. 'group' => '0',
  434. 'exposed' => TRUE,
  435. 'expose' => array(
  436. 'use_operator' => 0,
  437. 'operator' => 'assay_id_op',
  438. 'identifier' => 'assay_id',
  439. 'label' => 'Evidence Type',
  440. 'remember' => 0,
  441. ),
  442. 'case' => 1,
  443. 'id' => 'assay_id',
  444. 'table' => 'phenotype',
  445. 'field' => 'assay_id',
  446. 'relationship' => 'none',
  447. 'agg' => array(
  448. 'records_with' => 1,
  449. 'aggregates_with' => 1,
  450. ),
  451. 'values_form_type' => 'select',
  452. 'multiple' => 1,
  453. 'optional' => 0,
  454. 'show_all' => 0,
  455. ),
  456. 'uniquename' => array(
  457. 'operator' => 'contains',
  458. 'value' => '',
  459. 'group' => '0',
  460. 'exposed' => TRUE,
  461. 'expose' => array(
  462. 'use_operator' => 0,
  463. 'operator' => 'uniquename_op',
  464. 'identifier' => 'uniquename',
  465. 'label' => 'Unique Name Contains',
  466. 'remember' => 0,
  467. ),
  468. 'case' => 0,
  469. 'id' => 'uniquename',
  470. 'table' => 'phenotype',
  471. 'field' => 'uniquename',
  472. 'relationship' => 'none',
  473. 'agg' => array(
  474. 'records_with' => 1,
  475. 'aggregates_with' => 1,
  476. ),
  477. ),
  478. 'value' => array(
  479. 'operator' => 'contains',
  480. 'value' => '',
  481. 'group' => '0',
  482. 'exposed' => TRUE,
  483. 'expose' => array(
  484. 'use_operator' => 0,
  485. 'operator' => 'value_op',
  486. 'identifier' => 'phen_value',
  487. 'label' => 'Value Contains',
  488. 'remember' => 0,
  489. ),
  490. 'case' => 0,
  491. 'id' => 'value',
  492. 'table' => 'phenotype',
  493. 'field' => 'value',
  494. 'relationship' => 'none',
  495. 'agg' => array(
  496. 'records_with' => 1,
  497. 'aggregates_with' => 1,
  498. ),
  499. ),
  500. ));
  501. $handler->override_option('access', array(
  502. 'type' => 'perm',
  503. 'perm' => 'access content',
  504. ));
  505. $handler->override_option('cache', array(
  506. 'type' => 'none',
  507. ));
  508. $handler->override_option('title', 'Phenotypes');
  509. $handler->override_option('header', 'Click "Show" to see a list of all phenotypes matching the entered criteria. If you leave a any of the criteria blank then the phenotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all phenotypes will be listed.');
  510. $handler->override_option('header_format', '2');
  511. $handler->override_option('header_empty', 0);
  512. $handler->override_option('empty', 'No phenotypes match the supplied criteria.');
  513. $handler->override_option('empty_format', '2');
  514. $handler->override_option('items_per_page', 50);
  515. $handler->override_option('use_pager', '1');
  516. $handler->override_option('style_plugin', 'table');
  517. $handler->override_option('style_options', array(
  518. 'grouping' => '',
  519. 'override' => 1,
  520. 'sticky' => 0,
  521. 'order' => 'asc',
  522. 'summary' => '',
  523. 'columns' => array(
  524. 'uniquename' => 'uniquename',
  525. 'value' => 'value',
  526. ),
  527. 'info' => array(
  528. 'uniquename' => array(
  529. 'sortable' => 1,
  530. 'separator' => '',
  531. ),
  532. 'value' => array(
  533. 'sortable' => 1,
  534. 'separator' => '',
  535. ),
  536. ),
  537. 'default' => 'uniquename',
  538. ));
  539. $handler = $view->new_display('page', 'Page', 'page_1');
  540. $handler->override_option('path', 'chado/phenotypes');
  541. $handler->override_option('menu', array(
  542. 'type' => 'normal',
  543. 'title' => 'Phenotypes',
  544. 'description' => 'A phenotypic statement, or a single atomic phenotypic observation, is a controlled sentence describing observable effects of non-wild type function.',
  545. 'weight' => '10',
  546. 'name' => 'navigation',
  547. ));
  548. $handler->override_option('tab_options', array(
  549. 'type' => 'none',
  550. 'title' => '',
  551. 'description' => '',
  552. 'weight' => 0,
  553. 'name' => 'navigation',
  554. ));
  555. $views[$view->name] = $view;
  556. return $views;
  557. }