Validation module
This module contains code for validating phenopackets created by pyphetools. These functions are provided for convenience. We recommend using phenopacket-tools to validate phenopackets.
CohortValidator
Source code in pyphetools/validation/cohort_validator.py
get_error_free_individual_list()
Returns a list of individuals from which the erroneous and redundant termas have been removed and from which individuals with errors (e.g., not enough HPO terms) have been removed.
Returns:
Type | Description |
---|---|
List[Individual]
|
List of individuals with no errors |
Source code in pyphetools/validation/cohort_validator.py
get_validated_individual_list()
Returns:
Type | Description |
---|---|
List[ValidatedIndividual]
|
list of all individuals with QC Validation results |
get_validated_individuals_with_unfixable_errors()
Returns a list of individuals with errors that cannot be automatically fixed.
Returns:
Type | Description |
---|---|
List[ValidatedIndivudal]
|
List of individuals with unfixable errors |
Source code in pyphetools/validation/cohort_validator.py
ContentValidator
Bases: PhenopacketValidator
Validate a list of phenopackets as to whether they have a minunum number of phenotypic features and alleles
The following example shows how to use this class to assess whether each phenopacket in the directory called "phenopackets" contains at least one variant and at least three HPO terms.
from pyphetools.visualization import PhenopacketIngestor
from pyphetools.validation import ContentValidator
ingestor = PhenopacketIngestor(indir="phenopackets")
ppkt_d = ingestor.get_phenopacket_dictionary()
ppkt_list = list(ppkt_d.values())
validator = ContentValidator(min_var=1, min_hpo=3)
errors = validator.validate_phenopacket_list(ppkt_list)
print(f"{len(errors)} errors were identified")
Note that this class does not test for all errors. Use phenopacket-tools to check for redundant or conflicting annotations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_hpo
|
int
|
minimum number of phenotypic features (HP terms) for this phenopacket to be considered valid |
required |
allelic_requirement
|
AllelicRequirement
|
used to check number of alleles and variants |
None
|
Source code in pyphetools/validation/content_validator.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
validate_individual(individual)
check a single Individual as to whether there are sufficient HPO terms and alleles/variants
Returns:
Type | Description |
---|---|
List[ValidationResult]
|
a potential empty list of validations |
Source code in pyphetools/validation/content_validator.py
validate_phenopacket(phenopacket)
check a single phenopacket as to whether there are sufficient HPO terms and alleles/variants
Returns:
Type | Description |
---|---|
List[ValidationResult]
|
a potential empty list of validations |
Source code in pyphetools/validation/content_validator.py
OntologyQC
This class performs three kind of checks/cleansing of ontology data 1. negated superclass and observed subclass (this is an error in the original data) 2. observed superclass and observed subclass (this is a redundancy but arguably not an error) 3. Same term is excluded and observed (this is an unfixable error in the original data)
Source code in pyphetools/validation/ontology_qc.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
get_error_list()
get_error_string()
create and return a string that summarizes the redundancies and conflicts that were corrected
Returns:
Type | Description |
---|---|
Optional[str]
|
a string summarizing errors or None if there were none |
Source code in pyphetools/validation/ontology_qc.py
PhenopacketValidator
Abstract super class for classes that validate phenopackets
Source code in pyphetools/validation/phenopacket_validator.py
ValidationResult
A helper class to store the results of validation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phenopacket_id
|
str
|
Identifier of the phenopacket being validated |
required |
message
|
str
|
description of the error/warning |
required |
errorlevel
|
ErrorLevel
|
whether this result is an error or a warning |
required |
category
|
Category
|
type of QcError |
required |
term
|
HpTerm
|
HpTerm that caused the error |
None
|
Source code in pyphetools/validation/validation_result.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
category: str
property
Returns:
Type | Description |
---|---|
str
|
the name of the Category this ValidationResult is about |
error_level: str
property
Returns:
Type | Description |
---|---|
str
|
the name of the ErrorLevel this ValidationResult is about |
message: str
property
Returns:
Type | Description |
---|---|
str
|
description of the cause of ValidationResult |
term: Optional[HpTerm]
property
Returns:
Type | Description |
---|---|
Optional[str]
|
A string representation of the HPO term this ValidationResult is about, if applicable, or empty string |
get_items_as_array()
Returns:
Type | Description |
---|---|
List[str]
|
A list of items (strings) intended for display |
Source code in pyphetools/validation/validation_result.py
is_unfixable_error()
Some errors cannot be fixed automatically and require manual attention.
Returns:
Type | Description |
---|---|
bool
|
True iff this ValidationResult cannot be fixed automatically. |
Source code in pyphetools/validation/validation_result.py
ValidationResultBuilder
This class is intended for internal use only, and makes constructing ValidatioResult objects a little easier.
Source code in pyphetools/validation/validation_result.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
duplicate_term(redundant_term)
The HPO term is annotated as observed and excluded in the same individual. This is an unfixable error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
redundant_term
|
HpTerm
|
HPO term that is annotated as observed and excluded |
required |
Returns:
Type | Description |
---|---|
ValidationResultBuilder
|
a reference to self so this command can be used as part of a builder. |
Source code in pyphetools/validation/validation_result.py
observed_and_excluded_term(term)
The HPO term is annotated as observed and excluded in the same individual. This is an unfixable error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
redundant_term
|
HpTerm
|
HPO term that is annotated as observed and excluded |
required |
Returns:
Type | Description |
---|---|
ValidationResultBuilder
|
a reference to self so this command can be used as part of a builder. |
Source code in pyphetools/validation/validation_result.py
redundant_term(ancestor_term, descendent_term)
The HPO term and one of its ancestors are both annotated as observed in the same individual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ancestor_term
|
HpTerm
|
Ancestor HPO term that is annotated as observed |
required |
descendent_term
|
HpTerm
|
Descendent HPO term that is annotated as observed |
required |
Returns:
Type | Description |
---|---|
ValidationResultBuilder
|
a reference to self so this command can be used as part of a builder. |