Class: Chemicalml::Convention::Molecular::Constraints::ReferencesShouldResolve

Inherits:
Constraint::DocumentConstraint show all
Defined in:
lib/chemicalml/convention/molecular/constraints/references_should_resolve.rb

Overview

Walks the document via Cml::ReferenceResolver and reports every bond whose atomRefs2 references atoms that don't exist in the parent molecule. Warning severity — there are edge cases (inter-molecular bonds in transition states).

DocumentConstraint because it needs the whole tree to resolve references.

Instance Method Summary collapse

Instance Method Details

#check(document) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/chemicalml/convention/molecular/constraints/references_should_resolve.rb', line 16

def check(document)
  resolver = Chemicalml::Cml::ReferenceResolver.new(document)
  resolver.unresolved_refs.map do |entry|
    violation(path: describe(entry[:node]),
              message: "bond #{entry[:node].id.inspect} #{entry[:attr]} references " \
                       "missing atoms: #{entry[:missing].inspect}",
              severity: :warning,
              value: entry[:missing])
  end
end