Class: GeneAttribute

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Identifiable, Shared::IsData, Shared::Notable, Shared::Taggable
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 Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (Integer) controlled_vocabulary_term_id

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::Identifiable
  include Shared::IsData
  include Shared::Notable
  include Shared::Taggable
  
  acts_as_list scope: [:descriptor_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

- (Integer) descriptor_id

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::Identifiable
  include Shared::IsData
  include Shared::Notable
  include Shared::Taggable
  
  acts_as_list scope: [:descriptor_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

- (Integer) project_id

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::Identifiable
  include Shared::IsData
  include Shared::Notable
  include Shared::Taggable
  
  acts_as_list scope: [:descriptor_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

- (Integer) sequence_id

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::Identifiable
  include Shared::IsData
  include Shared::Notable
  include Shared::Taggable
  
  acts_as_list scope: [:descriptor_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

- (String) sequence_relationship_type

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::Identifiable
  include Shared::IsData
  include Shared::Notable
  include Shared::Taggable
  
  acts_as_list scope: [:descriptor_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

- (Object) add_to_descriptor_logic_if_absent (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

- (Object) to_logic_literal



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

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