From fde4d358128c91d9c4234dea59af30e93d9b2109 Mon Sep 17 00:00:00 2001 From: mboudet Date: Thu, 13 Dec 2018 13:38:10 +0000 Subject: [PATCH 1/8] Changed alias --- tripal_bipaa_ui.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tripal_bipaa_ui.install b/tripal_bipaa_ui.install index a09e739..0adc75e 100644 --- a/tripal_bipaa_ui.install +++ b/tripal_bipaa_ui.install @@ -32,9 +32,9 @@ function tripal_bipaa_ui_install() { $aliases = array( "organism" => "organism/[taxrank__genus]/[taxrank__species]", - "mRNA" => "feature/[obi__organism,TAXRANK:0000005]/[obi__organism,TAXRANK:0000006]/[rdfs__type]/[schema__name]", + "mRNA" => "feature/[obi__organism,TAXRANK:0000005]/[obi__organism,TAXRANK:0000006]/[rdfs__type]/[data__identifier]", "Analysis" => "analysis/[TripalEntity__entity_id]", - "polypeptide" => "feature/[obi__organism,TAXRANK:0000005]/[obi__organism,TAXRANK:0000006]/[rdfs__type]/[schema__name]" + "polypeptide" => "feature/[obi__organism,TAXRANK:0000005]/[obi__organism,TAXRANK:0000006]/[rdfs__type]/[data__identifier]" ); $includes = array( From 144803ade8ec39cbe5d48cf154b7eb7f5fc43d75 Mon Sep 17 00:00:00 2001 From: mboudet Date: Wed, 9 Jan 2019 14:42:53 +0000 Subject: [PATCH 2/8] Added fields for organisms --- tripal_bipaa_ui.install | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tripal_bipaa_ui.install b/tripal_bipaa_ui.install index 0adc75e..03af892 100644 --- a/tripal_bipaa_ui.install +++ b/tripal_bipaa_ui.install @@ -69,9 +69,22 @@ function tripal_bipaa_ui_install() { ), ); + $organism_field_list = array( + array( + "wrapper_name" => "Go", + "wrapper_machine_name" =>"go", + "field_machine_name" => "local__go_results", + ), + array( + "wrapper_name" => "Biomaterials", + "wrapper_machine_name" =>"biomaterials", + "field_machine_name" => "sep__biological_sample", + ) + ); + setup_fields("polypeptide", $field_list); setup_fields("mRNA", $field_list); - + setup_fields("organism", $organism_field_list); // Create a custom menu, to avoid unwanted modifications by other modules create_menu('Content Search', 'custom_search', ''); @@ -102,6 +115,7 @@ function tripal_bipaa_ui_install() { function tripal_bipaa_ui_modules_enabled($modules){ refresh_fields("polypeptide"); refresh_fields("mRNA"); + refresh_fields("organism"); drupal_flush_all_caches(); }; From a855bed6bf0951f661baa5f8160613fb20ce7356 Mon Sep 17 00:00:00 2001 From: mboudet Date: Thu, 31 Jan 2019 14:32:06 +0000 Subject: [PATCH 3/8] :( --- tripal_bipaa_ui.install | 100 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/tripal_bipaa_ui.install b/tripal_bipaa_ui.install index 03af892..55b385a 100644 --- a/tripal_bipaa_ui.install +++ b/tripal_bipaa_ui.install @@ -71,12 +71,12 @@ function tripal_bipaa_ui_install() { $organism_field_list = array( array( - "wrapper_name" => "Go", + "wrapper_name" => "GO Reports", "wrapper_machine_name" =>"go", "field_machine_name" => "local__go_results", ), array( - "wrapper_name" => "Biomaterials", + "wrapper_name" => "Biomaterial Browser", "wrapper_machine_name" =>"biomaterials", "field_machine_name" => "sep__biological_sample", ) @@ -100,6 +100,12 @@ function tripal_bipaa_ui_install() { disable_block('navigation'); disable_block('form'); + // Need to disable field_groups and their children + // Hopefully these group names are not random.. + disable_fields_groups('organism', ['Annotations', 'Cross Reference', 'Publication', 'Relationship'], True, True); + disable_fields_groups('mRNA',['Contact', 'Publication', 'Location on Map'], True, True); + disable_fields_groups('polypeptide',['Contact', 'Publication', 'Location on Map'], True, True); + //Clear cache menu_cache_clear_all(); }; @@ -185,6 +191,8 @@ function set_panel_children($bundle_name, $wrapper_name, $field_name){ function set_panels($bundle_name, $fields_list){ // Rewrited tripal_ds_update_ds_layout + // Fix was merge in tripal, so we should use the main function + $ds_identifier = 'TripalEntity|'.$bundle_name.'|default'; @@ -224,6 +232,94 @@ function set_panels($bundle_name, $fields_list){ }; }; +function disable_fields_groups($entity_name, $field_group_list=[], $use_labels=False, $disable_children=False){ + // There is no in house function to disable fields it seems.. + // Need to revert tripal_ds_update_ds_layout + // Need to get children for every field_group + + // We do not know the id of the field (random number) + // We can look into the label (which should not change..) + + $bundle_id = get_bundle_id($entity_name); + $bundle = tripal_load_bundle_entity(array('id' => $bundle_id)); + $bundle_name = $bundle->name; + + if($use_labels){ + // We need to extract the id : iterate on all field_groups for the entity and bundle + $field_group_labels = array(); + $results = db_select('field_group', 'fg') + ->fields('fg') + ->condition('bundle', $bundle_name, '=') + ->condition('entity_type', 'TripalEntity', '=') + ->execute()->fetchAll(); + if($results){ + foreach ($results as $field_group) { + $field_group_data = unserialize($field_group->data); + if(in_array($field_group_data["label"], $field_group_list)){ + $field_group_labels[] = $field_group->group_name; + } + } + } + $field_group_list= $field_group_labels; + + } + if($disable_children){ + $children = array(); + foreach($field_group_list as $field_group){ + // Get children for each field group + $field_group_id = $field_group.'|TripalEntity|'.$bundle_name.'|default'; + + $result = db_select('field_group', 'fg') + ->fields('fg', array('data')) + ->condition('fg.identifier', $field_group_id, '=') + ->execute() + ->fetchObject(); + + if($result) { + $layout_info = unserialize($result->data); + $children = array_merge($children, $layout_info["children"]); + } + } + if(!empty($children)){ + // Loop to get children of children (if existing) + disable_fields_groups($entity_name, $children, False, True); + } + $field_group_list = array_merge($field_group_list, $children); + } + + $ds_identifier = 'TripalEntity|'.$bundle_name.'|default'; + + $result = db_select('ds_layout_settings', 'ds') + ->fields('ds', array('settings')) + ->condition('ds.id', $ds_identifier, '=') + ->execute() + ->fetchObject(); + + //If the layout exists unserialize it. + if(!empty($result)) { + $layout_info = $result->settings; + $layout_info = unserialize($layout_info); + + + $region_array = array_diff($layout_info['regions']['right'], $field_group_list); + $field_array = array_diff_key($layout_info['fields'], $field_group_list); + + // Need to reindex first array + $layout_info['regions']['right'] = array_values($region_array); + $layout_info['fields'] = $field_array; + + + //Update the ds_layout_settings table with the new layout info. + db_update('ds_layout_settings') + ->fields(array( + 'settings' => serialize($layout_info), + )) + ->condition('ds_layout_settings.id', $ds_identifier, '=') + ->execute(); + }; +} + + function refresh_fields($entity_name){ $bundle_id = get_bundle_id($entity_name); $bundle = tripal_load_bundle_entity(array('id' => $bundle_id)); From 7eef58fb45c1cd1c151fc6187ed0be6be1007a37 Mon Sep 17 00:00:00 2001 From: mboudet Date: Tue, 5 Feb 2019 11:13:53 +0000 Subject: [PATCH 4/8] Cleanup fields + rewrote gene list with correct links --- tripal_bipaa_ui.install | 1 - tripal_bipaa_ui.module | 215 ++++++++++++++++++++++++++++++++-------- 2 files changed, 175 insertions(+), 41 deletions(-) diff --git a/tripal_bipaa_ui.install b/tripal_bipaa_ui.install index 55b385a..6741a11 100644 --- a/tripal_bipaa_ui.install +++ b/tripal_bipaa_ui.install @@ -28,7 +28,6 @@ function tripal_bipaa_ui_install() { // TEMP: need to setup at least an alias (temp bug fix) // https://github.com/tripal/tripal/issues/727 // Dict key needs to be in tripal_term - // Some links are malformed.. variable not set? $aliases = array( "organism" => "organism/[taxrank__genus]/[taxrank__species]", diff --git a/tripal_bipaa_ui.module b/tripal_bipaa_ui.module index f5759c4..5e89a30 100644 --- a/tripal_bipaa_ui.module +++ b/tripal_bipaa_ui.module @@ -146,45 +146,180 @@ function tripal_bipaa_ui_views_default_views_alter(&$views) { 3 => 0, ); + // Might as well not duplicate the code + $gene_handler = array( + "mRNA" => array( + "view" => $views['mRNA_search'], + "table" => 'SO__0000234' + ), + "Polypeptide" => array( + "view" => $views['Polypeptide_search'], + "table" => 'SO__0000104' + ) + ); - //mRNA - $handler = $views['mRNA_search']; - //Cleanup - unset($handler->display['default']->display_options['footer']['tripal_area_collections']); - unset($handler->display['default']->display_options['fields']['data__accession']); - unset($handler->display['default']->display_options['fields']['schema__alternate_name']); - unset($handler->display['default']->display_options['filters']['schema__name']['expose']['use_operator']); - unset($handler->display['default']->display_options['filters']['data__identifier']['expose']['use_operator']); - unset($handler->display['default']->display_options['filters']['data__accession']); - unset($handler->display['default']->display_options['filters']['obi__organism']['expose']['use_operator']); - - // Set up results without input - $handler->display['default']->display_options['exposed_form']['type'] = 'basic'; - // Change field name - $handler->display['default']->display_options['filters']['data__identifier']['expose']['label'] = 'Unique Name'; - $handler->display['default']->display_options['fields']['data__identifier']['label'] = 'Unique Name'; - - - //Polypeptide - $handler = $views['Polypeptide_search']; - //Cleanup - unset($handler->display['default']->display_options['footer']['tripal_area_collections']); - unset($handler->display['default']->display_options['fields']['data__accession']); - unset($handler->display['default']->display_options['fields']['schema__alternate_name']); - unset($handler->display['default']->display_options['filters']['schema__name']['expose']['use_operator']); - unset($handler->display['default']->display_options['filters']['data__identifier']['expose']['use_operator']); - unset($handler->display['default']->display_options['filters']['data__accession']); - unset($handler->display['default']->display_options['filters']['obi__organism']['expose']['use_operator']); - - // Set up results without input - $handler->display['default']->display_options['exposed_form']['type'] = 'basic'; - // Change field name - $handler->display['default']->display_options['filters']['data__identifier']['expose']['label'] = 'Unique Name'; - $handler->display['default']->display_options['fields']['data__identifier']['label'] = 'Unique Name'; - - - - + foreach ($gene_handler as $key => $value){ + + $handler = $value["view"]; + $table = $value["table"]; + //Cleanup + unset($handler->display['default']->display_options['footer']['tripal_area_collections']); + unset($handler->display['default']->display_options['fields']['data__accession']); + unset($handler->display['default']->display_options['fields']['schema__alternate_name']); + unset($handler->display['default']->display_options['filters']['schema__name']['expose']['use_operator']); + unset($handler->display['default']->display_options['filters']['data__identifier']['expose']['use_operator']); + unset($handler->display['default']->display_options['filters']['data__accession']); + unset($handler->display['default']->display_options['filters']['obi__organism']['expose']['use_operator']); + unset($handler->display['default']->display_options['fields']); + unset($handler->display['default']->display_options['filters']); + // Set up results without input + $handler->display['default']->display_options['exposed_form']['type'] = 'basic'; + + $handler->display['default']->display_options['style_options']['columns'] = array( + 'entity_id' => 'entity_id', + 'data__identifier' => 'data__identifier', + 'schema__name' => 'schema__name', + 'data__accession' => 'data__accession', + 'obi__organism' => 'obi__organism', + 'schema__alternate_name' => 'schema__alternate_name', + ); + $handler->display['default']->display_options['style_options']['default'] = '-1'; + $handler->display['default']->display_options['style_options']['info'] = array( + 'entity_id' => array( + 'sortable' => 1, + 'separator' => '', + ), + 'data__identifier' => array( + 'separator' => '', + 'sortable' => 1, + 'default_sort_order' => 'asc', + ), + 'schema__name' => array( + 'separator' => '', + 'sortable' => 1, + 'default_sort_order' => 'asc', + ), + 'data__accession' => array( + 'separator' => '', + 'sortable' => 1, + 'default_sort_order' => 'asc', + ), + 'obi__organism' => array( + 'separator' => '', + 'sortable' => 1, + 'default_sort_order' => 'asc', + ), + 'schema__alternate_name' => array( + 'separator' => '', + 'sortable' => 1, + 'default_sort_order' => 'asc', + ), + ); + /* Field: Entity ID */ + $handler->display['default']->display_options['fields']['entity_id']['id'] = 'entity_id'; + $handler->display['default']->display_options['fields']['entity_id']['table'] = $table; + $handler->display['default']->display_options['fields']['entity_id']['field'] = 'entity_id'; + $handler->display['default']->display_options['fields']['entity_id']['exclude'] = TRUE; + /* Field: Genus */ + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['id'] = 'obi__organism.TAXRANK:0000005'; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['table'] = $table; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['field'] = 'obi__organism.TAXRANK:0000005'; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['label'] = ''; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['exclude'] = TRUE; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000005']['element_label_colon'] = FALSE; + /* Field Species */ + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['id'] = 'obi__organism.TAXRANK:0000006'; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['table'] = $table; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['field'] = 'obi__organism.TAXRANK:0000006'; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['label'] = ''; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['exclude'] = TRUE; + $handler->display['default']->display_options['fields']['obi__organism.TAXRANK:0000006']['element_label_colon'] = FALSE; + /* Field Identifier */ + $handler->display['default']->display_options['fields']['data__identifier']['id'] = 'data__identifier'; + $handler->display['default']->display_options['fields']['data__identifier']['table'] = $table; + $handler->display['default']->display_options['fields']['data__identifier']['field'] = 'data__identifier'; + $handler->display['default']->display_options['fields']['data__identifier']['label'] = 'Unique Name'; + $handler->display['default']->display_options['fields']['data__identifier']['alter']['alter_text'] = TRUE; + $handler->display['default']->display_options['fields']['data__identifier']['alter']['text'] = '[data__identifier]'; + $handler->display['default']->display_options['fields']['data__identifier']['alter']['make_link'] = TRUE; + $handler->display['default']->display_options['fields']['data__identifier']['alter']['path'] = 'feature/[obi__organism.TAXRANK:0000005]/[obi__organism.TAXRANK:0000006]/'.$key.'/[data__identifier]'; + /* Field Name */ + $handler->display['default']->display_options['fields']['schema__name']['id'] = 'schema__name'; + $handler->display['default']->display_options['fields']['schema__name']['table'] = $table; + $handler->display['default']->display_options['fields']['schema__name']['field'] = 'schema__name'; + $handler->display['default']->display_options['fields']['schema__name']['alter']['alter_text'] = TRUE; + $handler->display['default']->display_options['fields']['schema__name']['alter']['text'] = '[schema__name]'; + $handler->display['default']->display_options['fields']['schema__name']['alter']['make_link'] = TRUE; + $handler->display['default']->display_options['fields']['schema__name']['alter']['path'] = 'feature/[obi__organism.TAXRANK:0000005]/[obi__organism.TAXRANK:0000006]/'.$key.'/[data__identifier]'; + /* Field Sequence Length */ + $handler->display['default']->display_options['fields']['data__sequence_length']['id'] = 'data__sequence_length'; + $handler->display['default']->display_options['fields']['data__sequence_length']['table'] = $table; + $handler->display['default']->display_options['fields']['data__sequence_length']['field'] = 'data__sequence_length'; + /* Field Organism */ + $handler->display['default']->display_options['fields']['obi__organism']['id'] = 'obi__organism'; + $handler->display['default']->display_options['fields']['obi__organism']['table'] = $table; + $handler->display['default']->display_options['fields']['obi__organism']['field'] = 'obi__organism'; + $handler->display['default']->display_options['fields']['obi__organism']['alter']['alter_text'] = TRUE; + $handler->display['default']->display_options['fields']['obi__organism']['alter']['text'] = '[obi__organism.TAXRANK:0000005] [obi__organism.TAXRANK:0000006]'; + $handler->display['default']->display_options['fields']['obi__organism']['alter']['make_link'] = TRUE; + $handler->display['default']->display_options['fields']['obi__organism']['alter']['path'] = 'organism/[obi__organism.TAXRANK:0000005]/[obi__organism.TAXRANK:0000006]'; + /* Sort criterion: : Identifier */ + $handler->display['default']->display_options['sorts']['priority']['id'] = 'schema__alternate_name'; + $handler->display['default']->display_options['sorts']['priority']['table'] = $table; + $handler->display['default']->display_options['sorts']['priority']['field'] = 'data__identifier'; + /* Filter criterion: Published */ + $handler->display['default']->display_options['filters']['status']['id'] = 'status'; + $handler->display['default']->display_options['filters']['status']['table'] = $table; + $handler->display['default']->display_options['filters']['status']['field'] = 'status'; + $handler->display['default']->display_options['filters']['status']['value'] = '1'; + /* Filter criterion: Identifier */ + $handler->display['default']->display_options['filters']['data__identifier']['id'] = 'data__identifier'; + $handler->display['default']->display_options['filters']['data__identifier']['table'] = $table; + $handler->display['default']->display_options['filters']['data__identifier']['field'] = 'data__identifier'; + $handler->display['default']->display_options['filters']['data__identifier']['operator'] = 'contains'; + $handler->display['default']->display_options['filters']['data__identifier']['group'] = 1; + $handler->display['default']->display_options['filters']['data__identifier']['exposed'] = TRUE; + $handler->display['default']->display_options['filters']['data__identifier']['expose']['operator_id'] = 'data__identifier_op'; + $handler->display['default']->display_options['filters']['data__identifier']['expose']['label'] = 'Unique Name'; + $handler->display['default']->display_options['filters']['data__identifier']['expose']['operator'] = 'data__identifier_op'; + $handler->display['default']->display_options['filters']['data__identifier']['expose']['identifier'] = 'data__identifier'; + $handler->display['default']->display_options['filters']['data__identifier']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + ); + /* Filter criterion: Name */ + $handler->display['default']->display_options['filters']['schema__name']['id'] = 'schema__name'; + $handler->display['default']->display_options['filters']['schema__name']['table'] = $table; + $handler->display['default']->display_options['filters']['schema__name']['field'] = 'schema__name'; + $handler->display['default']->display_options['filters']['schema__name']['operator'] = 'contains'; + $handler->display['default']->display_options['filters']['schema__name']['group'] = 1; + $handler->display['default']->display_options['filters']['schema__name']['exposed'] = TRUE; + $handler->display['default']->display_options['filters']['schema__name']['expose']['operator_id'] = 'schema__name_op'; + $handler->display['default']->display_options['filters']['schema__name']['expose']['label'] = 'Name'; + $handler->display['default']->display_options['filters']['schema__name']['expose']['operator'] = 'schema__name_op'; + $handler->display['default']->display_options['filters']['schema__name']['expose']['identifier'] = 'schema__name'; + $handler->display['default']->display_options['filters']['schema__name']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + ); + /* Filter criterion: Organism */ + $handler->display['default']->display_options['filters']['obi__organism']['id'] = 'obi__organism'; + $handler->display['default']->display_options['filters']['obi__organism']['table'] = $table; + $handler->display['default']->display_options['filters']['obi__organism']['field'] = 'obi__organism'; + $handler->display['default']->display_options['filters']['obi__organism']['operator'] = 'contains'; + $handler->display['default']->display_options['filters']['obi__organism']['group'] = 1; + $handler->display['default']->display_options['filters']['obi__organism']['exposed'] = TRUE; + $handler->display['default']->display_options['filters']['obi__organism']['expose']['operator_id'] = 'obi__organism_op'; + $handler->display['default']->display_options['filters']['obi__organism']['expose']['label'] = 'Organism'; + $handler->display['default']->display_options['filters']['obi__organism']['expose']['operator'] = 'obi__organism_op'; + $handler->display['default']->display_options['filters']['obi__organism']['expose']['identifier'] = 'obi__organism'; + $handler->display['default']->display_options['filters']['obi__organism']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + ); + + }; }; - - From 2f2c8140ab1afc198bc1b003409c0d89a5eb9446 Mon Sep 17 00:00:00 2001 From: mboudet Date: Wed, 6 Feb 2019 16:14:36 +0000 Subject: [PATCH 5/8] Dirty fix for tripal_analysis_expression redirection issues --- js/heatmap-fix.js | 296 +++++++++++++++++++++++++++++++++++++++ js/heatmap-search-fix.js | 144 +++++++++++++++++++ tripal_bipaa_ui.module | 43 ++++++ 3 files changed, 483 insertions(+) create mode 100644 js/heatmap-fix.js create mode 100644 js/heatmap-search-fix.js diff --git a/js/heatmap-fix.js b/js/heatmap-fix.js new file mode 100644 index 0000000..2ce21e4 --- /dev/null +++ b/js/heatmap-fix.js @@ -0,0 +1,296 @@ +(function ($) { + // To make draggable: + // Listening to plotly_click and then calling the appropriate restyle call + // should do the trick. + Drupal.behaviors.tripal_analysis_expression = { + /** + * Auto triggered by Drupal when the document is ready. + * + * @param context + * @param settings + */ + attach: function (context, settings) { + this.settings = settings.tripal_analysis_expression; + this.cache = {}; + if (!this.settings) { + return; + } + + this.data = this.settings.data; + + // Build drop down UI + var $selectContainer = $('#select_analysis'); + this.$select = $(''); + + // Add the dropdown to the page + $('#select_props').append(this.$propsSelect); + + // Initialize the props + this.updatePropsDropdown(); + + this.$propsSelect.on('change', function (e) { + this.selectedProp = e.target.value; + this.draw(this.constructHeatMapData()); + }.bind(this)); + }, + + /** + * Respond to changes in analysis selector + */ + updatePropsDropdown: function () { + this.$propsSelect.html(''); + var props = this.data.properties[this.selectedAnalysis]; + Object.keys(props).map(function (key) { + var option = $('