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. The atoms can be in the child form (<atom> elements) or the parallel-array form (atomID attribute with whitespace-separated ids).

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
# File 'lib/chemicalml/convention/molecular/constraints/atom_array_must_contain_atoms.rb', line 13

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

  aa = node.atom_array
  return [] if has_child_atoms?(aa) || has_parallel_array_atoms?(aa)

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