Class: Chemicalml::Convention::Molecular::Constraints::BondStereoCisTransMustHaveAtomRefs4

Inherits:
Constraint::NodeConstraint
  • Object
show all
Defined in:
lib/chemicalml/convention/molecular/constraints/bond_stereo_cis_trans_must_have_atom_refs4.rb

Overview

Molecular convention: <bondStereo> value C (cis) or T (trans) MUST have atomRefs4 and MUST NOT have atomRefs2.

Constant Summary collapse

CIS_TRANS_VALUES =
%w[C T].freeze

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chemicalml/convention/molecular/constraints/bond_stereo_cis_trans_must_have_atom_refs4.rb', line 13

def check_node(node, path)

  value = node.content.to_s.upcase
  return [] unless CIS_TRANS_VALUES.include?(value)

  violations = []
  if node.atom_refs4.to_s.strip.empty?
    violations << violation(
      path: (path + [describe(node)]).join('/'),
      message: "bondStereo value #{value.inspect} must have atomRefs4 " \
               '(four atom ids; two must match the parent bond)'
    )
  end
  unless node.atom_refs2.to_s.strip.empty?
    violations << violation(
      path: (path + [describe(node)]).join('/'),
      message: "bondStereo value #{value.inspect} must not have atomRefs2 " \
               '(only W/H wedge/hatch values use atomRefs2)'
    )
  end
  violations
end