Class: Chemicalml::Convention::Molecular::Constraints::BondStereoAtomRefs4ShouldBeDistinct
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::Molecular::Constraints::BondStereoAtomRefs4ShouldBeDistinct
- Defined in:
- lib/chemicalml/convention/molecular/constraints/bond_stereo_atom_refs4_should_be_distinct.rb
Overview
A <bondStereo> with atomRefs4 (used by C/T stereo)
SHOULD reference four distinct atom ids. Duplicate ids make
the stereo descriptor meaningless. Warning severity.
Instance Method Summary collapse
Methods inherited from Constraint::NodeConstraint
Instance Method Details
#check_node(node, _path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chemicalml/convention/molecular/constraints/bond_stereo_atom_refs4_should_be_distinct.rb', line 14 def check_node(node, _path) ids = parse_refs(node.atom_refs4) return [] if ids.size < 2 return [] if ids.uniq.size == ids.size duplicates = ids.group_by { |i| i }.select { |_, v| v.size > 1 }.keys [violation(path: yield_path(node), message: "bondStereo #{node.id.inspect} atomRefs4 should reference four distinct atoms; " \ "duplicate ids: #{duplicates.inspect}", severity: :warning, value: node.atom_refs4)] end |