Class: Chemicalml::Convention::Molecular::Constraints::AtomParityShouldIncludeParentAtom
- Inherits:
-
Constraint::DocumentConstraint
- Object
- Constraint
- Constraint::DocumentConstraint
- Chemicalml::Convention::Molecular::Constraints::AtomParityShouldIncludeParentAtom
- Defined in:
- lib/chemicalml/convention/molecular/constraints/atom_parity_should_include_parent_atom.rb
Overview
Walks the document and warns on <atomParity> elements
whose parent <atom>'s id does not appear in atomRefs4.
The CML convention requires the parent atom to be one of
the four references (otherwise the parity is meaningless).
DocumentConstraint because it needs to walk the tree and track parent-child relationships.
Instance Method Summary collapse
Instance Method Details
#check(document) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/chemicalml/convention/molecular/constraints/atom_parity_should_include_parent_atom.rb', line 16 def check(document) violations = [] visit_with_parent(document, nil) do |node, parent| next unless atom_parity?(node) next unless atom?(parent) refs = parse_refs(node.atom_refs4) next if refs.empty? next if refs.include?(parent.id) violations << violation( path: "atom[#{parent.id}]/atomParity", message: "atomParity atomRefs4 #{refs.inspect} should include the parent atom id " \ "#{parent.id.inspect}", severity: :warning, value: node.atom_refs4 ) end violations end |