Class: Chemicalml::Model::Reaction

Inherits:
Node
  • Object
show all
Defined in:
lib/chemicalml/model/reaction.rb

Overview

A chemical reaction. Reactants, products, arrow kind, optional conditions (above / below the arrow).

Constant Summary collapse

ARROWS =
%i[forward reverse equilibrium resonance].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #hash, short_name

Constructor Details

#initialize(id: nil, reactant_list:, product_list:, arrow: :forward, conditions_above: nil, conditions_below: nil, title: nil, type: nil) ⇒ Reaction

Returns a new instance of Reaction.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chemicalml/model/reaction.rb', line 13

def initialize(id: nil, reactant_list:, product_list:,
               arrow: :forward, conditions_above: nil,
               conditions_below: nil, title: nil, type: nil)
  @id = id
  @reactant_list = reactant_list
  @product_list = product_list
  @arrow = arrow
  @conditions_above = conditions_above
  @conditions_below = conditions_below
  @title = title
  @type = type
end

Instance Attribute Details

#arrowObject

Returns the value of attribute arrow.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def arrow
  @arrow
end

#conditions_aboveObject

Returns the value of attribute conditions_above.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def conditions_above
  @conditions_above
end

#conditions_belowObject

Returns the value of attribute conditions_below.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def conditions_below
  @conditions_below
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def id
  @id
end

#product_listObject

Returns the value of attribute product_list.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def product_list
  @product_list
end

#reactant_listObject

Returns the value of attribute reactant_list.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def reactant_list
  @reactant_list
end

#titleObject

Returns the value of attribute title.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def title
  @title
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/chemicalml/model/reaction.rb', line 10

def type
  @type
end

Instance Method Details

#childrenObject



26
27
28
# File 'lib/chemicalml/model/reaction.rb', line 26

def children
  [reactant_list, product_list]
end

#value_attributesObject



30
31
32
33
34
35
36
37
38
# File 'lib/chemicalml/model/reaction.rb', line 30

def value_attributes
  {
    id: id, reactant_list: reactant_list,
    product_list: product_list, arrow: arrow,
    conditions_above: conditions_above,
    conditions_below: conditions_below,
    title: title, type: type
  }
end