Skip to main content

Validate PDBe-KB JSONs by FunPDBe Schema

Project description

FunPDBe JSON Validator

Build Status codecov Maintainability

This Python3 client can be used for validating FunPDBe JSON files. It performs various sanity checks, and validates user JSONs against the FunPDBe schema.

For more information on FunPDBe is, visit https://funpdbe.org

Quick start

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Please note that the client is written in Python3, and the dependencies have to be installed accordingly (i.e. using pip3)!

Installing

Checking out this repository from GitHub

$ git clone https://github.com/PDBe-KB/funpdbe-validator.git
$ cd funpdbe-validator
$ pip3 install -r requirements.txt

Installing with PIP

pip install funpdbe-validator

Basic usage

This package contains two classes which handle the validation of FunPDBe JSON files.

  • Validator()
  • ResidueIndexes()

Basic example:

from funpdbe_validator.validator import Validator
from funpdbe_validator.residue_index import ResidueIndexes

def run():
    """
    Basic example of running the PDBe-KB/FunPDBe validator
    :return:
    """
    validator = Validator("name of the resource") # Same as in the JSON
    validator.load_schema()
    validator.load_json("/path/to/data.json")

    if validator.basic_checks() and validator.validate_against_schema():
        print("Passed data validations")
        residue_indexes = ResidueIndexes(validator.json_data)
        if residue_indexes.check_every_residue():
            print("Passed the index validation")
            return True
    return False


if __name__ == "__main__":
    run()

Using mmcif instead of PDBe-API for valiation: ResidueIndexes class has optional arguments- 'mmcif_mode' and 'cif_file'. When mmcif_mode is set True, the validator uses given mmcif (set using cif_fie) for validation instead of PDBe-API.

def run(resource_name, json_path, mmcif_mode=False, cif_file =None):
    """
    Basic example of running the PDBe-KB/FunPDBe validator
    :return: None
    """
    validator = Validator(resource_name) # Same as in the JSON
    validator.load_schema()
    for json_file_path in glob.glob('%s*.json' % json_path):
        validator.load_json(json_file_path)
        if validator.basic_checks() and validator.validate_against_schema():
            print("Passed data validations for %s" % json_file_path)
            residue_indexes = ResidueIndexes(validator.json_data,mmcif_mode,cif_file)
            if residue_indexes.check_every_residue():
                print("Passed the index validation for %s" % json_file_path)
                return True
            else:
                print("Failed index validation for %s: %s" % (json_file_path, residue_indexes.mismatches))
        else:
            print("Failed data validations for %s: %s" % (json_file_path, validator.error_log))
    return False

Using the "basic_run.py"

This script runs the validator for all the JSON files found at a specified path. Note: the path has to end with a /

python basic_run.py dataResourceName path/to/json/files/

Using the Dockerized version

docker build --tag funpdbe-validator-basic .
docker run funpdbe-validator-basic dataResourceName path/to/json/files/

Running the tests

Running tests for the client is performed simply by using

$ pytest tests

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Mihaly Varadi - Initial work - mvaradi

Special thanks to:

License

This project is licensed under the EMBL-EBI License - see the LICENSE file for details

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

funpdbe-validator-1.1.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

funpdbe_validator-1.1.3-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file funpdbe-validator-1.1.3.tar.gz.

File metadata

  • Download URL: funpdbe-validator-1.1.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for funpdbe-validator-1.1.3.tar.gz
Algorithm Hash digest
SHA256 365efced161547875db16bd9982b977cfb179b1fb087d03d3ea3ddcc7282ca07
MD5 23eaa875c6d9fbf106d434a136655c1a
BLAKE2b-256 c1d4bfa9aebd462387b32bb33939c6c0cd6107da7f3b36e53232488fb111cf38

See more details on using hashes here.

File details

Details for the file funpdbe_validator-1.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for funpdbe_validator-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6ebc1595e31ca0845e1aa2844284ab3b991832225d0fdfef3acdcd659bd6f0ff
MD5 09ba8069f567e8c61302e8400ad7fc88
BLAKE2b-256 d782d9b343c8842dd39b03a1a46466987d1725ae3e387830cc85b592963bce44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page