Class: Chemicalml::Convention::Molecular::Constraints::AtomArrayMustBeChildOfMoleculeOrFormula
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::Molecular::Constraints::AtomArrayMustBeChildOfMoleculeOrFormula
- Defined in:
- lib/chemicalml/convention/molecular/constraints/atom_array_must_be_child_of_molecule_or_formula.rb
Overview
Molecular convention: <atomArray> MUST be a child of
<molecule> or <formula>. Any other parent is invalid.
Checked from the parent's perspective during the walk —
when visiting a non-molecule/non-formula node, look for
misplaced atomArray children.
Instance Method Summary collapse
Methods inherited from Constraint::NodeConstraint
Instance Method Details
#check_node(node, path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/chemicalml/convention/molecular/constraints/atom_array_must_be_child_of_molecule_or_formula.rb', line 13 def check_node(node, path) return [] if allowed_parent?(node) misplaced = node.wire_children.select { |c| atom_array?(c) } misplaced.map do |child| violation( path: (path + [describe(node), describe(child)]).join('/'), message: 'atomArray must be a child of molecule or formula, ' \ "but appears under #{node.element_name.inspect}" ) end end |