Class: Chemicalml::Convention::Molecular::Constraints::MoleculeAtomArrayMutuallyExclusiveWithChildren

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

Overview

Molecular convention: a <molecule> MAY hold an atomArray OR child <molecule> elements, but not both. The two are mutually exclusive ways of describing composition.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/chemicalml/convention/molecular/constraints/molecule_atom_array_mutually_exclusive_with_children.rb', line 12

def check_node(node, path)
  return [] if node.atom_array.nil?
  return [] if (node.molecules || []).empty?

  [violation(
    path: (path + [describe(node)]).join('/'),
    message: "molecule #{node.id.inspect} has both an atomArray " \
             'and child molecule elements — these are mutually exclusive'
  )]
end