Class: Chemicalml::Model::Molecule

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

Overview

A molecule: ordered atom list + optional bond list + optional names and identifiers + optional count (multiplicity in a larger context).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #hash, short_name

Constructor Details

#initialize(id: nil, atoms: [], bonds: [], names: [], identifiers: [], count: nil, formal_charge: nil, title: nil) ⇒ Molecule

Returns a new instance of Molecule.



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

def initialize(id: nil, atoms: [], bonds: [], names: [],
               identifiers: [], count: nil, formal_charge: nil,
               title: nil)
  @id = id
  @atoms = atoms
  @bonds = bonds
  @names = names
  @identifiers = identifiers
  @count = count
  @formal_charge = formal_charge
  @title = title
end

Instance Attribute Details

#atomsObject

Returns the value of attribute atoms.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def atoms
  @atoms
end

#bondsObject

Returns the value of attribute bonds.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def bonds
  @bonds
end

#countObject

Returns the value of attribute count.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def count
  @count
end

#formal_chargeObject

Returns the value of attribute formal_charge.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def formal_charge
  @formal_charge
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def id
  @id
end

#identifiersObject

Returns the value of attribute identifiers.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def identifiers
  @identifiers
end

#namesObject

Returns the value of attribute names.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def names
  @names
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/chemicalml/model/molecule.rb', line 9

def title
  @title
end

Instance Method Details

#childrenObject



25
26
27
# File 'lib/chemicalml/model/molecule.rb', line 25

def children
  atoms + bonds + names + identifiers
end

#value_attributesObject



29
30
31
32
33
34
35
# File 'lib/chemicalml/model/molecule.rb', line 29

def value_attributes
  {
    id: id, atoms: atoms, bonds: bonds, names: names,
    identifiers: identifiers, count: count,
    formal_charge: formal_charge, title: title
  }
end