Class: Accession::Tag

Inherits:
Object
  • Object
show all
Includes:
Equality, HelperTagValue, ActiveModel::Model
Defined in:
lib/accession/tag.rb

Overview

A tag relates to a sample attribute. It provides all of the relevant information for that attribute i.e. which service it is required for and which groups it will be assigned to in the xml.

Direct Known Subclasses

TagCollectionDate, TagCountryOfOrigin

Defined Under Namespace

Modules: HelperTagValue

Constant Summary collapse

DEFAULT_ATTRIBUTES =
{ mandatory_services: [] }.freeze

Constants included from HelperTagValue

HelperTagValue::MISING_THIRD_PARTY_DATA, HelperTagValue::MISSING_CONTROL_SAMPLE, HelperTagValue::MISSING_DATA_AGGREEMENT_PRE2023, HelperTagValue::MISSING_ENDANGERED_SPECIES, HelperTagValue::MISSING_HUMAN_IDENTIFIABLE, HelperTagValue::MISSING_LAB_STOCK, HelperTagValue::MISSING_SAMPLE_GROUP, HelperTagValue::MISSING_SYNTHETIC_CONSTRUCT, HelperTagValue::NOT_APPLICABLE_CONTROL_SAMPLE, HelperTagValue::NOT_APPLICABLE_SAMPLE_GROUP, HelperTagValue::NOT_COLLECTED, HelperTagValue::NOT_PROVIDED, HelperTagValue::OTHER_DEFAULT_SETTINGS, HelperTagValue::RESTRICTED_ACCESS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HelperTagValue

#incorrect_format_value, #value_for

Methods included from Equality

#<=>, #to_a

Constructor Details

#initialize(attributes = {}) ⇒ Tag

Returns a new instance of Tag.



17
18
19
# File 'lib/accession/tag.rb', line 17

def initialize(attributes = {})
  super(DEFAULT_ATTRIBUTES.merge(attributes))
end

Instance Attribute Details

#class_name ⇒ Object

Returns the value of attribute class_name.



11
12
13
# File 'lib/accession/tag.rb', line 11

def class_name
  @class_name
end

#ebi_name ⇒ Object

Returns the value of attribute ebi_name.



11
12
13
# File 'lib/accession/tag.rb', line 11

def ebi_name
  @ebi_name
end

#groups ⇒ Object

Returns the value of attribute groups.



11
12
13
# File 'lib/accession/tag.rb', line 11

def groups
  @groups
end

#mandatory_services ⇒ Object

Returns the value of attribute mandatory_services.



11
12
13
# File 'lib/accession/tag.rb', line 11

def mandatory_services
  @mandatory_services
end

#name ⇒ Object

Returns the value of attribute name.



11
12
13
# File 'lib/accession/tag.rb', line 11

def name
  @name
end

#value ⇒ Object

Returns the value of attribute value.



11
12
13
# File 'lib/accession/tag.rb', line 11

def value
  @value
end

Instance Method Details

#add_value(value) ⇒ Object



45
46
47
48
# File 'lib/accession/tag.rb', line 45

def add_value(value)
  self.value = value
  self
end

#array_express? ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/accession/tag.rb', line 33

def array_express?
  array_express
end

#array_express_label ⇒ Object



61
62
63
# File 'lib/accession/tag.rb', line 61

def array_express_label
  "ArrayExpress-#{label_string.upcase}"
end

#attributes ⇒ Object



65
66
67
# File 'lib/accession/tag.rb', line 65

def attributes
  %i[mandatory_services value name groups ebi_name]
end

#label ⇒ Object



54
55
56
57
58
59
# File 'lib/accession/tag.rb', line 54

def label
  # ebi_name is used if present in the tag config, otherwise name is used
  # NB. ebi XML schema needs lowercase tag labels and spaces instead of underscores
  # i.e. 'sample name' instead of 'SAMPLE_NAME'
  label_string.tr('_', ' ').downcase
end

#label_string ⇒ Object



50
51
52
# File 'lib/accession/tag.rb', line 50

def label_string
  (ebi_name || name).to_s
end

#required_for?(service) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/accession/tag.rb', line 29

def required_for?(service)
  mandatory_services.include? service.provider
end

#sample_attributes? ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/accession/tag.rb', line 41

def sample_attributes?
  sample_attributes
end

#sample_name? ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/accession/tag.rb', line 37

def sample_name?
  sample_name
end