Class: GeneAttribute

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Identifiers, Shared::IsData, Shared::Notes, Shared::Tags
Defined in:
app/models/gene_attribute.rb

Overview

A GeneAttribute defines an attribute that must be matched for a Sequence to be classified as a Descriptor::Gene. There are two key attributes, sequence, and sequence relationship. A GeneAttribute will return all sequences who are the object of a taxon name relationship whose subject is Sequence and whose Type is #sequence_relationship_type

! Deprecated?

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::Tags

#reject_tags, #tag_with, #tagged?, #tagged_with?

Methods included from Shared::Notes

#concatenated_notes_string, #reject_notes

Methods included from Shared::Identifiers

#dwc_occurrence_id, #identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers, #uri, #uuid

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#controlled_vocabulary_term_idInteger

Returns not yet implemented, intent/idea is to define a subclass of CVT that represents GO terms.

Returns:

  • (Integer)

    not yet implemented, intent/idea is to define a subclass of CVT that represents GO terms.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/gene_attribute.rb', line 26

class GeneAttribute < ApplicationRecord
  include Housekeeping
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::IsData

  acts_as_list scope: [:descriptor_id, :project_id]

  belongs_to :descriptor, class_name: 'Descriptor::Gene', inverse_of: :gene_attributes
  belongs_to :sequence, inverse_of: :gene_attributes

  # Not yet implemented.
  # Deprecated: Use Tag/Keyword
  # belongs_to :controlled_vocabulary_term

  validates :descriptor, presence: true
  validates :sequence, presence: true

  validates_uniqueness_of :sequence, scope: [:descriptor, :sequence_relationship_type]

  after_save :add_to_descriptor_logic_if_absent

  def to_logic_literal
    "#{sequence_relationship_type}.#{sequence_id}"
  end

  protected

  def add_to_descriptor_logic_if_absent 
    descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
  end

end

#descriptor_idInteger

Returns the descriptor id (Gene) that this attribute defines.

Returns:

  • (Integer)

    the descriptor id (Gene) that this attribute defines



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/gene_attribute.rb', line 26

class GeneAttribute < ApplicationRecord
  include Housekeeping
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::IsData

  acts_as_list scope: [:descriptor_id, :project_id]

  belongs_to :descriptor, class_name: 'Descriptor::Gene', inverse_of: :gene_attributes
  belongs_to :sequence, inverse_of: :gene_attributes

  # Not yet implemented.
  # Deprecated: Use Tag/Keyword
  # belongs_to :controlled_vocabulary_term

  validates :descriptor, presence: true
  validates :sequence, presence: true

  validates_uniqueness_of :sequence, scope: [:descriptor, :sequence_relationship_type]

  after_save :add_to_descriptor_logic_if_absent

  def to_logic_literal
    "#{sequence_relationship_type}.#{sequence_id}"
  end

  protected

  def add_to_descriptor_logic_if_absent 
    descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
  end

end

#project_idInteger

the project ID

Returns:

  • (Integer)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/gene_attribute.rb', line 26

class GeneAttribute < ApplicationRecord
  include Housekeeping
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::IsData

  acts_as_list scope: [:descriptor_id, :project_id]

  belongs_to :descriptor, class_name: 'Descriptor::Gene', inverse_of: :gene_attributes
  belongs_to :sequence, inverse_of: :gene_attributes

  # Not yet implemented.
  # Deprecated: Use Tag/Keyword
  # belongs_to :controlled_vocabulary_term

  validates :descriptor, presence: true
  validates :sequence, presence: true

  validates_uniqueness_of :sequence, scope: [:descriptor, :sequence_relationship_type]

  after_save :add_to_descriptor_logic_if_absent

  def to_logic_literal
    "#{sequence_relationship_type}.#{sequence_id}"
  end

  protected

  def add_to_descriptor_logic_if_absent 
    descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
  end

end

#sequence_idInteger

Returns the sequence id (Gene), defines the nucleotides in the attribute.

Returns:

  • (Integer)

    the sequence id (Gene), defines the nucleotides in the attribute



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/gene_attribute.rb', line 26

class GeneAttribute < ApplicationRecord
  include Housekeeping
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::IsData

  acts_as_list scope: [:descriptor_id, :project_id]

  belongs_to :descriptor, class_name: 'Descriptor::Gene', inverse_of: :gene_attributes
  belongs_to :sequence, inverse_of: :gene_attributes

  # Not yet implemented.
  # Deprecated: Use Tag/Keyword
  # belongs_to :controlled_vocabulary_term

  validates :descriptor, presence: true
  validates :sequence, presence: true

  validates_uniqueness_of :sequence, scope: [:descriptor, :sequence_relationship_type]

  after_save :add_to_descriptor_logic_if_absent

  def to_logic_literal
    "#{sequence_relationship_type}.#{sequence_id}"
  end

  protected

  def add_to_descriptor_logic_if_absent 
    descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
  end

end

#sequence_relationship_typeString

Returns a SequenceRelationship#type, defines how the sequence was used in this attribute.

Returns:

  • (String)

    a SequenceRelationship#type, defines how the sequence was used in this attribute



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/gene_attribute.rb', line 26

class GeneAttribute < ApplicationRecord
  include Housekeeping
  include Shared::Identifiers
  include Shared::Notes
  include Shared::Tags
  include Shared::IsData

  acts_as_list scope: [:descriptor_id, :project_id]

  belongs_to :descriptor, class_name: 'Descriptor::Gene', inverse_of: :gene_attributes
  belongs_to :sequence, inverse_of: :gene_attributes

  # Not yet implemented.
  # Deprecated: Use Tag/Keyword
  # belongs_to :controlled_vocabulary_term

  validates :descriptor, presence: true
  validates :sequence, presence: true

  validates_uniqueness_of :sequence, scope: [:descriptor, :sequence_relationship_type]

  after_save :add_to_descriptor_logic_if_absent

  def to_logic_literal
    "#{sequence_relationship_type}.#{sequence_id}"
  end

  protected

  def add_to_descriptor_logic_if_absent 
    descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
  end

end

Instance Method Details

#add_to_descriptor_logic_if_absentObject (protected)



55
56
57
# File 'app/models/gene_attribute.rb', line 55

def add_to_descriptor_logic_if_absent 
  descriptor.extend_gene_attribute_logic(self, :and) unless descriptor.contains_logic_for?(self)
end

#to_logic_literalObject



49
50
51
# File 'app/models/gene_attribute.rb', line 49

def to_logic_literal
  "#{sequence_relationship_type}.#{sequence_id}"
end