Class: Chemicalml::Model::Atom

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

Overview

A chemical atom. Carries every attribute CML's <atom> carries that's chemistry-relevant: element symbol, formal charge, isotope, count (multiplicity), hydrogen count, lone pairs, radical electrons, spin multiplicity, 2D/3D coordinates, fractional coordinates. Optional atom_parity for atom-centre chirality.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #hash, short_name

Constructor Details

#initialize(element:, id: nil, formal_charge: nil, isotope: nil, count: nil, hydrogen_count: nil, lone_pairs: nil, radical_electrons: nil, spin_multiplicity: nil, title: nil, x2: nil, y2: nil, x3: nil, y3: nil, z3: nil, x_fract: nil, y_fract: nil, z_fract: nil, atom_parity: nil) ⇒ Atom

Returns a new instance of Atom.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/chemicalml/model/atom.rb', line 19

def initialize(element:, id: nil, formal_charge: nil,
               isotope: nil, count: nil, hydrogen_count: nil,
               lone_pairs: nil, radical_electrons: nil,
               spin_multiplicity: nil, title: nil,
               x2: nil, y2: nil, x3: nil, y3: nil, z3: nil,
               x_fract: nil, y_fract: nil, z_fract: nil,
               atom_parity: nil)
  @element = element
  @id = id
  @formal_charge = formal_charge
  @isotope = isotope
  @count = count
  @hydrogen_count = hydrogen_count
  @lone_pairs = lone_pairs
  @radical_electrons = radical_electrons
  @spin_multiplicity = spin_multiplicity
  @title = title
  @x2 = x2
  @y2 = y2
  @x3 = x3
  @y3 = y3
  @z3 = z3
  @x_fract = x_fract
  @y_fract = y_fract
  @z_fract = z_fract
  @atom_parity = atom_parity
end

Instance Attribute Details

#atom_parityObject

Returns the value of attribute atom_parity.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def atom_parity
  @atom_parity
end

#countObject

Returns the value of attribute count.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def count
  @count
end

#elementObject

Returns the value of attribute element.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def element
  @element
end

#formal_chargeObject

Returns the value of attribute formal_charge.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def formal_charge
  @formal_charge
end

#hydrogen_countObject

Returns the value of attribute hydrogen_count.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def hydrogen_count
  @hydrogen_count
end

#idObject

Returns the value of attribute id.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def id
  @id
end

#isotopeObject

Returns the value of attribute isotope.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def isotope
  @isotope
end

#lone_pairsObject

Returns the value of attribute lone_pairs.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def lone_pairs
  @lone_pairs
end

#radical_electronsObject

Returns the value of attribute radical_electrons.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def radical_electrons
  @radical_electrons
end

#spin_multiplicityObject

Returns the value of attribute spin_multiplicity.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def spin_multiplicity
  @spin_multiplicity
end

#titleObject

Returns the value of attribute title.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def title
  @title
end

#x2Object

Returns the value of attribute x2.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def x2
  @x2
end

#x3Object

Returns the value of attribute x3.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def x3
  @x3
end

#x_fractObject

Returns the value of attribute x_fract.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def x_fract
  @x_fract
end

#y2Object

Returns the value of attribute y2.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def y2
  @y2
end

#y3Object

Returns the value of attribute y3.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def y3
  @y3
end

#y_fractObject

Returns the value of attribute y_fract.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def y_fract
  @y_fract
end

#z3Object

Returns the value of attribute z3.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def z3
  @z3
end

#z_fractObject

Returns the value of attribute z_fract.



12
13
14
# File 'lib/chemicalml/model/atom.rb', line 12

def z_fract
  @z_fract
end

Instance Method Details

#childrenObject



47
48
49
# File 'lib/chemicalml/model/atom.rb', line 47

def children
  [atom_parity].compact
end

#value_attributesObject



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/chemicalml/model/atom.rb', line 51

def value_attributes
  {
    element: element, id: id, formal_charge: formal_charge,
    isotope: isotope, count: count, hydrogen_count: hydrogen_count,
    lone_pairs: lone_pairs, radical_electrons: radical_electrons,
    spin_multiplicity: spin_multiplicity, title: title,
    x2: x2, y2: y2, x3: x3, y3: y3, z3: z3,
    x_fract: x_fract, y_fract: y_fract, z_fract: z_fract,
    atom_parity: atom_parity
  }
end