Class: Chemicalml::Model::Bond

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

Overview

A bond between two atoms. Endpoint references are string IDs matching Atom#id; the kind enum follows CML conventions. Optional bond_stereo carries cis/trans/wedge/hatch info.

Constant Summary collapse

KINDS =
%i[single double triple quadruple aromatic wedge hash
dative wavy].freeze
CML_ORDER =
{
  single: "S", double: "D", triple: "T", quadruple: "Q",
  aromatic: "A", wedge: "W", hash: "H", dative: "DG", wavy: "V"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #hash, short_name

Constructor Details

#initialize(id: nil, atom_refs:, kind: :single, bond_stereo: nil) ⇒ Bond

Returns a new instance of Bond.



19
20
21
22
23
24
# File 'lib/chemicalml/model/bond.rb', line 19

def initialize(id: nil, atom_refs:, kind: :single, bond_stereo: nil)
  @id = id
  @atom_refs = atom_refs
  @kind = kind
  @bond_stereo = bond_stereo
end

Instance Attribute Details

#atom_refsObject

Returns the value of attribute atom_refs.



17
18
19
# File 'lib/chemicalml/model/bond.rb', line 17

def atom_refs
  @atom_refs
end

#bond_stereoObject

Returns the value of attribute bond_stereo.



17
18
19
# File 'lib/chemicalml/model/bond.rb', line 17

def bond_stereo
  @bond_stereo
end

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/chemicalml/model/bond.rb', line 17

def id
  @id
end

#kindObject

Returns the value of attribute kind.



17
18
19
# File 'lib/chemicalml/model/bond.rb', line 17

def kind
  @kind
end

Instance Method Details

#childrenObject



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

def children
  [bond_stereo].compact
end

#cml_orderObject



34
35
36
# File 'lib/chemicalml/model/bond.rb', line 34

def cml_order
  CML_ORDER.fetch(kind, "S")
end

#value_attributesObject



30
31
32
# File 'lib/chemicalml/model/bond.rb', line 30

def value_attributes
  { id: id, atom_refs: atom_refs, kind: kind, bond_stereo: bond_stereo }
end