Validation Rulesο
Validator Classesο
- class sloth.mmcif.rules.DictionaryValidator[source]ο
Bases:
ValidatorPluginValidator auto-generated from an mmCIF dictionary.
Parses a
.dicfile via SLOTHβsDictionaryParser, retains the schema metadata, and registers validators from it:mandatory items β from
_item.mandatory_codeenumeration β from
_item_enumeration.valuetype regex β from
_item_type_list.constructforeign-key integrity β single-key relationships
composite-key integrity β multi-key relationships
parent/child category presence β parent must exist when child does
- Parameters:
dict_path (str, optional) β Path to an mmCIF dictionary. Defaults to the bundled
mmcif_pdbx_v50.dic.quiet (bool) β Suppress progress messages from the dictionary parser (default True).
Usage:: β
from sloth.mmcif.rules import DictionaryValidator
v = DictionaryValidator() # schema-only rules handler.register(βvalidateβ, v)
- class sloth.mmcif.rules.MmcifValidator[source]ο
Bases:
DictionaryValidatorFull wwPDB validator = dictionary schema + deposition business rules.
Inherits all schema-level checks from
DictionaryValidator, then registers wwPDB-specific rules from the declarative tables below.- Parameters:
dict_path (str, optional) β Path to an mmCIF dictionary. Defaults to the bundled
mmcif_pdbx_v50.dic.quiet (bool) β Suppress dictionary parser progress messages (default True).
Usage:: β
from sloth.mmcif.rules import MmcifValidator
v = MmcifValidator() # full wwPDB + dictionary rules handler.register(βvalidateβ, v)
Single-Category Rule Factoriesο
- sloth.mmcif.rules.mandatory_items(items, exclude=(), severity=ValidationSeverity.ERROR)[source]ο
Items that must be non-null when the category is present.
- sloth.mmcif.rules.one_of_following(items, severity=ValidationSeverity.ERROR)[source]ο
At least one of items must be non-null.
- sloth.mmcif.rules.value_length(item, min_len=None, max_len=None, severity=ValidationSeverity.WARNING)[source]ο
String length bounds for an item.
- sloth.mmcif.rules.value_range(item, min_val=None, max_val=None, severity=ValidationSeverity.WARNING)[source]ο
Numeric bounds for an item.
- sloth.mmcif.rules.conditional_mandatory(required_items, when_item, when_values, severity=ValidationSeverity.ERROR)[source]ο
Items that must be non-null when when_item has one of when_values.
- sloth.mmcif.rules.regex_check(item, pattern, error_text='', severity=ValidationSeverity.ERROR)[source]ο
Values of item must match pattern.
- sloth.mmcif.rules.ordering_check(item_a, item_b, op='<', severity=ValidationSeverity.WARNING)[source]ο
Numeric ordering: item_a
opitem_b (per row).
- sloth.mmcif.rules.allowed_pairs(item_a, item_b, valid_mapping, severity=ValidationSeverity.ERROR)[source]ο
Restrict allowed (item_a, item_b) value combinations per row.
valid_mapping maps each value of item_a to the sequence of allowed values in item_b.
- sloth.mmcif.rules.min_rows(n, severity=ValidationSeverity.ERROR)[source]ο
Category must contain at least n rows.
- Return type:
- Parameters:
n (int)
severity (ValidationSeverity)
- sloth.mmcif.rules.enumeration_check(item, allowed_values, severity=ValidationSeverity.ERROR)[source]ο
Values of item must be in allowed_values.
Mirrors the dictionary
_item_enumerationvalidation from the PDBeurope/mmcif-validator.
Cross-Category Rule Factoriesο
- sloth.mmcif.rules.foreign_key(child_item, parent_item, severity=ValidationSeverity.ERROR)[source]ο
Cross-checker: every non-null value of child_item in cat_a must exist in parent_item of cat_b.
Mirrors the FK integrity check from the PDBeurope/mmcif-validator.
- sloth.mmcif.rules.parent_child(severity=ValidationSeverity.ERROR)[source]ο
Cross-checker: if child category (cat_a) is present, parent category (cat_b) must also be present and non-empty.
Mirrors the parent/child category validation from the PDBeurope/mmcif-validator.
- Return type:
- Parameters:
severity (ValidationSeverity)
- sloth.mmcif.rules.composite_key(child_items, parent_items, severity=ValidationSeverity.ERROR)[source]ο
Cross-checker: each combination of child_items in cat_a must exist as a matching combination of parent_items in cat_b.
Mirrors the composite key validation from the PDBeurope/mmcif-validator.
- sloth.mmcif.rules.oper_expression(expression_item='oper_expression', oper_list_item='id', severity=ValidationSeverity.ERROR)[source]ο
Cross-checker: validate that operation expression references in cat_a all resolve to valid IDs in cat_b (
_pdbx_struct_oper_list).Parses expressions like
(1-60),(1,2,5),(X0)(1-5,11-15).Mirrors the oper_expression validation from the PDBeurope/mmcif-validator.