chemicalml 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +23 -0
- data/CLAUDE.md +49 -1
- data/README.adoc +154 -26
- data/TODO.align/61-parallel-array-attrs.md +54 -0
- data/TODO.align/62-per-element-attribute-gaps.md +49 -0
- data/TODO.align/63-universal-children-mixin.md +42 -0
- data/TODO.align/64-per-element-child-gaps.md +81 -0
- data/TODO.align/65-simple-unit-convention.md +40 -0
- data/TODO.align/66-schema24-legacy-children.md +32 -0
- data/TODO.align/67-final-verification.md +32 -0
- data/TODO.align/68-detection-coverage.md +33 -0
- data/TODO.align/69-json-yaml-roundtrip.md +27 -0
- data/TODO.align/70-iterative-walker.md +40 -0
- data/TODO.align/71-violation-value.md +25 -0
- data/TODO.align/72-close-child-gaps.md +66 -0
- data/TODO.align/73-schema24-parse-limitation.md +64 -0
- data/TODO.align/74-final-verification-round18.md +15 -0
- data/TODO.align/75-key-value-mappings.md +43 -0
- data/TODO.align/76-schema24-workaround.md +57 -0
- data/TODO.align/77-convention-coverage-matrix.md +31 -0
- data/TODO.align/78-fixture-audit.md +23 -0
- data/TODO.align/79-final-verification-round19.md +15 -0
- data/TODO.align/80-xsd-enum-constants.md +35 -0
- data/TODO.align/81-enum-validation-constraints.md +29 -0
- data/TODO.align/82-reference-resolver.md +33 -0
- data/TODO.align/83-toml-roundtrip.md +20 -0
- data/TODO.align/84-final-verification-round21.md +16 -0
- data/TODO.align/85-bond-distinct-atoms.md +25 -0
- data/TODO.align/86-references-should-resolve.md +20 -0
- data/TODO.align/87-cli-utility.md +26 -0
- data/TODO.align/88-diverse-fixtures.md +26 -0
- data/TODO.align/89-final-verification-round22.md +15 -0
- data/TODO.align/90-bond-stereo-completeness.md +31 -0
- data/TODO.align/91-atomparity-distinct.md +21 -0
- data/TODO.align/92-unit-dictionary-completeness.md +28 -0
- data/TODO.align/93-yard-docs.md +23 -0
- data/TODO.align/94-final-verification-round23.md +15 -0
- data/TODO.align/README.round17.md +28 -0
- data/TODO.align/README.round18.md +37 -0
- data/TODO.align/README.round19.md +40 -0
- data/TODO.align/README.round20.md +49 -0
- data/TODO.align/README.round21.md +35 -0
- data/TODO.align/README.round22.md +48 -0
- data/TODO.align/README.round23.md +46 -0
- data/TODO.align/README.round24.md +53 -0
- data/TODO.align/README.round25.md +66 -0
- data/TODO.align/README.round26.md +55 -0
- data/TODO.align/README.round27.md +51 -0
- data/TODO.align/README.round28.md +61 -0
- data/TODO.align/README.round29.md +64 -0
- data/TODO.align/README.round30.md +50 -0
- data/TODO.align/README.round31.md +54 -0
- data/TODO.align/README.round32.md +67 -0
- data/TODO.align/README.round33.md +62 -0
- data/TODO.align/README.round34.md +70 -0
- data/docs/constraints.md +161 -0
- data/docs/generate_constraint_docs.rb +44 -0
- data/exe/chemicalml +6 -0
- data/lib/chemicalml/cli/base.rb +68 -0
- data/lib/chemicalml/cli/command.rb +43 -0
- data/lib/chemicalml/cli/constraints_command.rb +27 -0
- data/lib/chemicalml/cli/conventions_command.rb +14 -0
- data/lib/chemicalml/cli/dictionaries_command.rb +14 -0
- data/lib/chemicalml/cli/elements_command.rb +17 -0
- data/lib/chemicalml/cli/enums_command.rb +17 -0
- data/lib/chemicalml/cli/info_command.rb +77 -0
- data/lib/chemicalml/cli/inspect_command.rb +39 -0
- data/lib/chemicalml/cli/validate_command.rb +54 -0
- data/lib/chemicalml/cli.rb +43 -0
- data/lib/chemicalml/cml/base/abundance.rb +18 -8
- data/lib/chemicalml/cml/base/action.rb +34 -16
- data/lib/chemicalml/cml/base/action_list.rb +35 -17
- data/lib/chemicalml/cml/base/alternative.rb +13 -4
- data/lib/chemicalml/cml/base/amount.rb +14 -6
- data/lib/chemicalml/cml/base/angle.rb +28 -13
- data/lib/chemicalml/cml/base/annotation.rb +14 -6
- data/lib/chemicalml/cml/base/any_cml.rb +12 -5
- data/lib/chemicalml/cml/base/appinfo.rb +14 -6
- data/lib/chemicalml/cml/base/arg.rb +47 -13
- data/lib/chemicalml/cml/base/array.rb +40 -19
- data/lib/chemicalml/cml/base/array_list.rb +14 -6
- data/lib/chemicalml/cml/base/atom.rb +84 -28
- data/lib/chemicalml/cml/base/atom_array.rb +60 -23
- data/lib/chemicalml/cml/base/atom_parity.rb +14 -6
- data/lib/chemicalml/cml/base/atom_set.rb +14 -6
- data/lib/chemicalml/cml/base/atom_type.rb +25 -9
- data/lib/chemicalml/cml/base/atom_type_list.rb +22 -8
- data/lib/chemicalml/cml/base/atomic_basis_function.rb +33 -13
- data/lib/chemicalml/cml/base/band.rb +21 -8
- data/lib/chemicalml/cml/base/band_list.rb +15 -7
- data/lib/chemicalml/cml/base/basis_set.rb +24 -9
- data/lib/chemicalml/cml/base/bond.rb +36 -10
- data/lib/chemicalml/cml/base/bond_array.rb +34 -11
- data/lib/chemicalml/cml/base/bond_set.rb +14 -6
- data/lib/chemicalml/cml/base/bond_stereo.rb +20 -9
- data/lib/chemicalml/cml/base/bond_type.rb +23 -8
- data/lib/chemicalml/cml/base/bond_type_list.rb +22 -8
- data/lib/chemicalml/cml/base/cell_parameter.rb +28 -10
- data/lib/chemicalml/cml/base/cml_module.rb +36 -11
- data/lib/chemicalml/cml/base/common_children.rb +35 -0
- data/lib/chemicalml/cml/base/complex_object.rb +12 -5
- data/lib/chemicalml/cml/base/condition_list.rb +26 -10
- data/lib/chemicalml/cml/base/crystal.rb +26 -10
- data/lib/chemicalml/cml/base/definition.rb +12 -5
- data/lib/chemicalml/cml/base/description.rb +14 -6
- data/lib/chemicalml/cml/base/dictionary.rb +27 -10
- data/lib/chemicalml/cml/base/dictionary_entry.rb +67 -8
- data/lib/chemicalml/cml/base/dimension.rb +26 -12
- data/lib/chemicalml/cml/base/document.rb +18 -8
- data/lib/chemicalml/cml/base/documentation.rb +12 -5
- data/lib/chemicalml/cml/base/eigen.rb +32 -8
- data/lib/chemicalml/cml/base/electron.rb +26 -12
- data/lib/chemicalml/cml/base/enumeration.rb +16 -7
- data/lib/chemicalml/cml/base/expression.rb +21 -6
- data/lib/chemicalml/cml/base/float.rb +22 -10
- data/lib/chemicalml/cml/base/float_array.rb +24 -11
- data/lib/chemicalml/cml/base/formula.rb +31 -10
- data/lib/chemicalml/cml/base/fragment.rb +30 -12
- data/lib/chemicalml/cml/base/fragment_list.rb +24 -9
- data/lib/chemicalml/cml/base/gradient.rb +19 -6
- data/lib/chemicalml/cml/base/identifier.rb +18 -8
- data/lib/chemicalml/cml/base/integer.rb +22 -10
- data/lib/chemicalml/cml/base/integer_array.rb +24 -11
- data/lib/chemicalml/cml/base/isotope.rb +28 -9
- data/lib/chemicalml/cml/base/isotope_list.rb +17 -8
- data/lib/chemicalml/cml/base/join.rb +25 -9
- data/lib/chemicalml/cml/base/kpoint.rb +16 -7
- data/lib/chemicalml/cml/base/kpoint_list.rb +15 -7
- data/lib/chemicalml/cml/base/label.rb +14 -6
- data/lib/chemicalml/cml/base/lattice.rb +35 -10
- data/lib/chemicalml/cml/base/lattice_vector.rb +16 -7
- data/lib/chemicalml/cml/base/length.rb +26 -12
- data/lib/chemicalml/cml/base/line3.rb +18 -8
- data/lib/chemicalml/cml/base/link.rb +41 -20
- data/lib/chemicalml/cml/base/list.rb +22 -10
- data/lib/chemicalml/cml/base/map.rb +32 -11
- data/lib/chemicalml/cml/base/matrix.rb +32 -15
- data/lib/chemicalml/cml/base/mechanism.rb +20 -7
- data/lib/chemicalml/cml/base/mechanism_component.rb +14 -6
- data/lib/chemicalml/cml/base/metadata.rb +18 -8
- data/lib/chemicalml/cml/base/metadata_list.rb +27 -8
- data/lib/chemicalml/cml/base/molecule.rb +90 -26
- data/lib/chemicalml/cml/base/molecule_list.rb +26 -8
- data/lib/chemicalml/cml/base/name.rb +10 -4
- data/lib/chemicalml/cml/base/object.rb +18 -8
- data/lib/chemicalml/cml/base/observation.rb +16 -7
- data/lib/chemicalml/cml/base/operator.rb +14 -6
- data/lib/chemicalml/cml/base/parameter.rb +33 -13
- data/lib/chemicalml/cml/base/parameter_list.rb +27 -8
- data/lib/chemicalml/cml/base/particle.rb +20 -9
- data/lib/chemicalml/cml/base/peak.rb +71 -26
- data/lib/chemicalml/cml/base/peak_group.rb +62 -26
- data/lib/chemicalml/cml/base/peak_list.rb +24 -9
- data/lib/chemicalml/cml/base/peak_structure.rb +40 -13
- data/lib/chemicalml/cml/base/plane3.rb +14 -6
- data/lib/chemicalml/cml/base/point3.rb +14 -6
- data/lib/chemicalml/cml/base/potential.rb +17 -6
- data/lib/chemicalml/cml/base/potential_form.rb +30 -7
- data/lib/chemicalml/cml/base/potential_list.rb +15 -7
- data/lib/chemicalml/cml/base/product.rb +45 -10
- data/lib/chemicalml/cml/base/product_list.rb +29 -9
- data/lib/chemicalml/cml/base/property.rb +29 -11
- data/lib/chemicalml/cml/base/property_list.rb +23 -8
- data/lib/chemicalml/cml/base/reactant.rb +45 -10
- data/lib/chemicalml/cml/base/reactant_list.rb +29 -9
- data/lib/chemicalml/cml/base/reaction.rb +74 -20
- data/lib/chemicalml/cml/base/reaction_list.rb +23 -8
- data/lib/chemicalml/cml/base/reaction_scheme.rb +43 -13
- data/lib/chemicalml/cml/base/reaction_step.rb +30 -12
- data/lib/chemicalml/cml/base/reaction_step_list.rb +30 -11
- data/lib/chemicalml/cml/base/reactive_centre.rb +31 -6
- data/lib/chemicalml/cml/base/region.rb +20 -9
- data/lib/chemicalml/cml/base/related_entry.rb +11 -3
- data/lib/chemicalml/cml/base/sample.rb +30 -7
- data/lib/chemicalml/cml/base/scalar.rb +32 -15
- data/lib/chemicalml/cml/base/spectator.rb +25 -6
- data/lib/chemicalml/cml/base/spectator_list.rb +20 -7
- data/lib/chemicalml/cml/base/spectrum.rb +57 -18
- data/lib/chemicalml/cml/base/spectrum_data.rb +19 -9
- data/lib/chemicalml/cml/base/spectrum_list.rb +28 -9
- data/lib/chemicalml/cml/base/sphere3.rb +14 -6
- data/lib/chemicalml/cml/base/stmml.rb +12 -5
- data/lib/chemicalml/cml/base/string.rb +14 -6
- data/lib/chemicalml/cml/base/string_array.rb +22 -10
- data/lib/chemicalml/cml/base/substance.rb +36 -14
- data/lib/chemicalml/cml/base/substance_list.rb +29 -10
- data/lib/chemicalml/cml/base/symmetry.rb +31 -9
- data/lib/chemicalml/cml/base/system.rb +21 -10
- data/lib/chemicalml/cml/base/table.rb +38 -13
- data/lib/chemicalml/cml/base/table_cell.rb +12 -5
- data/lib/chemicalml/cml/base/table_content.rb +19 -9
- data/lib/chemicalml/cml/base/table_header.rb +15 -7
- data/lib/chemicalml/cml/base/table_header_cell.rb +22 -10
- data/lib/chemicalml/cml/base/table_row.rb +15 -7
- data/lib/chemicalml/cml/base/table_row_list.rb +15 -7
- data/lib/chemicalml/cml/base/tcell.rb +16 -7
- data/lib/chemicalml/cml/base/torsion.rb +28 -13
- data/lib/chemicalml/cml/base/transform3.rb +12 -5
- data/lib/chemicalml/cml/base/transition_state.rb +23 -5
- data/lib/chemicalml/cml/base/trow.rb +22 -6
- data/lib/chemicalml/cml/base/unit.rb +39 -16
- data/lib/chemicalml/cml/base/unit_list.rb +34 -12
- data/lib/chemicalml/cml/base/unit_type.rb +27 -10
- data/lib/chemicalml/cml/base/unit_type_list.rb +29 -11
- data/lib/chemicalml/cml/base/vector3.rb +14 -6
- data/lib/chemicalml/cml/base/xaxis.rb +30 -10
- data/lib/chemicalml/cml/base/yaxis.rb +30 -10
- data/lib/chemicalml/cml/base/z_matrix.rb +26 -5
- data/lib/chemicalml/cml/base.rb +139 -138
- data/lib/chemicalml/cml/canonical_comparison.rb +54 -0
- data/lib/chemicalml/cml/elements.rb +145 -136
- data/lib/chemicalml/cml/enums.rb +55 -0
- data/lib/chemicalml/cml/namespace.rb +2 -3
- data/lib/chemicalml/cml/patterns.rb +33 -0
- data/lib/chemicalml/cml/reference_resolver.rb +137 -0
- data/lib/chemicalml/cml/role.rb +138 -138
- data/lib/chemicalml/cml/schema24/configuration.rb +11 -1
- data/lib/chemicalml/cml/schema24.rb +139 -139
- data/lib/chemicalml/cml/schema3.rb +123 -123
- data/lib/chemicalml/cml/visitable.rb +77 -3
- data/lib/chemicalml/cml/wire_class_registry.rb +3 -3
- data/lib/chemicalml/cml.rb +163 -129
- data/lib/chemicalml/context_configuration.rb +4 -2
- data/lib/chemicalml/convention/cascade/constraints/reaction_scheme_must_have_content.rb +33 -0
- data/lib/chemicalml/convention/cascade/constraints/reaction_step_list_must_contain_steps.rb +31 -0
- data/lib/chemicalml/convention/cascade/constraints/reaction_step_must_have_reaction_or_lists.rb +33 -0
- data/lib/chemicalml/convention/cascade/constraints/reactive_centre_atom_refs_should_be_present.rb +34 -0
- data/lib/chemicalml/convention/cascade/constraints.rb +18 -0
- data/lib/chemicalml/convention/cascade.rb +43 -0
- data/lib/chemicalml/convention/compchem/constraints/array_rules.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/calculation_requires_finalization.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/compchem_module_must_contain_job_list.rb +2 -1
- data/lib/chemicalml/convention/compchem/constraints/environment_at_most_one_property_list.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/environment_must_not_contain_parameter.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/finalization_at_most_one_molecule.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/finalization_at_most_one_property_list.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/finalization_must_have_content.rb +44 -0
- data/lib/chemicalml/convention/compchem/constraints/finalization_must_not_contain_parameter.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/initialization_at_most_one_molecule.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/initialization_at_most_one_parameter_list.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/initialization_must_have_content.rb +54 -0
- data/lib/chemicalml/convention/compchem/constraints/initialization_must_not_contain_property.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/job_list_module_must_have_id.rb +1 -0
- data/lib/chemicalml/convention/compchem/constraints/job_module_at_most_one_environment.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/job_module_at_most_one_finalization.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/job_module_must_have_id.rb +1 -0
- data/lib/chemicalml/convention/compchem/constraints/job_must_contain_initialization.rb +1 -0
- data/lib/chemicalml/convention/compchem/constraints/matrix_rules.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints/scalar_units.rb +1 -1
- data/lib/chemicalml/convention/compchem/constraints.rb +4 -0
- data/lib/chemicalml/convention/compchem.rb +4 -2
- data/lib/chemicalml/convention/constraint.rb +40 -9
- data/lib/chemicalml/convention/coordinator.rb +4 -3
- data/lib/chemicalml/convention/detection.rb +10 -4
- data/lib/chemicalml/convention/dictionary/constraints/dictionary_must_have_namespace.rb +1 -0
- data/lib/chemicalml/convention/dictionary/constraints/dictionary_namespace_should_end_with_slash_or_hash.rb +1 -1
- data/lib/chemicalml/convention/dictionary/constraints/entry_id_must_match_pattern.rb +1 -1
- data/lib/chemicalml/convention/dictionary/constraints/entry_ids_unique_within_dictionary.rb +1 -1
- data/lib/chemicalml/convention/dictionary/constraints/entry_must_contain_definition.rb +1 -0
- data/lib/chemicalml/convention/dictionary/constraints/entry_must_have_id_and_term.rb +1 -1
- data/lib/chemicalml/convention/dictionary/constraints/entry_must_have_unit_type.rb +1 -0
- data/lib/chemicalml/convention/dictionary/constraints/entry_units_co_constraints.rb +1 -1
- data/lib/chemicalml/convention/dictionary/constraints.rb +8 -8
- data/lib/chemicalml/convention/dictionary.rb +2 -2
- data/lib/chemicalml/convention/molecular/constraints/atom_array_must_be_child_of_molecule_or_formula.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/atom_array_must_contain_atoms.rb +15 -6
- data/lib/chemicalml/convention/molecular/constraints/atom_coordinates_must_be_paired.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/atom_element_type_should_be_in_periodic_table.rb +39 -0
- data/lib/chemicalml/convention/molecular/constraints/atom_id_must_match_pattern.rb +3 -2
- data/lib/chemicalml/convention/molecular/constraints/atom_ids_unique_within_molecule.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/atom_must_have_element_type.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/atom_must_have_id.rb +2 -1
- data/lib/chemicalml/convention/molecular/constraints/atom_parity_atom_refs4_should_be_distinct.rb +44 -0
- data/lib/chemicalml/convention/molecular/constraints/atom_parity_should_include_parent_atom.rb +65 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_array_must_be_child_of_molecule.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_atom_refs2_should_be_distinct.rb +44 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_id_should_match_pattern.rb +38 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_ids_unique_within_molecule.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_must_have_atom_refs2.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/bond_must_have_order.rb +2 -1
- data/lib/chemicalml/convention/molecular/constraints/bond_must_reference_atoms_in_same_molecule.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_order_other_must_have_dict_ref.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_order_should_be_in_enum.rb +39 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_order_should_not_be_numeric.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/bond_stereo_atom_refs4_should_be_distinct.rb +43 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_stereo_cis_trans_must_have_atom_refs4.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/bond_stereo_other_must_have_dict_ref.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_stereo_should_be_in_enum.rb +38 -0
- data/lib/chemicalml/convention/molecular/constraints/bond_stereo_wedge_hash_must_have_atom_refs2.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/dict_ref_should_resolve.rb +59 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_atom_array_mutually_exclusive_with_children.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_bond_array_mutually_exclusive_with_children.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_chirality_should_be_in_enum.rb +38 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_count_must_not_appear_on_top_level.rb +1 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_id_should_match_pattern.rb +38 -0
- data/lib/chemicalml/convention/molecular/constraints/molecule_must_have_id.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/property_must_have_dict_ref.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints/property_scalar_data_type_matches_dictionary.rb +58 -0
- data/lib/chemicalml/convention/molecular/constraints/references_should_resolve.rb +37 -0
- data/lib/chemicalml/convention/molecular/constraints/scalar_must_have_data_type.rb +1 -1
- data/lib/chemicalml/convention/molecular/constraints.rb +49 -23
- data/lib/chemicalml/convention/molecular.rb +15 -2
- data/lib/chemicalml/convention/registry.rb +79 -11
- data/lib/chemicalml/convention/simple_unit/constraints/root_must_be_unit_list.rb +24 -0
- data/lib/chemicalml/convention/simple_unit/constraints/unit_must_have_power.rb +32 -0
- data/lib/chemicalml/convention/simple_unit/constraints/unit_must_have_symbol.rb +31 -0
- data/lib/chemicalml/convention/simple_unit/constraints.rb +16 -0
- data/lib/chemicalml/convention/simple_unit.rb +37 -0
- data/lib/chemicalml/convention/spectroscopy/constraints/peak_list_must_contain_peaks.rb +31 -0
- data/lib/chemicalml/convention/spectroscopy/constraints/peak_should_have_values.rb +34 -0
- data/lib/chemicalml/convention/spectroscopy/constraints/spectrum_must_have_content.rb +31 -0
- data/lib/chemicalml/convention/spectroscopy/constraints/spectrum_must_have_convention.rb +32 -0
- data/lib/chemicalml/convention/spectroscopy/constraints/spectrum_must_have_format.rb +31 -0
- data/lib/chemicalml/convention/spectroscopy/constraints.rb +20 -0
- data/lib/chemicalml/convention/spectroscopy.rb +41 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_list_must_contain_at_least_one_unit.rb +1 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_list_must_have_namespace.rb +1 -1
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_contain_definition.rb +1 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_id.rb +1 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_multiplier_or_constant_to_si.rb +34 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_parent_si.rb +32 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_symbol_and_unit_type.rb +1 -1
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_title.rb +32 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_parent_si_should_resolve.rb +45 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints/unit_unit_type_should_resolve.rb +46 -0
- data/lib/chemicalml/convention/unit_dictionary/constraints.rb +10 -0
- data/lib/chemicalml/convention/unit_dictionary.rb +7 -2
- data/lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_id_must_match_pattern.rb +1 -1
- data/lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_list_must_contain_at_least_one_unit_type.rb +1 -0
- data/lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_list_must_have_namespace.rb +1 -1
- data/lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_must_contain_definition.rb +1 -0
- data/lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_must_have_id_and_name.rb +1 -1
- data/lib/chemicalml/convention/unit_type_dictionary.rb +2 -2
- data/lib/chemicalml/convention/validation_report.rb +30 -3
- data/lib/chemicalml/convention/violation.rb +9 -3
- data/lib/chemicalml/convention.rb +41 -14
- data/lib/chemicalml/dictionary.rb +13 -9
- data/lib/chemicalml/logger.rb +47 -0
- data/lib/chemicalml/schema/definition.rb +2 -2
- data/lib/chemicalml/schema.rb +7 -7
- data/lib/chemicalml/version.rb +1 -1
- data/lib/chemicalml/versioned_parser.rb +10 -10
- data/lib/chemicalml.rb +78 -15
- data/lib/tasks/reference_fetch.rake +30 -31
- data/lib/tasks/scrape_fixtures.rake +23 -24
- metadata +114 -3
|
@@ -27,10 +27,10 @@ module Chemicalml
|
|
|
27
27
|
|
|
28
28
|
def element_name
|
|
29
29
|
xml_mapping = self.class.mappings[:xml]
|
|
30
|
-
root = xml_mapping
|
|
31
|
-
root
|
|
30
|
+
root = xml_mapping&.root
|
|
31
|
+
root&.name || self.class.name.split('::').last
|
|
32
32
|
rescue StandardError
|
|
33
|
-
self.class.name.split(
|
|
33
|
+
self.class.name.split('::').last
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def collect_wire_nodes(value)
|
|
@@ -60,6 +60,80 @@ module Chemicalml
|
|
|
60
60
|
rescue StandardError
|
|
61
61
|
false
|
|
62
62
|
end
|
|
63
|
+
|
|
64
|
+
# Walk the entire subtree from this node, yielding each wire
|
|
65
|
+
# instance. DFS pre-order. Useful for find-style queries and
|
|
66
|
+
# aggregate counts.
|
|
67
|
+
#
|
|
68
|
+
# @yield [Lutaml::Model::Serializable] each wire node.
|
|
69
|
+
# @return [Enumerator] without a block.
|
|
70
|
+
def each_wire_node(&)
|
|
71
|
+
return to_enum(:each_wire_node) unless block_given?
|
|
72
|
+
|
|
73
|
+
walk(self, &)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Iterate every Atom in the subtree.
|
|
77
|
+
def each_atom(&)
|
|
78
|
+
return to_enum(:each_atom) unless block_given?
|
|
79
|
+
|
|
80
|
+
each_wire_node { |n| yield(n) if n.is_a?(Chemicalml::Cml::Role::Atom) }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Iterate every Bond in the subtree.
|
|
84
|
+
def each_bond(&)
|
|
85
|
+
return to_enum(:each_bond) unless block_given?
|
|
86
|
+
|
|
87
|
+
each_wire_node { |n| yield(n) if n.is_a?(Chemicalml::Cml::Role::Bond) }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Iterate every Molecule in the subtree (top-level + nested).
|
|
91
|
+
def each_molecule(&)
|
|
92
|
+
return to_enum(:each_molecule) unless block_given?
|
|
93
|
+
|
|
94
|
+
each_wire_node { |n| yield(n) if n.is_a?(Chemicalml::Cml::Role::Molecule) }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Find the first atom in the subtree with the given id, or nil.
|
|
98
|
+
def find_atom(id)
|
|
99
|
+
each_atom.find { |a| a.node_id == id }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Find the first bond in the subtree with the given id, or nil.
|
|
103
|
+
def find_bond(id)
|
|
104
|
+
each_bond.find { |b| b.node_id == id }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Find the first molecule in the subtree with the given id.
|
|
108
|
+
def find_molecule(id)
|
|
109
|
+
each_molecule.find { |m| m.node_id == id }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Count of every Atom in the subtree.
|
|
113
|
+
def atom_count
|
|
114
|
+
each_atom.count
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Count of every Bond in the subtree.
|
|
118
|
+
def bond_count
|
|
119
|
+
each_bond.count
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Count of every Molecule in the subtree (recursive).
|
|
123
|
+
def molecule_count
|
|
124
|
+
each_molecule.count
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
private
|
|
128
|
+
|
|
129
|
+
def walk(node, &block)
|
|
130
|
+
return unless node.is_a?(Lutaml::Model::Serializable)
|
|
131
|
+
|
|
132
|
+
block.call(node)
|
|
133
|
+
return unless node.is_a?(Chemicalml::Cml::Visitable)
|
|
134
|
+
|
|
135
|
+
node.wire_children.each { |c| walk(c, &block) }
|
|
136
|
+
end
|
|
63
137
|
end
|
|
64
138
|
end
|
|
65
139
|
end
|
|
@@ -13,7 +13,7 @@ module Chemicalml
|
|
|
13
13
|
# walks the schema module's constants lazily.
|
|
14
14
|
module WireClassRegistry
|
|
15
15
|
SCHEMA_MODULES = {
|
|
16
|
-
schema3:
|
|
16
|
+
schema3: Chemicalml::Cml::Schema3,
|
|
17
17
|
schema24: Chemicalml::Cml::Schema24
|
|
18
18
|
}.freeze
|
|
19
19
|
|
|
@@ -26,14 +26,14 @@ module Chemicalml
|
|
|
26
26
|
unless schema_module.const_defined?(role_name, false)
|
|
27
27
|
raise ArgumentError,
|
|
28
28
|
"#{schema_module.name} does not define #{role_name} " \
|
|
29
|
-
|
|
29
|
+
'(not all elements exist in every schema version)'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
schema_module.const_get(role_name, false)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def self.role_name_for(role)
|
|
36
|
-
return role.name.split(
|
|
36
|
+
return role.name.split('::').last if role.is_a?(::Module)
|
|
37
37
|
|
|
38
38
|
role.to_s
|
|
39
39
|
end
|
data/lib/chemicalml/cml.rb
CHANGED
|
@@ -8,140 +8,174 @@ module Chemicalml
|
|
|
8
8
|
# and are included by both schema-versioned class hierarchies.
|
|
9
9
|
module Cml
|
|
10
10
|
# Structural modules (each in its own file, loaded independently).
|
|
11
|
-
autoload :Base,
|
|
12
|
-
autoload :
|
|
13
|
-
autoload :
|
|
14
|
-
autoload :
|
|
15
|
-
autoload :
|
|
16
|
-
autoload :
|
|
17
|
-
autoload :
|
|
18
|
-
autoload :
|
|
11
|
+
autoload :Base, 'chemicalml/cml/base'
|
|
12
|
+
autoload :CanonicalComparison, 'chemicalml/cml/canonical_comparison'
|
|
13
|
+
autoload :Elements, 'chemicalml/cml/elements'
|
|
14
|
+
autoload :Enums, 'chemicalml/cml/enums'
|
|
15
|
+
autoload :Namespace, 'chemicalml/cml/namespace'
|
|
16
|
+
autoload :Patterns, 'chemicalml/cml/patterns'
|
|
17
|
+
autoload :ReferenceResolver, 'chemicalml/cml/reference_resolver'
|
|
18
|
+
autoload :Role, 'chemicalml/cml/role'
|
|
19
|
+
autoload :Schema3, 'chemicalml/cml/schema3'
|
|
20
|
+
autoload :Schema24, 'chemicalml/cml/schema24'
|
|
21
|
+
autoload :Visitable, 'chemicalml/cml/visitable'
|
|
22
|
+
autoload :WireClassRegistry, 'chemicalml/cml/wire_class_registry'
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
# Look up a wire class by XML element name.
|
|
26
|
+
#
|
|
27
|
+
# @param xml_name [String, Symbol] the XML element name, e.g. "atomArray".
|
|
28
|
+
# @param schema [Symbol] `:schema3` (default) or `:schema24`.
|
|
29
|
+
# @return [Class, nil] the matching wire class, or nil if not found.
|
|
30
|
+
def for_xml_name(xml_name, schema: :schema3)
|
|
31
|
+
class_name = Elements::XML_TO_CLASS[xml_name.to_s]
|
|
32
|
+
return nil unless class_name
|
|
33
|
+
|
|
34
|
+
parent = schema == :schema24 ? Schema24 : Schema3
|
|
35
|
+
parent.const_get(class_name)
|
|
36
|
+
rescue NameError
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Enumerate every wire class for a schema version.
|
|
41
|
+
#
|
|
42
|
+
# @param schema [Symbol] `:schema3` or `:schema24`.
|
|
43
|
+
# @return [Array<Class>] the wire classes.
|
|
44
|
+
def wire_classes(schema: :schema3)
|
|
45
|
+
parent = schema == :schema24 ? Schema24 : Schema3
|
|
46
|
+
Elements::ALL.keys.map do |class_name|
|
|
47
|
+
parent.const_get(class_name)
|
|
48
|
+
rescue NameError
|
|
49
|
+
nil
|
|
50
|
+
end.compact
|
|
51
|
+
end
|
|
52
|
+
end
|
|
19
53
|
|
|
20
54
|
# Backward-compatible aliases (Cml::Foo = Schema3::Foo). All 121
|
|
21
55
|
# aliases load from a single file via autoload — the file loads
|
|
22
56
|
# lazily when the first alias is referenced, then defines all of
|
|
23
57
|
# them via const_set (aliasing existing Schema3 classes, not
|
|
24
58
|
# creating new ones).
|
|
25
|
-
autoload :Array,
|
|
26
|
-
autoload :Atom,
|
|
27
|
-
autoload :AtomArray,
|
|
28
|
-
autoload :AtomParity,
|
|
29
|
-
autoload :Bond,
|
|
30
|
-
autoload :BondArray,
|
|
31
|
-
autoload :BondStereo,
|
|
32
|
-
autoload :Dictionary,
|
|
33
|
-
autoload :DictionaryEntry,
|
|
34
|
-
autoload :Document,
|
|
35
|
-
autoload :Formula,
|
|
36
|
-
autoload :Identifier,
|
|
37
|
-
autoload :Label,
|
|
38
|
-
autoload :List,
|
|
39
|
-
autoload :Matrix,
|
|
40
|
-
autoload :Metadata,
|
|
41
|
-
autoload :MetadataList,
|
|
42
|
-
autoload :Module,
|
|
43
|
-
autoload :Molecule,
|
|
44
|
-
autoload :Name,
|
|
45
|
-
autoload :Parameter,
|
|
46
|
-
autoload :ParameterList,
|
|
47
|
-
autoload :Product,
|
|
48
|
-
autoload :ProductList,
|
|
49
|
-
autoload :Property,
|
|
50
|
-
autoload :PropertyList,
|
|
51
|
-
autoload :Reaction,
|
|
52
|
-
autoload :ReactionList,
|
|
53
|
-
autoload :Reactant,
|
|
54
|
-
autoload :ReactantList,
|
|
55
|
-
autoload :Scalar,
|
|
56
|
-
autoload :Substance,
|
|
57
|
-
autoload :Unit,
|
|
58
|
-
autoload :UnitList,
|
|
59
|
-
autoload :UnitType,
|
|
60
|
-
autoload :UnitTypeList,
|
|
61
|
-
autoload :Abundance,
|
|
62
|
-
autoload :Action,
|
|
63
|
-
autoload :ActionList,
|
|
64
|
-
autoload :Amount,
|
|
65
|
-
autoload :Angle,
|
|
66
|
-
autoload :AnyCml,
|
|
67
|
-
autoload :ArrayList,
|
|
68
|
-
autoload :AtomSet,
|
|
69
|
-
autoload :AtomType,
|
|
70
|
-
autoload :AtomTypeList,
|
|
71
|
-
autoload :AtomicBasisFunction,
|
|
72
|
-
autoload :Band,
|
|
73
|
-
autoload :BandList,
|
|
74
|
-
autoload :BasisSet,
|
|
75
|
-
autoload :BondSet,
|
|
76
|
-
autoload :BondType,
|
|
77
|
-
autoload :BondTypeList,
|
|
78
|
-
autoload :CellParameter,
|
|
79
|
-
autoload :ConditionList,
|
|
80
|
-
autoload :Crystal,
|
|
81
|
-
autoload :Definition,
|
|
82
|
-
autoload :Description,
|
|
83
|
-
autoload :Dimension,
|
|
84
|
-
autoload :Documentation,
|
|
85
|
-
autoload :Eigen,
|
|
86
|
-
autoload :Electron,
|
|
87
|
-
autoload :Fragment,
|
|
88
|
-
autoload :FragmentList,
|
|
89
|
-
autoload :Gradient,
|
|
90
|
-
autoload :Isotope,
|
|
91
|
-
autoload :IsotopeList,
|
|
92
|
-
autoload :Join,
|
|
93
|
-
autoload :Kpoint,
|
|
94
|
-
autoload :KpointList,
|
|
95
|
-
autoload :Lattice,
|
|
96
|
-
autoload :LatticeVector,
|
|
97
|
-
autoload :Length,
|
|
98
|
-
autoload :Line3,
|
|
99
|
-
autoload :Link,
|
|
100
|
-
autoload :Map,
|
|
101
|
-
autoload :Mechanism,
|
|
102
|
-
autoload :MechanismComponent,
|
|
103
|
-
autoload :MoleculeList,
|
|
104
|
-
autoload :Object,
|
|
105
|
-
autoload :Observation,
|
|
106
|
-
autoload :Particle,
|
|
107
|
-
autoload :Peak,
|
|
108
|
-
autoload :PeakGroup,
|
|
109
|
-
autoload :PeakList,
|
|
110
|
-
autoload :PeakStructure,
|
|
111
|
-
autoload :Plane3,
|
|
112
|
-
autoload :Point3,
|
|
113
|
-
autoload :Potential,
|
|
114
|
-
autoload :PotentialForm,
|
|
115
|
-
autoload :PotentialList,
|
|
116
|
-
autoload :ReactionScheme,
|
|
117
|
-
autoload :ReactionStep,
|
|
118
|
-
autoload :ReactionStepList,
|
|
119
|
-
autoload :ReactiveCentre,
|
|
120
|
-
autoload :Region,
|
|
121
|
-
autoload :Sample,
|
|
122
|
-
autoload :Spectator,
|
|
123
|
-
autoload :SpectatorList,
|
|
124
|
-
autoload :Spectrum,
|
|
125
|
-
autoload :SpectrumData,
|
|
126
|
-
autoload :SpectrumList,
|
|
127
|
-
autoload :Sphere3,
|
|
128
|
-
autoload :Stmml,
|
|
129
|
-
autoload :SubstanceList,
|
|
130
|
-
autoload :Symmetry,
|
|
131
|
-
autoload :System,
|
|
132
|
-
autoload :Table,
|
|
133
|
-
autoload :TableCell,
|
|
134
|
-
autoload :TableContent,
|
|
135
|
-
autoload :TableHeader,
|
|
136
|
-
autoload :TableHeaderCell,
|
|
137
|
-
autoload :TableRow,
|
|
138
|
-
autoload :TableRowList,
|
|
139
|
-
autoload :Torsion,
|
|
140
|
-
autoload :Transform3,
|
|
141
|
-
autoload :TransitionState,
|
|
142
|
-
autoload :Vector3,
|
|
143
|
-
autoload :Xaxis,
|
|
144
|
-
autoload :Yaxis,
|
|
145
|
-
autoload :ZMatrix,
|
|
59
|
+
autoload :Array, 'chemicalml/cml/aliases'
|
|
60
|
+
autoload :Atom, 'chemicalml/cml/aliases'
|
|
61
|
+
autoload :AtomArray, 'chemicalml/cml/aliases'
|
|
62
|
+
autoload :AtomParity, 'chemicalml/cml/aliases'
|
|
63
|
+
autoload :Bond, 'chemicalml/cml/aliases'
|
|
64
|
+
autoload :BondArray, 'chemicalml/cml/aliases'
|
|
65
|
+
autoload :BondStereo, 'chemicalml/cml/aliases'
|
|
66
|
+
autoload :Dictionary, 'chemicalml/cml/aliases'
|
|
67
|
+
autoload :DictionaryEntry, 'chemicalml/cml/aliases'
|
|
68
|
+
autoload :Document, 'chemicalml/cml/aliases'
|
|
69
|
+
autoload :Formula, 'chemicalml/cml/aliases'
|
|
70
|
+
autoload :Identifier, 'chemicalml/cml/aliases'
|
|
71
|
+
autoload :Label, 'chemicalml/cml/aliases'
|
|
72
|
+
autoload :List, 'chemicalml/cml/aliases'
|
|
73
|
+
autoload :Matrix, 'chemicalml/cml/aliases'
|
|
74
|
+
autoload :Metadata, 'chemicalml/cml/aliases'
|
|
75
|
+
autoload :MetadataList, 'chemicalml/cml/aliases'
|
|
76
|
+
autoload :Module, 'chemicalml/cml/aliases'
|
|
77
|
+
autoload :Molecule, 'chemicalml/cml/aliases'
|
|
78
|
+
autoload :Name, 'chemicalml/cml/aliases'
|
|
79
|
+
autoload :Parameter, 'chemicalml/cml/aliases'
|
|
80
|
+
autoload :ParameterList, 'chemicalml/cml/aliases'
|
|
81
|
+
autoload :Product, 'chemicalml/cml/aliases'
|
|
82
|
+
autoload :ProductList, 'chemicalml/cml/aliases'
|
|
83
|
+
autoload :Property, 'chemicalml/cml/aliases'
|
|
84
|
+
autoload :PropertyList, 'chemicalml/cml/aliases'
|
|
85
|
+
autoload :Reaction, 'chemicalml/cml/aliases'
|
|
86
|
+
autoload :ReactionList, 'chemicalml/cml/aliases'
|
|
87
|
+
autoload :Reactant, 'chemicalml/cml/aliases'
|
|
88
|
+
autoload :ReactantList, 'chemicalml/cml/aliases'
|
|
89
|
+
autoload :Scalar, 'chemicalml/cml/aliases'
|
|
90
|
+
autoload :Substance, 'chemicalml/cml/aliases'
|
|
91
|
+
autoload :Unit, 'chemicalml/cml/aliases'
|
|
92
|
+
autoload :UnitList, 'chemicalml/cml/aliases'
|
|
93
|
+
autoload :UnitType, 'chemicalml/cml/aliases'
|
|
94
|
+
autoload :UnitTypeList, 'chemicalml/cml/aliases'
|
|
95
|
+
autoload :Abundance, 'chemicalml/cml/aliases'
|
|
96
|
+
autoload :Action, 'chemicalml/cml/aliases'
|
|
97
|
+
autoload :ActionList, 'chemicalml/cml/aliases'
|
|
98
|
+
autoload :Amount, 'chemicalml/cml/aliases'
|
|
99
|
+
autoload :Angle, 'chemicalml/cml/aliases'
|
|
100
|
+
autoload :AnyCml, 'chemicalml/cml/aliases'
|
|
101
|
+
autoload :ArrayList, 'chemicalml/cml/aliases'
|
|
102
|
+
autoload :AtomSet, 'chemicalml/cml/aliases'
|
|
103
|
+
autoload :AtomType, 'chemicalml/cml/aliases'
|
|
104
|
+
autoload :AtomTypeList, 'chemicalml/cml/aliases'
|
|
105
|
+
autoload :AtomicBasisFunction, 'chemicalml/cml/aliases'
|
|
106
|
+
autoload :Band, 'chemicalml/cml/aliases'
|
|
107
|
+
autoload :BandList, 'chemicalml/cml/aliases'
|
|
108
|
+
autoload :BasisSet, 'chemicalml/cml/aliases'
|
|
109
|
+
autoload :BondSet, 'chemicalml/cml/aliases'
|
|
110
|
+
autoload :BondType, 'chemicalml/cml/aliases'
|
|
111
|
+
autoload :BondTypeList, 'chemicalml/cml/aliases'
|
|
112
|
+
autoload :CellParameter, 'chemicalml/cml/aliases'
|
|
113
|
+
autoload :ConditionList, 'chemicalml/cml/aliases'
|
|
114
|
+
autoload :Crystal, 'chemicalml/cml/aliases'
|
|
115
|
+
autoload :Definition, 'chemicalml/cml/aliases'
|
|
116
|
+
autoload :Description, 'chemicalml/cml/aliases'
|
|
117
|
+
autoload :Dimension, 'chemicalml/cml/aliases'
|
|
118
|
+
autoload :Documentation, 'chemicalml/cml/aliases'
|
|
119
|
+
autoload :Eigen, 'chemicalml/cml/aliases'
|
|
120
|
+
autoload :Electron, 'chemicalml/cml/aliases'
|
|
121
|
+
autoload :Fragment, 'chemicalml/cml/aliases'
|
|
122
|
+
autoload :FragmentList, 'chemicalml/cml/aliases'
|
|
123
|
+
autoload :Gradient, 'chemicalml/cml/aliases'
|
|
124
|
+
autoload :Isotope, 'chemicalml/cml/aliases'
|
|
125
|
+
autoload :IsotopeList, 'chemicalml/cml/aliases'
|
|
126
|
+
autoload :Join, 'chemicalml/cml/aliases'
|
|
127
|
+
autoload :Kpoint, 'chemicalml/cml/aliases'
|
|
128
|
+
autoload :KpointList, 'chemicalml/cml/aliases'
|
|
129
|
+
autoload :Lattice, 'chemicalml/cml/aliases'
|
|
130
|
+
autoload :LatticeVector, 'chemicalml/cml/aliases'
|
|
131
|
+
autoload :Length, 'chemicalml/cml/aliases'
|
|
132
|
+
autoload :Line3, 'chemicalml/cml/aliases'
|
|
133
|
+
autoload :Link, 'chemicalml/cml/aliases'
|
|
134
|
+
autoload :Map, 'chemicalml/cml/aliases'
|
|
135
|
+
autoload :Mechanism, 'chemicalml/cml/aliases'
|
|
136
|
+
autoload :MechanismComponent, 'chemicalml/cml/aliases'
|
|
137
|
+
autoload :MoleculeList, 'chemicalml/cml/aliases'
|
|
138
|
+
autoload :Object, 'chemicalml/cml/aliases'
|
|
139
|
+
autoload :Observation, 'chemicalml/cml/aliases'
|
|
140
|
+
autoload :Particle, 'chemicalml/cml/aliases'
|
|
141
|
+
autoload :Peak, 'chemicalml/cml/aliases'
|
|
142
|
+
autoload :PeakGroup, 'chemicalml/cml/aliases'
|
|
143
|
+
autoload :PeakList, 'chemicalml/cml/aliases'
|
|
144
|
+
autoload :PeakStructure, 'chemicalml/cml/aliases'
|
|
145
|
+
autoload :Plane3, 'chemicalml/cml/aliases'
|
|
146
|
+
autoload :Point3, 'chemicalml/cml/aliases'
|
|
147
|
+
autoload :Potential, 'chemicalml/cml/aliases'
|
|
148
|
+
autoload :PotentialForm, 'chemicalml/cml/aliases'
|
|
149
|
+
autoload :PotentialList, 'chemicalml/cml/aliases'
|
|
150
|
+
autoload :ReactionScheme, 'chemicalml/cml/aliases'
|
|
151
|
+
autoload :ReactionStep, 'chemicalml/cml/aliases'
|
|
152
|
+
autoload :ReactionStepList, 'chemicalml/cml/aliases'
|
|
153
|
+
autoload :ReactiveCentre, 'chemicalml/cml/aliases'
|
|
154
|
+
autoload :Region, 'chemicalml/cml/aliases'
|
|
155
|
+
autoload :Sample, 'chemicalml/cml/aliases'
|
|
156
|
+
autoload :Spectator, 'chemicalml/cml/aliases'
|
|
157
|
+
autoload :SpectatorList, 'chemicalml/cml/aliases'
|
|
158
|
+
autoload :Spectrum, 'chemicalml/cml/aliases'
|
|
159
|
+
autoload :SpectrumData, 'chemicalml/cml/aliases'
|
|
160
|
+
autoload :SpectrumList, 'chemicalml/cml/aliases'
|
|
161
|
+
autoload :Sphere3, 'chemicalml/cml/aliases'
|
|
162
|
+
autoload :Stmml, 'chemicalml/cml/aliases'
|
|
163
|
+
autoload :SubstanceList, 'chemicalml/cml/aliases'
|
|
164
|
+
autoload :Symmetry, 'chemicalml/cml/aliases'
|
|
165
|
+
autoload :System, 'chemicalml/cml/aliases'
|
|
166
|
+
autoload :Table, 'chemicalml/cml/aliases'
|
|
167
|
+
autoload :TableCell, 'chemicalml/cml/aliases'
|
|
168
|
+
autoload :TableContent, 'chemicalml/cml/aliases'
|
|
169
|
+
autoload :TableHeader, 'chemicalml/cml/aliases'
|
|
170
|
+
autoload :TableHeaderCell, 'chemicalml/cml/aliases'
|
|
171
|
+
autoload :TableRow, 'chemicalml/cml/aliases'
|
|
172
|
+
autoload :TableRowList, 'chemicalml/cml/aliases'
|
|
173
|
+
autoload :Torsion, 'chemicalml/cml/aliases'
|
|
174
|
+
autoload :Transform3, 'chemicalml/cml/aliases'
|
|
175
|
+
autoload :TransitionState, 'chemicalml/cml/aliases'
|
|
176
|
+
autoload :Vector3, 'chemicalml/cml/aliases'
|
|
177
|
+
autoload :Xaxis, 'chemicalml/cml/aliases'
|
|
178
|
+
autoload :Yaxis, 'chemicalml/cml/aliases'
|
|
179
|
+
autoload :ZMatrix, 'chemicalml/cml/aliases'
|
|
146
180
|
end
|
|
147
181
|
end
|
|
@@ -74,7 +74,9 @@ module Chemicalml
|
|
|
74
74
|
def create_context(id:, registry: nil, fallback_to: [context_id])
|
|
75
75
|
normalized_id = id.to_sym
|
|
76
76
|
ensure_version_registered
|
|
77
|
-
|
|
77
|
+
if Lutaml::Model::GlobalContext.context(normalized_id)
|
|
78
|
+
Lutaml::Model::GlobalContext.unregister_context(normalized_id)
|
|
79
|
+
end
|
|
78
80
|
Lutaml::Model::GlobalContext.create_context(
|
|
79
81
|
id: normalized_id,
|
|
80
82
|
registry: registry || Lutaml::Model::TypeRegistry.new,
|
|
@@ -122,7 +124,7 @@ module Chemicalml
|
|
|
122
124
|
def version_parent_module
|
|
123
125
|
return nil unless name
|
|
124
126
|
|
|
125
|
-
parent_const_name = name.split(
|
|
127
|
+
parent_const_name = name.split('::')[0..-2].join('::')
|
|
126
128
|
return nil if parent_const_name.empty?
|
|
127
129
|
|
|
128
130
|
Object.const_get(parent_const_name)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Chemicalml
|
|
4
|
+
module Convention
|
|
5
|
+
module Cascade
|
|
6
|
+
module Constraints
|
|
7
|
+
# A `<reactionScheme>` MUST contain at least one
|
|
8
|
+
# `<reactionStepList>` or `<reaction>` child. An empty scheme
|
|
9
|
+
# carries no cascade information.
|
|
10
|
+
class ReactionSchemeMustHaveContent < Chemicalml::Convention::Constraint::NodeConstraint
|
|
11
|
+
self.description = 'A `<reactionScheme>` MUST contain at least one `<reactionStepList>` or `<reaction>` child. An empty scheme carries no cascade information.'
|
|
12
|
+
applies_to Chemicalml::Cml::Role::ReactionScheme
|
|
13
|
+
|
|
14
|
+
def check_node(node, _path)
|
|
15
|
+
return [] unless (node.reaction_step_lists || []).empty? &&
|
|
16
|
+
(node.reactions || []).empty?
|
|
17
|
+
|
|
18
|
+
[violation(path: yield_path(node),
|
|
19
|
+
message: "reactionScheme #{node.id.inspect} must contain at least one " \
|
|
20
|
+
'reactionStepList or reaction')]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def yield_path(node)
|
|
26
|
+
id = node.node_id
|
|
27
|
+
id ? "reactionScheme[#{id}]" : 'reactionScheme'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Chemicalml
|
|
4
|
+
module Convention
|
|
5
|
+
module Cascade
|
|
6
|
+
module Constraints
|
|
7
|
+
# A `<reactionStepList>` MUST contain at least one
|
|
8
|
+
# `<reactionStep>` child. An empty step list breaks the
|
|
9
|
+
# cascade chain.
|
|
10
|
+
class ReactionStepListMustContainSteps < Chemicalml::Convention::Constraint::NodeConstraint
|
|
11
|
+
self.description = 'A `<reactionStepList>` MUST contain at least one `<reactionStep>` child. An empty step list breaks the cascade chain.'
|
|
12
|
+
applies_to Chemicalml::Cml::Role::ReactionStepList
|
|
13
|
+
|
|
14
|
+
def check_node(node, _path)
|
|
15
|
+
return [] unless (node.reaction_steps || []).empty?
|
|
16
|
+
|
|
17
|
+
[violation(path: yield_path(node),
|
|
18
|
+
message: 'reactionStepList must contain at least one reactionStep')]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def yield_path(node)
|
|
24
|
+
id = node.node_id
|
|
25
|
+
id ? "reactionStepList[#{id}]" : 'reactionStepList'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/chemicalml/convention/cascade/constraints/reaction_step_must_have_reaction_or_lists.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Chemicalml
|
|
4
|
+
module Convention
|
|
5
|
+
module Cascade
|
|
6
|
+
module Constraints
|
|
7
|
+
# A `<reactionStep>` MUST contain either a `<reaction>` child
|
|
8
|
+
# or explicit `<reactantList>` + `<productList>` children. An
|
|
9
|
+
# empty step is a dead-end in the cascade.
|
|
10
|
+
class ReactionStepMustHaveReactionOrLists < Chemicalml::Convention::Constraint::NodeConstraint
|
|
11
|
+
self.description = 'A `<reactionStep>` MUST contain either a `<reaction>` child or explicit `<reactantList>` + `<productList>` children. An empty step is a dead-end in the cascade.'
|
|
12
|
+
applies_to Chemicalml::Cml::Role::ReactionStep
|
|
13
|
+
|
|
14
|
+
def check_node(node, _path)
|
|
15
|
+
return [] if node.reaction
|
|
16
|
+
return [] if node.reactant_list && node.product_list
|
|
17
|
+
|
|
18
|
+
[violation(path: yield_path(node),
|
|
19
|
+
message: "reactionStep #{node.id.inspect} must contain a reaction " \
|
|
20
|
+
'or both reactantList and productList')]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def yield_path(node)
|
|
26
|
+
id = node.node_id
|
|
27
|
+
id ? "reactionStep[#{id}]" : 'reactionStep'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/chemicalml/convention/cascade/constraints/reactive_centre_atom_refs_should_be_present.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Chemicalml
|
|
4
|
+
module Convention
|
|
5
|
+
module Cascade
|
|
6
|
+
module Constraints
|
|
7
|
+
# A `<reactiveCentre>` SHOULD declare its `atomRefs` attribute.
|
|
8
|
+
# Without atom references the reactive centre is
|
|
9
|
+
# indistinguishable from a placeholder. Warning severity —
|
|
10
|
+
# consumers may use `ref` or external context instead.
|
|
11
|
+
class ReactiveCentreAtomRefsShouldBePresent < Chemicalml::Convention::Constraint::NodeConstraint
|
|
12
|
+
self.description = 'A `<reactiveCentre>` SHOULD declare its `atomRefs` attribute. Without atom references the reactive centre is indistinguishable from a placeholder. Warning severity —'
|
|
13
|
+
applies_to Chemicalml::Cml::Role::ReactiveCentre
|
|
14
|
+
|
|
15
|
+
def check_node(node, _path)
|
|
16
|
+
return [] unless node.atomRefs.to_s.empty?
|
|
17
|
+
|
|
18
|
+
[violation(path: yield_path(node),
|
|
19
|
+
message: "reactiveCentre #{node.id.inspect} should declare atomRefs " \
|
|
20
|
+
'to identify the reacting atoms',
|
|
21
|
+
severity: :warning)]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def yield_path(node)
|
|
27
|
+
id = node.node_id
|
|
28
|
+
id ? "reactiveCentre[#{id}]" : 'reactiveCentre'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Chemicalml
|
|
4
|
+
module Convention
|
|
5
|
+
module Cascade
|
|
6
|
+
module Constraints
|
|
7
|
+
autoload :ReactionSchemeMustHaveContent,
|
|
8
|
+
'chemicalml/convention/cascade/constraints/reaction_scheme_must_have_content'
|
|
9
|
+
autoload :ReactionStepListMustContainSteps,
|
|
10
|
+
'chemicalml/convention/cascade/constraints/reaction_step_list_must_contain_steps'
|
|
11
|
+
autoload :ReactionStepMustHaveReactionOrLists,
|
|
12
|
+
'chemicalml/convention/cascade/constraints/reaction_step_must_have_reaction_or_lists'
|
|
13
|
+
autoload :ReactiveCentreAtomRefsShouldBePresent,
|
|
14
|
+
'chemicalml/convention/cascade/constraints/reactive_centre_atom_refs_should_be_present'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|