tripal_phenotype.views.inc 16 KB

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