Class: StudyType

Inherits:
ApplicationRecord show all
Extended by:
Attributable::Association::Target
Defined in:
app/models/study_type.rb

Overview

Note:

Study::Metadata#study_type_valid? has hard-coded validation to prevent the 'Not specified' study type from being used. This should probably be updated to use the #valid_for_creation flag. I'm also not sure of having 'Not specified' be a specific database entry, although it has been assigned to several historic studies so does at least allow a not_nil constraint.

On Study creation the user selects a StudyType from a drop down list of pre-registered study types.

This information is exposed:

  • In the warehouses, where it may be used by customers, NPG, or bioinformaticians
  • Via the V1 API. (Not aware of any uses here, but there may be)
  • As <STUDY_TYPE existing_study_type="..." /> during study accessioning with the EBI

Defined Under Namespace

Modules: Associations

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Attributable::Association::Target

default, extended, for_select_association

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Attribute Details

#vaild_typeBoolean

Returns Indicates the study type is recognised by the EBI. If false the accessioned study will contain <STUDY_TYPE existing_study_type="Other" new_study_type="<study_type.name>"/> instead of <STUDY_TYPE existing_study_type="<study_type.name>"/>.

Returns:

  • (Boolean)

    Indicates the study type is recognised by the EBI. If false the accessioned study will contain <STUDY_TYPE existing_study_type="Other" new_study_type="<study_type.name>"/> instead of <STUDY_TYPE existing_study_type="<study_type.name>"/>



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/study_type.rb', line 28

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#valid_for_creationBoolean

Returns Indicates a study can be created with this option (determines if it appears in the dropdown).

Returns:

  • (Boolean)

    Indicates a study can be created with this option (determines if it appears in the dropdown)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/study_type.rb', line 28

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

Class Method Details

.include?(studytype_name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/study_type.rb', line 39

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end