Tripal v1.0 (6.x-1.0)
tripal_feature.views.inc
Go to the documentation of this file.
00001 <?php
00002 
00031 function tripal_feature_views_data()  {
00032   $data = array();
00033 
00034   if (module_exists('tripal_views')) {
00035     $tables = array(
00036       'feature',
00037     );
00038 
00039     foreach ($tables as $tablename) {
00040       $priority = 9;
00041 
00042       // check to see if the table is integrated. If it is then integrate it's
00043       // corresponding 'chado_[table]' table.
00044       if (!tripal_views_is_integrated($tablename, $priority)) {
00045         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
00046 
00047         // Add in node relationships if chado is in the same db as drupal
00048         if (tripal_core_chado_schema_exists()) {
00049           $integrations = tripal_views_add_node_relationship_to_chado_table_integration($table_integration_array);
00050           foreach ($integrations as $integration) {
00051             tripal_views_integration_add_entry($integration);
00052           }
00053         }
00054         else {
00055           tripal_views_integration_add_entry($table_integration_array);
00056         }
00057 
00058       }
00059     }
00060 
00061     $tables = array(
00062       'feature_cvterm',
00063       'feature_cvterm_dbxref',
00064       'feature_cvterm_pub',
00065       'feature_cvtermprop',
00066       'feature_dbxref',
00067       'feature_pub',
00068       'feature_pubprop',
00069       'feature_relationship',
00070       'feature_relationship_pub',
00071       'feature_relationshipprop',
00072       'feature_relationshipprop_pub',
00073       'feature_synonym',
00074       'featureloc',
00075       'featureloc_pub',
00076       'featureprop',
00077       'featureprop_pub',
00078       'featuremap',
00079       'featuremap_pub',
00080       'featurepos',
00081       'featurerange'
00082     );
00083     foreach ($tables as $tablename) {
00084       $priority = 9;
00085       if (!tripal_views_is_integrated($tablename, $priority)) {
00086         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
00087         tripal_views_integration_add_entry($table_integration_array);
00088       }
00089     }
00090   }
00091 
00092   return $data;
00093 }
00094 
00106 function tripal_feature_views_handlers() {
00107   return array(
00108     'info' => array(
00109       'path' => drupal_get_path('module', 'tripal_feature') . '/views_handlers',
00110     ),
00111     'handlers' => array(
00112     'views_handler_field_residues' => array(
00113       'parent' => 'views_handler_field',
00114     ),
00115     ),
00116   );
00117 }
00118 
00122 function tripal_feature_views_data_alter(&$data) {
00123 
00124   if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
00125 
00126     // Add featuer relationship to node
00127     $data['node']['feature_chado_nid'] = array(
00128       'group' => 'Feature',
00129       'title' => 'Feature Node',
00130       'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
00131       'real field' => 'nid',
00132       'relationship' => array(
00133         'handler' => 'views_handler_relationship',
00134         'title' => t('Node => Chado'),
00135         'label' => t('Node => Chado'),
00136         'real field' => 'nid',
00137         'base' => 'chado_feature',
00138         'base field' => 'nid'
00139       ),
00140     );
00141   }
00142 
00143 }
00144 
00149 function tripal_feature_views_default_views() {
00150   $views = array();
00151 
00152   if (!module_exists('tripal_views')) {
00153     return $views;
00154   }
00155 
00156   // Main default view
00157   $view = new view;
00158   $view->name = 'feature_listing';
00159   $view->description = 'A listing of chado sequence features.';
00160   $view->tag = 'chado default';
00161   $view->base_table = 'feature';
00162   $view->core = 0;
00163   $view->api_version = '2';
00164   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
00165   $handler = $view->new_display('default', 'features_all', 'default');
00166   $handler->override_option('fields', array(
00167     'uniquename' => array(
00168       'label' => 'Unique Name',
00169       'alter' => array(
00170         'alter_text' => 0,
00171         'text' => '',
00172         'make_link' => 0,
00173         'path' => 'node/[nid]',
00174         'link_class' => '',
00175         'alt' => '',
00176         'prefix' => '',
00177         'suffix' => '',
00178         'target' => '',
00179         'help' => '',
00180         'trim' => 0,
00181         'max_length' => '',
00182         'word_boundary' => 1,
00183         'ellipsis' => 1,
00184         'html' => 0,
00185         'strip_tags' => 0,
00186       ),
00187       'empty' => '',
00188       'hide_empty' => 0,
00189       'empty_zero' => 0,
00190       'link_to_node' => 0,
00191       'exclude' => 0,
00192       'id' => 'uniquename',
00193       'table' => 'feature',
00194       'field' => 'uniquename',
00195       'relationship' => 'none',
00196       'override' => array(
00197         'button' => 'Override',
00198       ),
00199     ),
00200     'name' => array(
00201       'label' => 'Name',
00202       'alter' => array(
00203         'alter_text' => 0,
00204         'text' => '',
00205         'make_link' => 0,
00206         'path' => '',
00207         'link_class' => '',
00208         'alt' => '',
00209         'prefix' => '',
00210         'suffix' => '',
00211         'target' => '',
00212         'help' => '',
00213         'trim' => 0,
00214         'max_length' => '',
00215         'word_boundary' => 1,
00216         'ellipsis' => 1,
00217         'html' => 0,
00218         'strip_tags' => 0,
00219       ),
00220       'empty' => '',
00221       'hide_empty' => 0,
00222       'empty_zero' => 0,
00223       'link_to_node' => 1,
00224       'exclude' => 0,
00225       'id' => 'name',
00226       'table' => 'feature',
00227       'field' => 'name',
00228       'relationship' => 'none',
00229       'override' => array(
00230         'button' => 'Override',
00231       ),
00232     ),
00233     'name_1' => array(
00234       'label' => 'Type',
00235       'alter' => array(
00236         'alter_text' => 0,
00237         'text' => '',
00238         'make_link' => 0,
00239         'path' => '',
00240         'link_class' => '',
00241         'alt' => '',
00242         'prefix' => '',
00243         'suffix' => '',
00244         'target' => '',
00245         'help' => '',
00246         'trim' => 0,
00247         'max_length' => '',
00248         'word_boundary' => 1,
00249         'ellipsis' => 1,
00250         'html' => 0,
00251         'strip_tags' => 0,
00252       ),
00253       'empty' => '',
00254       'hide_empty' => 0,
00255       'empty_zero' => 0,
00256       'exclude' => 0,
00257       'id' => 'name_1',
00258       'table' => 'cvterm',
00259       'field' => 'name',
00260       'relationship' => 'none',
00261     ),
00262     'common_name' => array(
00263       'label' => 'Common Name',
00264       'alter' => array(
00265         'alter_text' => 0,
00266         'text' => '',
00267         'make_link' => 0,
00268         'path' => '',
00269         'link_class' => '',
00270         'alt' => '',
00271         'prefix' => '',
00272         'suffix' => '',
00273         'target' => '',
00274         'help' => '',
00275         'trim' => 0,
00276         'max_length' => '',
00277         'word_boundary' => 1,
00278         'ellipsis' => 1,
00279         'html' => 0,
00280         'strip_tags' => 0,
00281       ),
00282       'empty' => '',
00283       'hide_empty' => 0,
00284       'empty_zero' => 0,
00285       'link_to_node' => 1,
00286       'exclude' => 0,
00287       'id' => 'common_name',
00288       'table' => 'organism',
00289       'field' => 'common_name',
00290       'relationship' => 'none',
00291       'override' => array(
00292         'button' => 'Override',
00293       ),
00294     ),
00295     'seqlen' => array(
00296       'label' => 'Sequence Length',
00297       'alter' => array(
00298         'alter_text' => 0,
00299         'text' => '',
00300         'make_link' => 0,
00301         'path' => '',
00302         'link_class' => '',
00303         'alt' => '',
00304         'prefix' => '',
00305         'suffix' => '',
00306         'target' => '',
00307         'help' => '',
00308         'trim' => 0,
00309         'max_length' => '',
00310         'word_boundary' => 1,
00311         'ellipsis' => 1,
00312         'html' => 0,
00313         'strip_tags' => 0,
00314       ),
00315       'empty' => '',
00316       'hide_empty' => 0,
00317       'empty_zero' => 0,
00318       'set_precision' => FALSE,
00319       'precision' => 0,
00320       'decimal' => '.',
00321       'separator' => ',',
00322       'prefix' => '',
00323       'suffix' => '',
00324       'exclude' => 0,
00325       'id' => 'seqlen',
00326       'table' => 'feature',
00327       'field' => 'seqlen',
00328       'relationship' => 'none',
00329     ),
00330     'is_obsolete' => array(
00331       'label' => 'Is Obsolete',
00332       'alter' => array(
00333         'alter_text' => 0,
00334         'text' => '',
00335         'make_link' => 0,
00336         'path' => '',
00337         'absolute' => 0,
00338         'link_class' => '',
00339         'alt' => '',
00340         'rel' => '',
00341         'prefix' => '',
00342         'suffix' => '',
00343         'target' => '',
00344         'help' => '',
00345         'trim' => 0,
00346         'max_length' => '',
00347         'word_boundary' => 1,
00348         'ellipsis' => 1,
00349         'html' => 0,
00350         'strip_tags' => 0,
00351       ),
00352       'empty' => '',
00353       'hide_empty' => 0,
00354       'empty_zero' => 0,
00355       'hide_alter_empty' => 1,
00356       'type' => 'separator',
00357       'not' => 0,
00358       'separator' => ', ',
00359       'exclude' => 0,
00360       'id' => 'is_obsolete',
00361       'table' => 'feature',
00362       'field' => 'is_obsolete',
00363       'relationship' => 'none',
00364     ),
00365     'timeaccessioned' => array(
00366       'label' => 'Accessioned On',
00367       'alter' => array(
00368         'alter_text' => 0,
00369         'text' => '',
00370         'make_link' => 0,
00371         'path' => '',
00372         'absolute' => 0,
00373         'link_class' => '',
00374         'alt' => '',
00375         'rel' => '',
00376         'prefix' => '',
00377         'suffix' => '',
00378         'target' => '',
00379         'help' => '',
00380         'trim' => 0,
00381         'max_length' => '',
00382         'word_boundary' => 1,
00383         'ellipsis' => 1,
00384         'html' => 0,
00385         'strip_tags' => 0,
00386       ),
00387       'empty' => '',
00388       'hide_empty' => 0,
00389       'empty_zero' => 0,
00390       'hide_alter_empty' => 1,
00391       'date_format' => 'large',
00392       'custom_date_format' => '',
00393       'type' => 'separator',
00394       'separator' => ', ',
00395       'exclude' => 0,
00396       'id' => 'timeaccessioned',
00397       'table' => 'feature',
00398       'field' => 'timeaccessioned',
00399       'relationship' => 'none',
00400     ),
00401   ));
00402   $handler->override_option('sorts', array(
00403     'common_name' => array(
00404       'order' => 'ASC',
00405       'id' => 'common_name',
00406       'table' => 'organism',
00407       'field' => 'common_name',
00408       'relationship' => 'none',
00409     ),
00410     'name' => array(
00411       'order' => 'ASC',
00412       'id' => 'name',
00413       'table' => 'cvterm',
00414       'field' => 'name',
00415       'relationship' => 'none',
00416     ),
00417     'name_1' => array(
00418       'order' => 'ASC',
00419       'id' => 'name_1',
00420       'table' => 'feature',
00421       'field' => 'name',
00422       'relationship' => 'none',
00423     ),
00424   ));
00425   $handler->override_option('filters', array(
00426     'common_name' => array(
00427       'operator' => '=',
00428       'value' => array(),
00429       'group' => '0',
00430       'exposed' => TRUE,
00431       'expose' => array(
00432         'use_operator' => 0,
00433         'operator' => 'common_name_op',
00434         'identifier' => 'organism',
00435         'label' => 'Organism Common Name',
00436         'remember' => 0,
00437       ),
00438       'case' => 1,
00439       'id' => 'common_name',
00440       'table' => 'organism',
00441       'field' => 'common_name',
00442       'relationship' => 'none',
00443       'values_form_type' => 'select',
00444       'multiple' => 1,
00445       'optional' => 0,
00446       'override' => array(
00447         'button' => 'Override',
00448       ),
00449       'agg' => array(
00450         'records_with' => 1,
00451         'aggregates_with' => 1,
00452       ),
00453     ),
00454     'type_id' => array(
00455       'operator' => '=',
00456       'value' => array(),
00457       'group' => '0',
00458       'exposed' => TRUE,
00459       'expose' => array(
00460         'use_operator' => 0,
00461         'operator' => 'type_id_op',
00462         'identifier' => 'type_id',
00463         'label' => 'Type',
00464         'remember' => 0,
00465       ),
00466       'case' => 1,
00467       'id' => 'type_id',
00468       'table' => 'feature',
00469       'field' => 'type_id',
00470       'relationship' => 'none',
00471       'values_form_type' => 'select',
00472       'multiple' => 1,
00473       'optional' => 0,
00474       'show_all' => 0,
00475       'agg' => array(
00476         'records_with' => 1,
00477         'aggregates_with' => 1,
00478       ),
00479     ),
00480     'name_1' => array(
00481       'operator' => 'allwords',
00482       'value' => '',
00483       'group' => '0',
00484       'exposed' => TRUE,
00485       'expose' => array(
00486         'use_operator' => 0,
00487         'operator' => 'name_1_op',
00488         'identifier' => 'name',
00489         'label' => 'Name Contains',
00490         'bef_filter_description' => '',
00491         'remember' => 0,
00492       ),
00493       'case' => 0,
00494       'id' => 'name_1',
00495       'table' => 'feature',
00496       'field' => 'name',
00497       'relationship' => 'none',
00498       'agg' => array(
00499         'records_with' => 1,
00500         'aggregates_with' => 1,
00501       ),
00502     ),
00503     'search_results' => array(
00504       'operator' => '=',
00505       'value' => '',
00506       'group' => '0',
00507       'exposed' => FALSE,
00508       'expose' => array(
00509         'operator' => FALSE,
00510         'label' => '',
00511       ),
00512       'id' => 'search_results',
00513       'table' => 'views',
00514       'field' => 'search_results',
00515       'relationship' => 'none',
00516       'apply_button' => 'Show',
00517       'no_results_text' => 'Click "Show" to see a list of all features matching the entered criteria. If you leave a any of the criteria blank then the features will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all features will be listed.',
00518     ),
00519   ));
00520   $handler->override_option('access', array(
00521     'type' => 'perm',
00522     'perm' => 'access chado_feature content',
00523   ));
00524   $handler->override_option('cache', array(
00525     'type' => 'none',
00526   ));
00527   $handler->override_option('title', 'Sequence Features');
00528   $handler->override_option('header', 'Click "Show" to see a list of all features matching the entered criteria. If you leave a any of the criteria blank then the features will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all features will be listed.');
00529   $handler->override_option('header_format', '2');
00530   $handler->override_option('header_empty', 0);
00531   $handler->override_option('empty', 'No features matched the supplied criteria.');
00532   $handler->override_option('empty_format', '2');
00533   $handler->override_option('items_per_page', 50);
00534   $handler->override_option('use_pager', '1');
00535   $handler->override_option('style_plugin', 'table');
00536   $handler->override_option('style_options', array(
00537     'grouping' => '',
00538     'override' => 1,
00539     'sticky' => 0,
00540     'order' => 'asc',
00541     'columns' => array(
00542       'accession' => 'accession',
00543       'accession_link' => 'accession_link',
00544       'name' => 'name',
00545       'uniquename' => 'uniquename',
00546       'name_1' => 'name_1',
00547       'common_name' => 'common_name',
00548       'seqlen' => 'seqlen',
00549       'is_obsolete' => 'is_obsolete',
00550       'is_analysis' => 'is_analysis',
00551       'nid' => 'nid',
00552     ),
00553     'info' => array(
00554       'accession' => array(
00555         'sortable' => 1,
00556         'separator' => '',
00557       ),
00558       'accession_link' => array(
00559         'sortable' => 1,
00560         'separator' => '',
00561       ),
00562       'name' => array(
00563         'sortable' => 1,
00564         'separator' => '',
00565       ),
00566       'uniquename' => array(
00567         'sortable' => 1,
00568         'separator' => '',
00569       ),
00570       'name_1' => array(
00571         'sortable' => 1,
00572         'separator' => '',
00573       ),
00574       'common_name' => array(
00575         'sortable' => 1,
00576         'separator' => '',
00577       ),
00578       'seqlen' => array(
00579         'sortable' => 1,
00580         'separator' => '',
00581       ),
00582       'is_obsolete' => array(
00583         'sortable' => 1,
00584         'separator' => '',
00585       ),
00586       'is_analysis' => array(
00587         'sortable' => 1,
00588         'separator' => '',
00589       ),
00590       'nid' => array(
00591         'separator' => '',
00592       ),
00593     ),
00594     'default' => '-1',
00595   ));
00596   $default_handler = $handler;
00597   $handler = $view->new_display('page', 'Page', 'page_1');
00598   $handler->override_option('path', 'chado/features');
00599   $handler->override_option('menu', array(
00600     'type' => 'normal',
00601     'title' => 'Features',
00602     'description' => 'A feature is a biological sequence or a section of a biological sequence, or a collection of such sections. Examples include genes, exons, transcripts, regulatory regions, polypeptides, protein domains, chromosome sequences, sequence variations, cross-genome match regions such as hits and HSPs and so on.',
00603     'weight' => '10',
00604     'name' => 'navigation',
00605   ));
00606   $handler->override_option('tab_options', array(
00607     'type' => 'none',
00608     'title' => '',
00609     'description' => '',
00610     'weight' => 0,
00611     'name' => 'navigation',
00612   ));
00613   // Add code specific to a local chado installation
00614   // NOTE: Edit $handler above to $default_handler for the default display
00615   if (tripal_core_chado_schema_exists()) {
00616     // Add nid field
00617     $fields = $view->get_items('field', 'default');
00618     $new_fields = array(
00619       'nid' => array(
00620         'label' => 'Nid',
00621         'alter' => array(
00622           'alter_text' => 0,
00623           'text' => '',
00624           'make_link' => 0,
00625           'path' => '',
00626           'absolute' => 0,
00627           'link_class' => '',
00628           'alt' => '',
00629           'rel' => '',
00630           'prefix' => '',
00631           'suffix' => '',
00632           'target' => '',
00633           'help' => '',
00634           'trim' => 0,
00635           'max_length' => '',
00636           'word_boundary' => 1,
00637           'ellipsis' => 1,
00638           'html' => 0,
00639           'strip_tags' => 0,
00640         ),
00641         'empty' => '',
00642         'hide_empty' => 0,
00643         'empty_zero' => 0,
00644         'hide_alter_empty' => 1,
00645         'link_to_node' => 0,
00646         'exclude' => 1,
00647         'id' => 'nid',
00648         'table' => 'node',
00649         'field' => 'nid',
00650         'relationship' => 'none',
00651       )
00652     );
00653     $fields = $new_fields + $fields;
00654     // Adds feature => Node relationship
00655     $default_handler->override_option('relationships', array(
00656       'nid' => array(
00657         'label' => 'Feature to Node',
00658         'required' => 0,
00659         'id' => 'nid',
00660         'table' => 'chado_feature',
00661         'field' => 'nid',
00662         'relationship' => 'none',
00663       ),
00664     ));
00665     // Change analysis.name to have a link to the node
00666     $fields['name']['alter']['link_to_node'] = 1;
00667     $default_handler->override_option('fields', $fields);
00668     // Only show records with published nodes
00687   }
00688   $views[$view->name] = $view;
00689 
00690   return $views;
00691 }
 All Classes Files Functions Variables