hpotk.validate package

The hpotk.validate package provides code for Q/C of HPO applications.

class hpotk.validate.RuleValidator[source]

Bases: object

RuleValidator checks if a sequence of hpotk.model.Identified or hpotk.model.TermId items meet the validation requirements. The observation status is included in case the items extend hpotk.model.ObservableFeature.

The validators can check each item individually or as a collection, for instance, to discover violation of the annotation propagation rule, etc.

The issues are returned as ValidationResults.

abstract validate(items: Sequence[TermId | Identified]) ValidationResults[source]

Validate the sequence of term IDs or items that have an identifier.

Parameters:

items – the items to validate.

Returns:

results packaged in ValidationResults container.

class hpotk.validate.ValidationResult(level, category, message)

Bases: tuple

A tuple of ValidationLevel, a validation category string, and human-centric message.

category

Alias for field number 1

level

Alias for field number 0

message

Alias for field number 2

class hpotk.validate.ValidationLevel(value)[source]

Bases: Enum

An enumeration of the validation levels.

WARNING = 1

Validation warning represents a potential issue that can be fixed.

ERROR = 2

Validation error represents an issue that MUST be fixed

class hpotk.validate.ValidationResults(results: Sequence[ValidationResult])[source]

Bases: object

A container for results of a single validation run.

Parameters:

results

property results: Sequence[ValidationResult]

Get a sequence of validation results.

is_ok() bool[source]

Test if the validation run found no errors.

Returns:

True if no errors were found or False otherwise.

class hpotk.validate.AnnotationPropagationValidator(ontology: MinimalOntology)[source]

Bases: BaseOntologyRuleValidator

Validator to check that a sequence of terms, when interpreted together, does not violate the annotation propagation rule.

More formally, the terms must not satisfy the following:

  • terms must not contain a present term and its present or excluded ancestor

  • terms must not contain an excluded term and its excluded ancestor

Violation of annotation propagation rule produces an ValidationLevel.ERROR.

The validator replaces obsolete term IDs with the current term IDs before performing the validation.

Parameters:

ontology – HPO represented as hpotk.ontology.MinimalOntology.

validate(items: Sequence[TermId | Identified]) ValidationResults[source]

Validate the sequence of term IDs or items that have an identifier.

Parameters:

items – the items to validate.

Returns:

results packaged in ValidationResults container.

class hpotk.validate.PhenotypicAbnormalityValidator(ontology: MinimalOntology)[source]

Bases: BaseOntologyRuleValidator

Validator for checking that the term is a phenotypic abnormality (a descendant of Phenotypic abnormality [HP:0000118]).

Presence of a term that is not a descendant of Phenotypic abnormality is a ValidationLevel.WARNING.

The validator replaces obsolete term IDs with the current term IDs before performing the validation.

Parameters:

ontology – HPO represented as hpotk.ontology.MinimalOntology.

validate(items: Sequence[TermId | Identified]) ValidationResults[source]

Validate the sequence of term IDs or items that have an identifier.

Parameters:

items – the items to validate.

Returns:

results packaged in ValidationResults container.

class hpotk.validate.ObsoleteTermIdsValidator(ontology: MinimalOntology)[source]

Bases: BaseOntologyRuleValidator

ObsoleteTermIdsValidator points out usage of obsolete term ids in items.

Presence of an obsolete term ID is a ValidationLevel.WARNING.

Parameters:

ontology – HPO represented as hpotk.ontology.MinimalOntology.

validate(items: Sequence[TermId | Identified]) ValidationResults[source]

Validate the sequence of term IDs or items that have an identifier.

Parameters:

items – the items to validate.

Returns:

results packaged in ValidationResults container.

class hpotk.validate.ValidationRunner(validators: Iterable[RuleValidator])[source]

Bases: object

The runner applies a sequence of rule validators on items and packs the results into ValidationResults.

Parameters:

validators – an iterable of RuleValidators to apply.

validate_all(items: Sequence[TermId | Identified]) ValidationResults[source]

Validate the items with all rules.

Returns:

the results packed into ValidationResults.