Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disease ontology improvements #28

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions app/assets/javascripts/publications.js

This file was deleted.

2 changes: 2 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
12 changes: 1 addition & 11 deletions app/controllers/assays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def create
@assay = Assay.new(assay_params)

update_assay_organisms @assay, params
update_assay_human_diseases @assay, params
@assay.contributor = current_person
update_sharing_policies @assay
update_annotations(params[:tag_list], @assay)
Expand Down Expand Up @@ -132,7 +131,6 @@ def fix_assay_linkage

def update
update_assay_organisms @assay, params
update_assay_human_diseases @assay, params
update_annotations(params[:tag_list], @assay)
update_sharing_policies @assay
update_relationships(@assay, params)
Expand Down Expand Up @@ -160,14 +158,6 @@ def update_assay_organisms(assay, params)
end
end

def update_assay_human_diseases(assay, params)
human_diseases = params[:assay_human_disease_ids] || params[:assay][:human_disease_ids] || []
assay.assay_human_diseases = []
Array(human_diseases).each do |human_disease_id|
assay.associate_human_disease(human_disease_id)
end
end

def show
respond_to do |format|
format.html { render(params[:only_content] ? { layout: false } : {}) }
Expand All @@ -185,7 +175,7 @@ def assay_params
{ samples_attributes: %i[asset_id direction] },
{ data_files_attributes: %i[asset_id direction relationship_type_id] },
{ placeholders_attributes: %i[asset_id direction relationship_type_id] },
{ publication_ids: [] },
{ publication_ids: [] }, { human_disease_ids: [] },
{ extended_metadata_attributes: determine_extended_metadata_keys },
{ discussion_links_attributes:[:id, :url, :label, :_destroy] }
).tap do |assay_params|
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/data_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,17 @@ 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?
# parse the data file if it is with sample data

# 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
Expand Down Expand Up @@ -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] },
Expand Down
33 changes: 21 additions & 12 deletions app/helpers/human_diseases_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +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,
publications: c.publications.count,
models: c.models.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
8 changes: 7 additions & 1 deletion app/models/data_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions app/models/human_disease.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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|
Expand Down
5 changes: 5 additions & 0 deletions app/models/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 0 additions & 5 deletions app/models/publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion app/views/admin/features_enabled.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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')) %>
<div id="human_diseases_plot" class="additional_settings" style="<%= show_or_hide_block Seek::Config.human_diseases_enabled -%>">
<%= 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.") %>
</div>

<%= 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')) %>
<div id="programme_details" class="additional_settings" style="<%= show_or_hide_block Seek::Config.programmes_enabled -%>">
Expand Down Expand Up @@ -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.") %>

Expand Down
4 changes: 1 addition & 3 deletions app/views/assays/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
<% end %>

<% if Seek::Config.human_diseases_enabled %>
<div id="add_human_disease_form">
<%= render :partial=>"assays/select_human_diseases" -%>
</div>
<%= 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? %>
Expand Down
51 changes: 0 additions & 51 deletions app/views/assays/_select_human_diseases.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/assets/_resource_list_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions app/views/data_files/_resource_list_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<div class="row">
<div class="col-sm-6">
<%= 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)) : "" %>
</div>
Expand Down
6 changes: 5 additions & 1 deletion app/views/data_files/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@

</div>

<% 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 } %>
Expand Down
Loading
Loading