From 88a89c9f55aacc87bcdf4ec1a794768264ebc14e Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Fri, 3 Jul 2020 10:45:35 +0200 Subject: [PATCH 1/8] Add human disease options to admin feature page Two checkboxes to enable human diseases and plot on frontpage --- app/controllers/admin_controller.rb | 2 ++ app/views/admin/features_enabled.html.erb | 10 +++++++++- app/views/homes/_home_contents.html.erb | 2 +- lib/seek/config_setting_attributes.yml | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 0e42d115dd..45447c9925 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -122,6 +122,8 @@ def update_features_enabled Seek::Config.samples_enabled = string_to_boolean params[:samples_enabled] Seek::Config.sops_enabled = string_to_boolean params[:sops_enabled] Seek::Config.workflows_enabled = string_to_boolean params[:workflows_enabled] + Seek::Config.human_diseases_enabled = string_to_boolean params[:human_diseases_enabled] + Seek::Config.human_diseases_plot_enabled = string_to_boolean params[:human_diseases_plot_enabled] Seek::Config.require_cookie_consent = string_to_boolean params[:require_cookie_consent] diff --git a/app/views/admin/features_enabled.html.erb b/app/views/admin/features_enabled.html.erb index 5f5057cbe7..e309155a51 100644 --- a/app/views/admin/features_enabled.html.erb +++ b/app/views/admin/features_enabled.html.erb @@ -65,6 +65,14 @@ <%= admin_checkbox_setting(:organisms_enabled, 1, Seek::Config.organisms_enabled, "Organisms enabled", "Whether the users can register organisms in SEEK.") %> + <%= admin_checkbox_setting(:human_diseases_enabled, 1, Seek::Config.human_diseases_enabled, + "Human diseases enabled", "Whether the users can register human diseases in SEEK.", + :onchange=>toggle_appear_javascript('human_diseases_plot')) %> +
+ <%= admin_checkbox_setting(:human_diseases_plot_enabled, 1, Seek::Config.human_diseases_plot_enabled, + "Show plot on SEEK frontpage", "A sunburst plot will be displayed on the frontpage, which contains annotated human diseases and counts.") %> +
+ <%= admin_checkbox_setting(:programmes_enabled, 1, Seek::Config.programmes_enabled, "#{t('programme').pluralize} enabled", "Whether #{t('programme').pluralize} are enabled. #{t('programme').pluralize} allow a collection of #{t('project').pluralize} to be grouped together. This is useful if you have a large number of #{t('project').pluralize} from different initiatives.",onchange: toggle_appear_javascript('programme_details')) %>
@@ -126,7 +134,7 @@ <%= admin_checkbox_setting(:require_cookie_consent, 1, Seek::Config.require_cookie_consent, - "Add a cookie consent banner and a cookie setting page", "Show a banner asking for consent for the use of cookies. SEEK uses an essential cookie for session handling, and optional cookies for tracking if set below. + "Add a cookie consent banner and a cookie setting page", "Show a banner asking for consent for the use of cookies. SEEK uses an essential cookie for session handling, and optional cookies for tracking if set below. Some cookies might be also set by embedded content. This banner will offer 3 choices: Only necessary, Embedded content, All. Setting up this option will also add a cookie setting page accessible from the footer.") %> diff --git a/app/views/homes/_home_contents.html.erb b/app/views/homes/_home_contents.html.erb index 7431eb2d88..a6b5523702 100644 --- a/app/views/homes/_home_contents.html.erb +++ b/app/views/homes/_home_contents.html.erb @@ -59,6 +59,6 @@

-<% if Seek::Config.human_diseases_enabled %> +<% if Seek::Config.human_diseases_enabled && Seek::Config.human_diseases_plot_enabled %> <%= render :partial => 'human_diseases/overview_plot' %> <% end %> diff --git a/lib/seek/config_setting_attributes.yml b/lib/seek/config_setting_attributes.yml index e23642e9df..7c5ba287d3 100644 --- a/lib/seek/config_setting_attributes.yml +++ b/lib/seek/config_setting_attributes.yml @@ -53,6 +53,7 @@ modelling_analysis_enabled: allow_publications_fulltext: allow_edit_of_registered_publ: human_diseases_enabled: +human_diseases_plot_enabled: jerm_enabled: email_enabled: jws_enabled: From 4be3e47c4346267a585f7df24fe58a248a4a4d88 Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Fri, 3 Jul 2020 10:54:21 +0200 Subject: [PATCH 2/8] Remove useless related_human_diseases of publication --- app/models/publication.rb | 5 ----- .../projects/asset_report/_linked_publication_row.html.erb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/publication.rb b/app/models/publication.rb index 9e378ff882..9f79a95166 100755 --- a/app/models/publication.rb +++ b/app/models/publication.rb @@ -528,11 +528,6 @@ def related_organism_ids joins: [:assays_organisms, :models_organisms] ) - # returns a list of related human diseases, related through either the assay or the model - def related_human_diseases - (assays.collect(&:human_diseases).flatten | models.collect(&:human_disease).flatten).uniq - end - def self.subscribers_are_notified_of?(action) action == 'create' end diff --git a/app/views/projects/asset_report/_linked_publication_row.html.erb b/app/views/projects/asset_report/_linked_publication_row.html.erb index 4a3ae0cc95..13b1ea74c6 100644 --- a/app/views/projects/asset_report/_linked_publication_row.html.erb +++ b/app/views/projects/asset_report/_linked_publication_row.html.erb @@ -46,7 +46,7 @@ <% end -%> - <% human_diseases=pub.related_human_diseases -%> + <% human_diseases=pub.human_diseases -%> <% if human_diseases.empty? -%> None defined <% else %> From 3b5a8394920c44de7ecd8b8d8965c356012c7748 Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Fri, 3 Jul 2020 13:24:06 +0200 Subject: [PATCH 3/8] Hide human_disease avatar in resource list --- app/views/assets/_resource_list_item.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/assets/_resource_list_item.html.erb b/app/views/assets/_resource_list_item.html.erb index 8b79818d77..872bb34167 100644 --- a/app/views/assets/_resource_list_item.html.erb +++ b/app/views/assets/_resource_list_item.html.erb @@ -8,7 +8,7 @@ avatar_partial = get_list_item_avatar_partial(resource) if avatar_partial.nil? #dont show JERM avatar for strain without contributor, as there are strains without contributor and are not harvested - avatar_partial = nil if (resource.kind_of?(Strain) && resource.contributor.try(:person).nil?) || resource.is_a?(Organism) + avatar_partial = nil if (resource.kind_of?(Strain) && resource.contributor.try(:person).nil?) || resource.is_a?(Organism) || resource.is_a?(HumanDisease) avatar_content = avatar_partial.blank? ? nil : render(:partial=> avatar_partial,:locals=>{:resource => resource}) access_based_css_class = "list_item" From d280290cd3700ee5cb6f0eca18a4f6493fc0b460 Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Fri, 3 Jul 2020 15:28:33 +0200 Subject: [PATCH 4/8] Add human disease tagging to data files --- app/controllers/data_files_controller.rb | 10 +++++----- app/helpers/human_diseases_helper.rb | 3 ++- app/models/data_file.rb | 8 +++++++- app/models/human_disease.rb | 6 ++++-- app/views/data_files/_resource_list_item.html.erb | 3 +++ app/views/data_files/edit.html.erb | 6 +++++- .../data_files/multi-steps/_basic_metadata.html.erb | 8 ++++++-- app/views/data_files/show.html.erb | 9 ++++++++- app/views/human_diseases/_overview_plot.html.erb | 9 +++++---- ...20200703120513_add_human_diseases_to_data_files.rb | 11 +++++++++++ db/schema.rb | 7 +++++++ test/unit/filterer_test.rb | 2 ++ 12 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20200703120513_add_human_diseases_to_data_files.rb diff --git a/app/controllers/data_files_controller.rb b/app/controllers/data_files_controller.rb index a835d35df6..56472d2511 100644 --- a/app/controllers/data_files_controller.rb +++ b/app/controllers/data_files_controller.rb @@ -381,8 +381,8 @@ def create_metadata if all_valid - update_relationships(@data_file, params) - + update_relationships(@data_file, params) + respond_to do |format| flash[:notice] = "#{t('data_file')} was successfully uploaded and saved." if flash.now[:notice].nil? @@ -390,8 +390,8 @@ def create_metadata # the assay_id param can also contain the relationship type @data_file.assays << @assay if @create_new_assay - format.html { redirect_to params[:single_page] ? - { controller: :single_pages, action: :show, id: params[:single_page] } + format.html { redirect_to params[:single_page] ? + { controller: :single_pages, action: :show, id: params[:single_page] } : data_file_path(@data_file) } format.json { render json: @data_file, include: [params[:include]] } end @@ -469,7 +469,7 @@ def forbid_new_version_if_samples def data_file_params params.require(:data_file).permit(:title, :description, :simulation_data, { project_ids: [] }, - :license, *creator_related_params, { event_ids: [] }, + :license, *creator_related_params, { event_ids: [] }, { human_disease_ids: [] }, { special_auth_codes_attributes: [:code, :expiration_date, :id, :_destroy] }, { assay_assets_attributes: [:assay_id, :relationship_type_id] }, { creator_ids: [] }, { assay_assets_attributes: [:assay_id, :relationship_type_id] }, diff --git a/app/helpers/human_diseases_helper.rb b/app/helpers/human_diseases_helper.rb index defeec686f..e355dd9f0d 100644 --- a/app/helpers/human_diseases_helper.rb +++ b/app/helpers/human_diseases_helper.rb @@ -65,9 +65,10 @@ def get_human_diseases_plot_data() title: c.title, parent: c.parents.first ? c.parents.first.id.to_s : '', projects: c.projects.count, - assays: c.assays.count, + # assays: c.assays.count, # currently not in use publications: c.publications.count, models: c.models.count, + data_files: c.data_files.count, } end end diff --git a/app/models/data_file.rb b/app/models/data_file.rb index 1541a2823e..18d7f8dead 100644 --- a/app/models/data_file.rb +++ b/app/models/data_file.rb @@ -42,8 +42,10 @@ class DataFile < ApplicationRecord joins: [:assays] ) - explicit_versioning(version_column: 'version', sync_ignore_columns: ['doi', 'file_template_id']) do + has_and_belongs_to_many :human_diseases + has_filter :human_disease + explicit_versioning(version_column: 'version', sync_ignore_columns: ['doi', 'file_template_id']) do acts_as_doi_mintable(proxy: :parent, type: 'Dataset', general_type: 'Dataset') acts_as_versioned_resource acts_as_favouritable @@ -229,6 +231,10 @@ def initialise_assay_from_template end end + def human_disease_terms + human_diseases.collect(&:searchable_terms).flatten + end + has_task :sample_extraction has_task :sample_persistence end diff --git a/app/models/human_disease.rb b/app/models/human_disease.rb index a7c913c882..c6b01d084f 100644 --- a/app/models/human_disease.rb +++ b/app/models/human_disease.rb @@ -17,6 +17,7 @@ class HumanDisease < ApplicationRecord has_and_belongs_to_many :projects has_and_belongs_to_many :publications + has_and_belongs_to_many :data_files has_many :human_disease_parents, foreign_key: 'human_disease_id', class_name: 'HumanDiseaseParent' has_many :parents, through: :human_disease_parents, source: :parent, dependent: :destroy @@ -69,7 +70,7 @@ class HumanDisease < ApplicationRecord end def can_delete?(user = User.current_user) - !user.nil? && user.is_admin_or_project_administrator? && models.empty? && assays.empty? && projects.empty? && publications.empty? + !user.nil? && user.is_admin_or_project_administrator? && models.empty? && assays.empty? && projects.empty? && publications.empty? && data_files.empty? end def can_manage?(_user = User.current_user) @@ -114,7 +115,8 @@ def to_node(selected = nil, ignore_count = false) ids = projects.pluck(:id).map { |x| 'proj_' + x.to_s } + assays.pluck(:id).map { |x| 'ass_' + x.to_s } + models.pluck(:id).map { |x| 'mod_' + x.to_s } + - publications.pluck(:id).map { |x| 'pub_' + x.to_s } + publications.pluck(:id).map { |x| 'pub_' + x.to_s } + + data_files.pluck(:id).map { |x| 'data_' + x.to_s } child_nodes = [] children.each do |child| diff --git a/app/views/data_files/_resource_list_item.html.erb b/app/views/data_files/_resource_list_item.html.erb index dcd81fca39..7a537ad48a 100644 --- a/app/views/data_files/_resource_list_item.html.erb +++ b/app/views/data_files/_resource_list_item.html.erb @@ -3,6 +3,9 @@
<%= render partial:"assets/resource_list_item_contributor_and_creators",object:resource %> + <% if Seek::Config.human_diseases_enabled and !resource.human_diseases.empty? %> + <%= list_item_simple_list resource.human_diseases, "Human Diseases" %> + <% end %> <%= list_item_doi(resource) %> <%= @assay ? (list_item_optional_attribute "Relationship type", resource.relationship_type(@assay).try(:title)) : "" %>
diff --git a/app/views/data_files/edit.html.erb b/app/views/data_files/edit.html.erb index 9d147a8bea..8cb62af221 100644 --- a/app/views/data_files/edit.html.erb +++ b/app/views/data_files/edit.html.erb @@ -27,11 +27,15 @@
+ <% if Seek::Config.human_diseases_enabled %> + <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> + <% end %> + <% if Seek::Config.file_templates_enabled %> <%= render :partial => "assets/select_template", :locals => {:resource => (@data_file ? @data_file : DataFile.new), :templates => authorised_assets(FileTemplate, nil, 'edit') } %> <% end %> - + <%= render :partial => 'assets/controlled_vocab_annotations_form_properties', :locals => { :resource => (@data_file ? @data_file : DataFile.new) } -%> <%= render :partial => 'assets/license_selector', :locals => { :resource => @data_file } %> diff --git a/app/views/data_files/multi-steps/_basic_metadata.html.erb b/app/views/data_files/multi-steps/_basic_metadata.html.erb index c021e4f32f..da692c4301 100644 --- a/app/views/data_files/multi-steps/_basic_metadata.html.erb +++ b/app/views/data_files/multi-steps/_basic_metadata.html.erb @@ -25,9 +25,13 @@ -
"> +
"> <%= render :partial => 'projects/project_selector', locals: { resource: @data_file } -%> -
+
<% if Seek::Config.human_diseases_enabled %> +
+ <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> +
+ <% end %> <%= render :partial => 'assets/select_tags', locals: {collapsed: true} if DataFile.is_taggable? %> <%if(is_modal)%> Cancel diff --git a/app/views/data_files/show.html.erb b/app/views/data_files/show.html.erb index 2b2585b194..b31dd120a5 100644 --- a/app/views/data_files/show.html.erb +++ b/app/views/data_files/show.html.erb @@ -25,7 +25,14 @@ <% end %> <% end %> - <%= render :partial => "assets/special_auth_code_display", :locals => {:resource => @data_file} %> + <% if Seek::Config.human_diseases_enabled %> +

+ Human Diseases: + <%= human_diseases_link_list @data_file.human_diseases -%> +

+ <% end %> + + <%= render :partial => "assets/special_auth_code_display", :locals => {:resource => @data_file} %> <%= render :partial => "assets/asset_doi", :locals => {:displayed_resource=>@display_data_file} %> diff --git a/app/views/human_diseases/_overview_plot.html.erb b/app/views/human_diseases/_overview_plot.html.erb index ed9d245f47..1725ef9f1c 100644 --- a/app/views/human_diseases/_overview_plot.html.erb +++ b/app/views/human_diseases/_overview_plot.html.erb @@ -22,9 +22,10 @@ var data = [ <% plots = [ - { key: :projects, annotation: { x: 0.145, y: 1.05 } }, - { key: :publications, annotation: { x: 0.5, y: 1.05 } }, - { key: :models, annotation: { x: 0.86, y: 1.05 } }, + { key: :projects, annotation: { x: 0.105, y: 1.05 } }, + { key: :publications, annotation: { x: 0.37, y: 1.05 } }, + { key: :models, annotation: { x: 0.63, y: 1.05 } }, + { key: :data_files, annotation: { x: 0.895, y: 1.05 } }, ] index = -1 %> @@ -48,7 +49,7 @@ var layout = { margin: { l: 0, r: 0, b: 0, t: 50 }, sunburstcolorway: [ '#217290', '#EC7063', '#5499C7', '#01d28e', '#f4d03f', '#8e44ad'], - grid: { rows: 1, columns:3, pattern: 'independent' }, + grid: { rows: 1, columns: 4, pattern: 'independent' }, annotations: [ <% plots.each do |plot| %> { diff --git a/db/migrate/20200703120513_add_human_diseases_to_data_files.rb b/db/migrate/20200703120513_add_human_diseases_to_data_files.rb new file mode 100644 index 0000000000..4f101e19aa --- /dev/null +++ b/db/migrate/20200703120513_add_human_diseases_to_data_files.rb @@ -0,0 +1,11 @@ +class AddHumanDiseasesToDataFiles < ActiveRecord::Migration[5.2] + def change + create_table "data_files_human_diseases", id: false, force: :cascade do |t| + t.integer "human_disease_id" + t.integer "data_file_id" + end + + add_index "data_files_human_diseases", ["human_disease_id", "data_file_id"], name: "index_diseases_data_files_on_disease_id_and_data_file_id", using: :btree + add_index "data_files_human_diseases", ["data_file_id"], name: "index_diseases_data_files_on_data_file_id", using: :btree + end + end diff --git a/db/schema.rb b/db/schema.rb index 22e12632eb..76feb5e35d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -430,6 +430,13 @@ t.integer "event_id" end + create_table "data_files_human_diseases", id: false, force: :cascade do |t| + t.integer "human_disease_id" + t.integer "data_file_id" + t.index ["data_file_id"], name: "index_diseases_data_files_on_data_file_id" + t.index ["human_disease_id", "data_file_id"], name: "index_diseases_data_files_on_disease_id_and_data_file_id" + end + create_table "data_files_projects", id: false, force: :cascade do |t| t.integer "project_id" t.integer "data_file_id" diff --git a/test/unit/filterer_test.rb b/test/unit/filterer_test.rb index a45cdbb54a..00bc614c6d 100644 --- a/test/unit/filterer_test.rb +++ b/test/unit/filterer_test.rb @@ -9,6 +9,7 @@ class FiltererTest < ActiveSupport::TestCase assert_includes data_file_filters, :tag assert_includes data_file_filters, :created_at assert_includes data_file_filters, :project + assert_includes data_file_filters, :human_disease assert_not_includes data_file_filters, :assay_class assert_includes assay_filters, :query @@ -16,6 +17,7 @@ class FiltererTest < ActiveSupport::TestCase assert_includes assay_filters, :created_at assert_includes assay_filters, :project assert_includes assay_filters, :assay_class + assert_includes assay_filters, :human_disease assert_not_includes assay_filters, :published_year Banana = Class.new(ApplicationRecord) From 398c242854a00b5de308c871c84711341e49c5ee Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Fri, 10 Jul 2020 10:45:52 +0200 Subject: [PATCH 5/8] Use fancy multiselect field for human diseases In Assay form --- app/assets/javascripts/publications.js | 80 --------------------- app/controllers/assays_controller.rb | 12 +--- app/views/assays/_form.html.erb | 4 +- app/views/assays/_select_human_diseases.erb | 51 ------------- 4 files changed, 2 insertions(+), 145 deletions(-) delete mode 100644 app/assets/javascripts/publications.js delete mode 100644 app/views/assays/_select_human_diseases.erb diff --git a/app/assets/javascripts/publications.js b/app/assets/javascripts/publications.js deleted file mode 100644 index bda7eb449c..0000000000 --- a/app/assets/javascripts/publications.js +++ /dev/null @@ -1,80 +0,0 @@ -var human_diseases=new Array(); - -function addSelectedHumanDisease() { - selected_option_index=$("possible_human_diseases").selectedIndex; - selected_option=$("possible_human_diseases").options[selected_option_index]; - title=selected_option.text; - id=selected_option.value; - - if(checkNotInList(id,human_diseases)) { - addHumanDisease(title,id); - updateHumanDiseases(); - } - else { - alert('The human disease has already been added:\n\n' + - title); - } -} - -function removeHumanDisease(id) { - - for(var i = 0; i < human_diseases.length; i++) - if(human_diseases[i][1] == id) { - human_diseases.splice(i, 1); - break; - } - - // update the page - updateHumanDiseases(); -} - -function updateHumanDiseases() { - human_disease_text=''; - type="Human Disease"; - human_disease_ids=new Array(); - - for (var i=0;i: ' + title - //+ "  (" + contributor + ")" - + '  ' - + '[remove]
'; - human_disease_ids.push(id); - } - - // remove the last line break - if(human_disease_text.length > 0) { - human_disease_text = human_disease_text.slice(0,-5); - } - - // update the page - if(human_disease_text.length == 0) { - $('human_disease_to_list').innerHTML = 'No human diseases'; - } - else { - $('human_disease_to_list').innerHTML = human_disease_text; - } - - clearList('publication_human_disease_ids'); - - select=$('publication_human_disease_ids'); - for (i=0;i <% if Seek::Config.human_diseases_enabled %> -
- <%= render :partial=>"assays/select_human_diseases" -%> -
+ <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> <% end %> <%= render partial: 'assets/manage_specific_attributes', locals:{f:f} if show_form_manage_specific_attributes? %> diff --git a/app/views/assays/_select_human_diseases.erb b/app/views/assays/_select_human_diseases.erb deleted file mode 100644 index 4dd7290665..0000000000 --- a/app/views/assays/_select_human_diseases.erb +++ /dev/null @@ -1,51 +0,0 @@ -<% - select_truncate_length=120 - available_human_diseases = HumanDisease.order(:title) - existing_json = associations_json_from_assay_human_diseases(@assay.assay_human_diseases) --%> -<%= folding_panel('Human Diseases', false, - help_text: "Here you can associate the #{t('assays.assay').downcase} with specific human diseases.") do %> -

- The following Human Diseases are involved in this <%= "#{@assay_text}" -%>: -

- - <%= associations_list('human_disease_to_list', 'associations/assay_human_disease', existing_json, empty_text: 'No Human Diseases') %> - -
- - <%= select_tag :possible_human_diseases, - options_for_select(available_human_diseases.map { |d| [truncate(h(d.title), length: select_truncate_length), d.id]}), - promt: 'Select Human Disease ...', class: 'form-control' -%> - <%= button_link_to "Include in the #{@assay_text}", 'new', '#', id: 'add-human-disease-btn' %> -
- -<% end %> - - From 075dee2e705d150fe8387ba0ae8e3bf6e1bb6ba1 Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Mon, 10 Aug 2020 14:09:49 +0200 Subject: [PATCH 6/8] Add human disease filter to models --- app/models/model.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/model.rb b/app/models/model.rb index 50d01fd40e..ece684c60b 100644 --- a/app/models/model.rb +++ b/app/models/model.rb @@ -43,6 +43,11 @@ class Model < ApplicationRecord label_field: 'organisms.title', includes: [:organism] ) + has_filter human_disease: Seek::Filtering::Filter.new( + value_field: 'human_diseases.id', + label_field: 'human_diseases.title', + includes: [:human_disease] + ) has_filter :model_type, :model_format, :recommended_environment has_filter modelling_analysis_type: Seek::Filtering::Filter.new( From 4fd42daebfb6c4f1c7c3bac2f7e1d9937e2fcd3a Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Wed, 16 Sep 2020 16:36:02 +0200 Subject: [PATCH 7/8] Add human diseases related resource paths * data_files_human_diseases_path * human_diseases_data_files_path * publication_human_diseases_path --- config/routes.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index e632e6f4f0..c66ccc0867 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -494,7 +494,7 @@ get :retrieve_nels_sample_metadata get :has_matching_sample_type end - resources :people, :programmes, :projects, :investigations, :assays, :samples, :studies, :publications, :events, :collections, :workflows, :file_templates, :placeholders, only: [:index] + resources :people, :programmes, :projects, :investigations, :assays, :samples, :studies, :publications, :events, :collections, :workflows, :file_templates, :placeholders, :human_diseases, only: [:index] end resources :presentations, concerns: [:has_content_blobs, :publishable, :has_versions, :asset] do @@ -607,7 +607,7 @@ post :request_contact post :upload_pdf end - resources :people, :programmes, :projects, :investigations, :assays, :studies, :models, :data_files, :documents, :presentations, :organisms, :events, :collections, :workflows, :human_diseases, only: [:index] + resources :people, :programmes, :projects, :investigations, :assays, :studies, :models, :data_files, :documents, :presentations, :organisms, :human_diseases, :events, :collections, :workflows, :human_diseases, only: [:index] end resources :events, concerns: [:asset] do @@ -639,7 +639,7 @@ collection do post :search_ajax end - resources :projects, :programmes, :assays, :studies, :models, :publications, only: [:index] + resources :projects, :programmes, :assays, :studies, :models, :publications, :data_files, only: [:index] member do get :tree end From c6ab8eeed380274333ca014cafecf726cf91c8fb Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Thu, 5 Nov 2020 11:02:57 +0100 Subject: [PATCH 8/8] Show untagged content below disease plot --- app/helpers/human_diseases_helper.rb | 34 ++++++++++++------- .../human_diseases/_overview_plot.html.erb | 18 ++++++---- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/helpers/human_diseases_helper.rb b/app/helpers/human_diseases_helper.rb index e355dd9f0d..14d0b20e33 100644 --- a/app/helpers/human_diseases_helper.rb +++ b/app/helpers/human_diseases_helper.rb @@ -58,19 +58,27 @@ def get_transitive_related_resources(resource, limit = nil) end def get_human_diseases_plot_data() - Rails.cache.fetch('human_diseases_plot_data', expires_in: 12.hours) do - HumanDisease.all.order(:id).map do |c| - { - id: c.id.to_s, - title: c.title, - parent: c.parents.first ? c.parents.first.id.to_s : '', - projects: c.projects.count, - # assays: c.assays.count, # currently not in use - publications: c.publications.count, - models: c.models.count, - data_files: c.data_files.count, - } - end + Rails.cache.fetch('human_diseases_data', expires_in: 12.hours) do + { + tagged: + HumanDisease.all.order(:id).map do |c| + { + id: c.id.to_s, + title: c.title, + parent: c.parents.first ? c.parents.first.id.to_s : '', + projects: c.projects.count, + publications: c.publications.count, + models: c.models.count, + data_files: c.data_files.count, + } + end, + untagged: { + projects: Project.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + publications: Publication.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + models: Model.where(human_disease: nil).count(), + data_files: DataFile.left_outer_joins(:human_diseases).where(human_diseases: { id: nil }).count(), + }, + } end end end diff --git a/app/views/human_diseases/_overview_plot.html.erb b/app/views/human_diseases/_overview_plot.html.erb index 1725ef9f1c..4cc1690add 100644 --- a/app/views/human_diseases/_overview_plot.html.erb +++ b/app/views/human_diseases/_overview_plot.html.erb @@ -1,5 +1,7 @@ <% - dataframe = get_human_diseases_plot_data() + data = get_human_diseases_plot_data() + tagged = data[:tagged] + untagged = data[:untagged] %>
+ + Untagged:
+ <%= untagged.map{ |key, value| key.to_s.humanize + ': ' + value.to_s }.join(', ') %> +
@@ -32,11 +38,11 @@ <% plots.each do |plot| %> { type: 'sunburst', - ids: [ <%== dataframe.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ], - labels: [ <%== dataframe.map{ |c| '"' + + '"' }.join(', ') %> ], - parents: [ <%== dataframe.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ], - values: [ <%== dataframe.map{ |c| c[plot[:key]] }.join(', ') %> ], - hovertext: [ <%== dataframe.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ], + ids: [ <%== tagged.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ], + labels: [ <%== tagged.map{ |c| '"' + + '"' }.join(', ') %> ], + parents: [ <%== tagged.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ], + values: [ <%== tagged.map{ |c| c[plot[:key]] }.join(', ') %> ], + hovertext: [ <%== tagged.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ], outsidetextfont: { size: 20, color: '#377eb8' }, leaf: { opacity: 1 }, marker: { line: { width: 2 } },