Comprehensive toolkit for resolving Gen3 JSON schemas, validating JSON metadata against schemas, and verifying linkage integrity between data nodes. Includes utilities for parsing Excel metadata templates, generating linkage configuration maps, orchestrating schema validation, and producing detailed validation reports and statistics
Project description
Gen3 Validator
Gen3 Validator is a Python toolkit designed to make working with Gen3 metadata schemas and data validation straightforward for developers.
Installation
pip install gen3_validator
pip show gen3_validator
Docs
Quickstart
import gen3_validator
resolver = gen3_validator.ResolveSchema(schema_path = "../tests/schema/gen3_test_schema.json")
resolver.resolve_schema()
schema = resolver.schema_resolved
data = [
{
"baseline_timepoint": True, # variable not in data dictionary
"freeze_thaw_cycles": "10", # should be an integer
"sample_collection_method": "2fddbe7d09",
"sample_id": "d4f31f7bb6",
"sample_in_preservation": "snap Frozen",
"sample_in_storage": "yes",
"sample_provider": "USYD",
"sample_source": "UBERON:3781554",
"sample_storage_method": "not stored",
"sample_type": "59a8fd8005",
"storage_location": "UMELB",
"subjects": {
"submitter_id": "subject_e5616257f8"
},
"submitter_id": "sample_efdbe56d20",
"type": "sample"
},
{
"baseline_timepoint": True,
"freeze_thaw_cycles": 76,
"sample_collection_method": "e2a6403b51",
"sample_id": 3324635, # should be a string
"sample_in_preservation": "not allowed to collect",
"sample_in_storage": "unknown",
"sample_provider": "USYD",
"sample_source": "UBERON:9332357",
"sample_storage_method": "frozen, liquid nitrogen",
"sample_type": "8fd28ec2f3",
"storage_location": "Baker",
"subjects": {
"submitter_id": "subject_071bc3e81a"
},
"submitter_id": "sample_f7645c1221",
"type": "sample"
}
]
results = gen3_validator.validate.validate_list_dict(data, schema)
print(results)
Example output:
[
{
'node': 'sample',
'index': 0,
'validation_result': 'FAIL',
'invalid_key': 'freeze_thaw_cycles',
'schema_path': 'properties.freeze_thaw_cycles.type',
'validator': 'type',
'validator_value': 'integer',
'validation_error': "'10' is not of type 'integer'"
},
{
'node': 'sample',
'index': 0,
'validation_result': 'FAIL',
'invalid_key': 'root',
'schema_path': 'additionalProperties',
'validator': 'additionalProperties',
'validator_value': False,
'validation_error': "Additional properties are not allowed ('baseline_timepoint', 'subjects' were unexpected)"
},
{
'node': 'sample',
'index': 1,
'validation_result': 'FAIL',
'invalid_key': 'sample_id',
'schema_path': 'properties.sample_id.type',
'validator': 'type',
'validator_value': 'string',
'validation_error': "3324635 is not of type 'string'"
},
{
'node': 'sample',
'index': 1,
'validation_result': 'FAIL',
'invalid_key': 'root',
'schema_path': 'additionalProperties',
'validator': 'additionalProperties',
'validator_value': False,
'validation_error': "Additional properties are not allowed ('baseline_timepoint', 'subjects' were unexpected)"
}
]
Dev Setup
- Make sure you have poetry installed.
- Clone the repository.
- Run the following command to activate the virtual environment.
eval $(poetry env activate)
- Run the following command to install the dependencies.
poetry install
- Run the following command to run the tests.
pytest -vv tests/
License
See the license page for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gen3_validator-2.0.0.tar.gz.
File metadata
- Download URL: gen3_validator-2.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.25 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89e14bdf298da2139a256f2cee49e69c5f2730c872507430b5aa014c13c95679
|
|
| MD5 |
9f2543e56c32c3586a9d2428a98641b3
|
|
| BLAKE2b-256 |
c20c46ecdc99bc6c9837157664e6318fd622081971ba2c89de549e115c9ceeaa
|
File details
Details for the file gen3_validator-2.0.0-py3-none-any.whl.
File metadata
- Download URL: gen3_validator-2.0.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.25 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fe619bd7d79d7f75844beb5c9d8f0dbd879cbd6c6259b6196d4e7adbabaf2e5
|
|
| MD5 |
52100ef17eb444832a9da9d436376381
|
|
| BLAKE2b-256 |
7421939bc3a16ee938d38efce6ab7129636b0d5291855f027f310c13776f6c9c
|