Class: Chemicalml::Convention::Molecular::Constraints::AtomArrayMustContainAtoms

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

Overview

atomArray MUST contain at least one atom child per the molecular convention.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/chemicalml/convention/molecular/constraints/atom_array_must_contain_atoms.rb', line 10

def check_node(node, path)
  return [] unless molecule?(node)
  return [] unless node.atom_array

  atoms = node.atom_array.atoms || []
  return [] unless atoms.empty?

  [violation(path: path.empty? ? "molecule" : path.join("/"),
             message: "atomArray must contain at least one atom")]
end