Tripal v1.0 (6.x-1.0)
tripal_phenotype.views.inc
Go to the documentation of this file.
00001 <?php
00002 
00018 /*************************************************************************
00019  * Implements hook_views_data()
00020  * Purpose: Describe chado/tripal tables & fields to views
00021  *
00022  * @return: a data array which follows the structure outlined in the
00023  *   views2 documentation for this hook. Essentially, it's an array of table
00024  *   definitions keyed by chado/tripal table name. Each table definition
00025  *   includes basic details about the table, fields in that table and
00026  *   relationships between that table and others (joins)
00027  */
00028 function tripal_phenotype_views_data()  {
00029   $data = array();
00030 
00031   if (module_exists('tripal_views')) {
00032     $tables = array(
00033       'phenotype'
00034     );
00035     foreach ($tables as $tablename) {
00036       $priority = 9;
00037 
00038       // check to see if the table is integrated. If it is then integrate it's
00039       // corresponding 'chado_[table]' table.
00040       if (!tripal_views_is_integrated($tablename, $priority)) {
00041         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
00042 
00043         // Add specialty handlers
00044         switch ($tablename) {
00045           case 'phenotype':
00046             $table_integration_array['fields']['attr_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
00047             $table_integration_array['fields']['assay_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
00048             $table_integration_array['fields']['cvalue_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
00049             $table_integration_array['fields']['observable_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
00050             break;
00051         }
00052 
00053         tripal_views_integration_add_entry($table_integration_array);
00054       }
00055     }
00056 
00057     $tables = array(
00058       'feature_phenotype',
00059       'phenotype_cvterm'
00060     );
00061     foreach ($tables as $tablename) {
00062       $priority = 9;
00063       if (!tripal_views_is_integrated($tablename, $priority)) {
00064         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
00065         tripal_views_integration_add_entry($table_integration_array);
00066       }
00067     }
00068   }
00069 
00070   return $data;
00071 }
00072 
00073 /*************************************************************************
00074  * Implements hook_views_handlers()
00075  * Purpose: Register all custom handlers with views
00076  *   where a handler describes either "the type of field",
00077  *   "how a field should be filtered", "how a field should be sorted"
00078  *
00079  * @return: An array of handler definitions
00080  */
00081 function tripal_phenotype_views_handlers() {
00082   return array(
00083    'info' => array(
00084      'path' => drupal_get_path('module', 'tripal_phenotype') . '/views/handlers',
00085   ),
00086    'handlers' => array(
00087 
00088   ),
00089   );
00090 }
00091 
00096 function tripal_phenotype_views_default_views() {
00097   $views = array();
00098 
00099   if (!module_exists('tripal_views')) {
00100     return $views;
00101   }
00102 
00103   // Main default view
00104   $view = new view;
00105   $view->name = 'phenotype_listing';
00106   $view->description = 'A listing of chado phenotypes';
00107   $view->tag = 'chado default';
00108   $view->base_table = 'phenotype';
00109   $view->core = 6;
00110   $view->api_version = '2';
00111   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
00112   $handler = $view->new_display('default', 'Defaults', 'default');
00113   $handler->override_option('relationships', array(
00114     'assay_id' => array(
00115       'label' => 'assay_id to cvterm',
00116       'required' => 0,
00117       'id' => 'assay_id',
00118       'table' => 'phenotype',
00119       'field' => 'assay_id',
00120       'relationship' => 'none',
00121     ),
00122     'attr_id' => array(
00123       'label' => 'attr_id to cvterm',
00124       'required' => 0,
00125       'id' => 'attr_id',
00126       'table' => 'phenotype',
00127       'field' => 'attr_id',
00128       'relationship' => 'none',
00129     ),
00130     'cvalue_id' => array(
00131       'label' => 'cvalue_id to cvterm',
00132       'required' => 0,
00133       'id' => 'cvalue_id',
00134       'table' => 'phenotype',
00135       'field' => 'cvalue_id',
00136       'relationship' => 'none',
00137     ),
00138     'observable_id' => array(
00139       'label' => 'observable_id to cvterm',
00140       'required' => 0,
00141       'id' => 'observable_id',
00142       'table' => 'phenotype',
00143       'field' => 'observable_id',
00144       'relationship' => 'none',
00145     ),
00146   ));
00147   $handler->override_option('fields', array(
00148     'uniquename' => array(
00149       'label' => 'Unique Name',
00150       'alter' => array(
00151         'alter_text' => 0,
00152         'text' => '',
00153         'make_link' => 0,
00154         'path' => '',
00155         'absolute' => 0,
00156         'link_class' => '',
00157         'alt' => '',
00158         'rel' => '',
00159         'prefix' => '',
00160         'suffix' => '',
00161         'target' => '',
00162         'help' => '',
00163         'trim' => 0,
00164         'max_length' => '',
00165         'word_boundary' => 1,
00166         'ellipsis' => 1,
00167         'html' => 0,
00168         'strip_tags' => 0,
00169       ),
00170       'empty' => '',
00171       'hide_empty' => 0,
00172       'empty_zero' => 0,
00173       'hide_alter_empty' => 1,
00174       'type' => 'separator',
00175       'separator' => ', ',
00176       'exclude' => 0,
00177       'id' => 'uniquename',
00178       'table' => 'phenotype',
00179       'field' => 'uniquename',
00180       'relationship' => 'none',
00181     ),
00182     'name_1' => array(
00183       'label' => 'Phenotypic Attribute',
00184       'alter' => array(
00185         'alter_text' => 0,
00186         'text' => '',
00187         'make_link' => 0,
00188         'path' => '',
00189         'absolute' => 0,
00190         'link_class' => '',
00191         'alt' => '',
00192         'rel' => '',
00193         'prefix' => '',
00194         'suffix' => '',
00195         'target' => '',
00196         'help' => '',
00197         'trim' => 0,
00198         'max_length' => '',
00199         'word_boundary' => 1,
00200         'ellipsis' => 1,
00201         'html' => 0,
00202         'strip_tags' => 0,
00203       ),
00204       'empty' => '',
00205       'hide_empty' => 0,
00206       'empty_zero' => 0,
00207       'hide_alter_empty' => 1,
00208       'type' => 'separator',
00209       'separator' => ', ',
00210       'exclude' => 0,
00211       'id' => 'name_1',
00212       'table' => 'cvterm',
00213       'field' => 'name',
00214       'relationship' => 'attr_id',
00215     ),
00216     'name_3' => array(
00217       'label' => 'Controlled Value',
00218       'alter' => array(
00219         'alter_text' => 0,
00220         'text' => '',
00221         'make_link' => 0,
00222         'path' => '',
00223         'absolute' => 0,
00224         'link_class' => '',
00225         'alt' => '',
00226         'rel' => '',
00227         'prefix' => '',
00228         'suffix' => '',
00229         'target' => '',
00230         'help' => '',
00231         'trim' => 0,
00232         'max_length' => '',
00233         'word_boundary' => 1,
00234         'ellipsis' => 1,
00235         'html' => 0,
00236         'strip_tags' => 0,
00237       ),
00238       'empty' => '',
00239       'hide_empty' => 0,
00240       'empty_zero' => 0,
00241       'hide_alter_empty' => 1,
00242       'type' => 'separator',
00243       'separator' => ', ',
00244       'exclude' => 0,
00245       'id' => 'name_3',
00246       'table' => 'cvterm',
00247       'field' => 'name',
00248       'relationship' => 'cvalue_id',
00249     ),
00250     'value' => array(
00251       'label' => 'Value',
00252       'alter' => array(
00253         'alter_text' => 0,
00254         'text' => '',
00255         'make_link' => 0,
00256         'path' => '',
00257         'absolute' => 0,
00258         'link_class' => '',
00259         'alt' => '',
00260         'rel' => '',
00261         'prefix' => '',
00262         'suffix' => '',
00263         'target' => '',
00264         'help' => '',
00265         'trim' => 0,
00266         'max_length' => '',
00267         'word_boundary' => 1,
00268         'ellipsis' => 1,
00269         'html' => 0,
00270         'strip_tags' => 0,
00271       ),
00272       'empty' => '',
00273       'hide_empty' => 0,
00274       'empty_zero' => 0,
00275       'hide_alter_empty' => 1,
00276       'type' => 'separator',
00277       'separator' => ', ',
00278       'exclude' => 0,
00279       'id' => 'value',
00280       'table' => 'phenotype',
00281       'field' => 'value',
00282       'relationship' => 'none',
00283     ),
00284     'name_2' => array(
00285       'label' => 'Observation Type',
00286       'alter' => array(
00287         'alter_text' => 0,
00288         'text' => '',
00289         'make_link' => 0,
00290         'path' => '',
00291         'absolute' => 0,
00292         'link_class' => '',
00293         'alt' => '',
00294         'rel' => '',
00295         'prefix' => '',
00296         'suffix' => '',
00297         'target' => '',
00298         'help' => '',
00299         'trim' => 0,
00300         'max_length' => '',
00301         'word_boundary' => 1,
00302         'ellipsis' => 1,
00303         'html' => 0,
00304         'strip_tags' => 0,
00305       ),
00306       'empty' => '',
00307       'hide_empty' => 0,
00308       'empty_zero' => 0,
00309       'hide_alter_empty' => 1,
00310       'type' => 'separator',
00311       'separator' => ', ',
00312       'exclude' => 0,
00313       'id' => 'name_2',
00314       'table' => 'cvterm',
00315       'field' => 'name',
00316       'relationship' => 'observable_id',
00317     ),
00318     'name' => array(
00319       'label' => 'Evidence Type',
00320       'alter' => array(
00321         'alter_text' => 0,
00322         'text' => '',
00323         'make_link' => 0,
00324         'path' => '',
00325         'absolute' => 0,
00326         'link_class' => '',
00327         'alt' => '',
00328         'rel' => '',
00329         'prefix' => '',
00330         'suffix' => '',
00331         'target' => '',
00332         'help' => '',
00333         'trim' => 0,
00334         'max_length' => '',
00335         'word_boundary' => 1,
00336         'ellipsis' => 1,
00337         'html' => 0,
00338         'strip_tags' => 0,
00339       ),
00340       'empty' => '',
00341       'hide_empty' => 0,
00342       'empty_zero' => 0,
00343       'hide_alter_empty' => 1,
00344       'type' => 'separator',
00345       'separator' => ', ',
00346       'exclude' => 0,
00347       'id' => 'name',
00348       'table' => 'cvterm',
00349       'field' => 'name',
00350       'relationship' => 'assay_id',
00351     ),
00352   ));
00353   $handler->override_option('filters', array(
00354     'search_results' => array(
00355       'operator' => '=',
00356       'value' => '',
00357       'group' => '0',
00358       'exposed' => FALSE,
00359       'expose' => array(
00360         'operator' => FALSE,
00361         'label' => '',
00362       ),
00363       'id' => 'search_results',
00364       'table' => 'views',
00365       'field' => 'search_results',
00366       'relationship' => 'none',
00367       'apply_button' => 'Show',
00368       '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.',
00369     ),
00370     'attr_id' => array(
00371       'operator' => '=',
00372       'value' => '',
00373       'group' => '0',
00374       'exposed' => TRUE,
00375       'expose' => array(
00376         'use_operator' => 0,
00377         'operator' => 'attr_id_op',
00378         'identifier' => 'attr_id',
00379         'label' => 'Phenotypic Attribute',
00380         'remember' => 0,
00381       ),
00382       'case' => 1,
00383       'id' => 'attr_id',
00384       'table' => 'phenotype',
00385       'field' => 'attr_id',
00386       'relationship' => 'none',
00387       'agg' => array(
00388         'records_with' => 1,
00389         'aggregates_with' => 1,
00390       ),
00391       'values_form_type' => 'select',
00392       'multiple' => 1,
00393       'optional' => 0,
00394       'show_all' => 0,
00395     ),
00396     'cvalue_id' => array(
00397       'operator' => '=',
00398       'value' => '',
00399       'group' => '0',
00400       'exposed' => TRUE,
00401       'expose' => array(
00402         'use_operator' => 0,
00403         'operator' => 'cvalue_id_op',
00404         'identifier' => 'cvalue_id',
00405         'label' => 'Controlled Value',
00406         'remember' => 0,
00407       ),
00408       'case' => 1,
00409       'id' => 'cvalue_id',
00410       'table' => 'phenotype',
00411       'field' => 'cvalue_id',
00412       'relationship' => 'none',
00413       'agg' => array(
00414         'records_with' => 1,
00415         'aggregates_with' => 1,
00416       ),
00417       'values_form_type' => 'select',
00418       'multiple' => 1,
00419       'optional' => 0,
00420       'show_all' => 0,
00421     ),
00422     'observable_id' => array(
00423       'operator' => '=',
00424       'value' => '',
00425       'group' => '0',
00426       'exposed' => TRUE,
00427       'expose' => array(
00428         'use_operator' => 0,
00429         'operator' => 'observable_id_op',
00430         'identifier' => 'observable_id',
00431         'label' => 'Observation Type',
00432         'remember' => 0,
00433       ),
00434       'case' => 1,
00435       'id' => 'observable_id',
00436       'table' => 'phenotype',
00437       'field' => 'observable_id',
00438       'relationship' => 'none',
00439       'agg' => array(
00440         'records_with' => 1,
00441         'aggregates_with' => 1,
00442       ),
00443       'values_form_type' => 'select',
00444       'multiple' => 1,
00445       'optional' => 0,
00446       'show_all' => 0,
00447     ),
00448     'assay_id' => array(
00449       'operator' => '=',
00450       'value' => '',
00451       'group' => '0',
00452       'exposed' => TRUE,
00453       'expose' => array(
00454         'use_operator' => 0,
00455         'operator' => 'assay_id_op',
00456         'identifier' => 'assay_id',
00457         'label' => 'Evidence Type',
00458         'remember' => 0,
00459       ),
00460       'case' => 1,
00461       'id' => 'assay_id',
00462       'table' => 'phenotype',
00463       'field' => 'assay_id',
00464       'relationship' => 'none',
00465       'agg' => array(
00466         'records_with' => 1,
00467         'aggregates_with' => 1,
00468       ),
00469       'values_form_type' => 'select',
00470       'multiple' => 1,
00471       'optional' => 0,
00472       'show_all' => 0,
00473     ),
00474     'uniquename' => array(
00475       'operator' => '~',
00476       'value' => '',
00477       'group' => '0',
00478       'exposed' => TRUE,
00479       'expose' => array(
00480         'use_operator' => 0,
00481         'operator' => 'uniquename_op',
00482         'identifier' => 'uniquename',
00483         'label' => 'Unique Name Contains',
00484         'remember' => 0,
00485       ),
00486       'case' => 0,
00487       'id' => 'uniquename',
00488       'table' => 'phenotype',
00489       'field' => 'uniquename',
00490       'relationship' => 'none',
00491       'agg' => array(
00492         'records_with' => 1,
00493         'aggregates_with' => 1,
00494       ),
00495     ),
00496     'value' => array(
00497       'operator' => '~',
00498       'value' => '',
00499       'group' => '0',
00500       'exposed' => TRUE,
00501       'expose' => array(
00502         'use_operator' => 0,
00503         'operator' => 'value_op',
00504         'identifier' => 'phen_value',
00505         'label' => 'Value Contains',
00506         'remember' => 0,
00507       ),
00508       'case' => 0,
00509       'id' => 'value',
00510       'table' => 'phenotype',
00511       'field' => 'value',
00512       'relationship' => 'none',
00513       'agg' => array(
00514         'records_with' => 1,
00515         'aggregates_with' => 1,
00516       ),
00517     ),
00518   ));
00519   $handler->override_option('access', array(
00520     'type' => 'perm',
00521     'perm' => 'access content',
00522   ));
00523   $handler->override_option('cache', array(
00524     'type' => 'none',
00525   ));
00526   $handler->override_option('title', 'Phenotypes');
00527   $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.');
00528   $handler->override_option('header_format', '2');
00529   $handler->override_option('header_empty', 0);
00530   $handler->override_option('empty', 'No phenotypes match the supplied criteria.');
00531   $handler->override_option('empty_format', '2');
00532   $handler->override_option('items_per_page', 50);
00533   $handler->override_option('use_pager', '1');
00534   $handler->override_option('style_plugin', 'table');
00535   $handler->override_option('style_options', array(
00536     'grouping' => '',
00537     'override' => 1,
00538     'sticky' => 0,
00539     'order' => 'asc',
00540     'summary' => '',
00541     'columns' => array(
00542       'uniquename' => 'uniquename',
00543       'value' => 'value',
00544     ),
00545     'info' => array(
00546       'uniquename' => array(
00547         'sortable' => 1,
00548         'separator' => '',
00549       ),
00550       'value' => array(
00551         'sortable' => 1,
00552         'separator' => '',
00553       ),
00554     ),
00555     'default' => 'uniquename',
00556   ));
00557   $handler = $view->new_display('page', 'Page', 'page_1');
00558   $handler->override_option('path', 'chado/phenotypes');
00559   $handler->override_option('menu', array(
00560     'type' => 'normal',
00561     'title' => 'Phenotypes',
00562     'description' => 'A phenotypic statement, or a single atomic phenotypic observation, is a controlled sentence describing observable effects of non-wild type function.',
00563     'weight' => '10',
00564     'name' => 'navigation',
00565   ));
00566   $handler->override_option('tab_options', array(
00567     'type' => 'none',
00568     'title' => '',
00569     'description' => '',
00570     'weight' => 0,
00571     'name' => 'navigation',
00572   ));
00573   $views[$view->name] = $view;
00574 
00575   return $views;
00576 }
00577 
 All Classes Files Functions Variables