Module: EBICheck::Utils

Defined in:
lib/ebi_check/utils.rb

Constant Summary collapse

XPATH_STUDY_TITLE =

Study XPaths

'//STUDY_TITLE'
XPATH_STUDY_DESCRIPTION =
'//STUDY_DESCRIPTION'
XPATH_CENTER_PROJECT_NAME =
'//CENTER_PROJECT_NAME'
XPATH_STUDY_ABSTRACT =
'//STUDY_ABSTRACT'
XPATH_EXISTING_STUDY_TYPE =
'//STUDY_TYPE/@existing_study_type'
XPATH_NEW_STUDY_TYPE =
'//STUDY_TYPE/@new_study_type'
XPATH_SCIENTIFIC_NAME =

Sample XPaths

'//SAMPLE/SAMPLE_NAME/SCIENTIFIC_NAME'
XPATH_COMMON_NAME =
'//SAMPLE/SAMPLE_NAME/COMMON_NAME'
XPATH_SAMPLE_TITLE =
'//SAMPLE/TITLE'
XPATH_SAMPLE_ATTRIBUTE =
'//SAMPLE/SAMPLE_ATTRIBUTES/SAMPLE_ATTRIBUTE'
XPATH_TAXON_ID =
'//SAMPLE/SAMPLE_NAME/TAXON_ID'
XPATH_VALUE =
'VALUE'
XPATH_TAG =
'TAG'

Class Method Summary collapse

Class Method Details

.extract_sample_fields(xml) ⇒ Hash

Extracts sample fields from the provided XML string.

Parameters:

  • xml (String)

    The sample XML data.

Returns:

  • (Hash)

    A hash containing the extracted sample fields.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ebi_check/utils.rb', line 58

 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

.extract_study_fields(xml) ⇒ Hash

Extracts study fields from the provided XML string.

Parameters:

  • xml (String)

    The study XML data.

Returns:

  • (Hash)

    A hash containing the extracted study fields.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ebi_check/utils.rb', line 43

 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