diff --git a/data/test_data.json b/data/test_data.json index e85b9d8..f6edeef 100644 --- a/data/test_data.json +++ b/data/test_data.json @@ -7,42 +7,38 @@ "pdb_id": "2gs6", "chains": [ { - "additional_chain_annotations": {}, "residues": [ { - "additional_residue_annotations": {}, - "pdb_res_label": 811, + "pdb_res_label": "811", "aa_type": "HIS", "site_data": [ { "confidence_score": 1, - "site_id_ref": 811, + "site_id_ref": 1, "confidence_classification": "high", "raw_score": 1 } ] }, { - "additional_residue_annotations": {}, - "pdb_res_label": 812, + "pdb_res_label": "812", "aa_type": "ARG", "site_data": [ { "confidence_score": 1, - "site_id_ref": 812, + "site_id_ref": 2, "confidence_classification": "high", "raw_score": 1 } ] }, { - "additional_residue_annotations": {}, - "pdb_res_label": 813, + "pdb_res_label": "813", "aa_type": "ASP", "site_data": [ { "confidence_score": 1, - "site_id_ref": 813, + "site_id_ref": 2, "confidence_classification": "high", "raw_score": 1 } @@ -54,31 +50,18 @@ ], "sites": [ { - "additional_site_annotations": {}, - "source_release_date": "06/20/2006", - "site_id": 811, - "label": "HRD motif", - "source_accession": "2gs6", - "source_database": "pdb" + "site_id": 1, + "label": "HRD motif" }, { - "additional_site_annotations": {}, - "source_release_date": "06/20/2006", - "site_id": 812, - "label": "HRD motif", - "source_accession": "2gs6", - "source_database": "pdb" + "site_id": 2, + "label": "HRD motif" }, { - "additional_site_annotations": {}, - "source_release_date": "06/20/2006", - "site_id": 813, - "label": "HRD motif", - "source_accession": "2gs6", - "source_database": "pdb" + "site_id": 3, + "label": "HRD motif" } ], - "additional_entry_annotations": {}, "evidence_code_ontology": [ { "eco_term": "computational combinatorial evidence", diff --git a/data/test_data_invalid.json b/data/test_data_invalid.json new file mode 100644 index 0000000..e85b9d8 --- /dev/null +++ b/data/test_data_invalid.json @@ -0,0 +1,88 @@ +{ + "data_resource": "ProKinO", + "resource_version": "2.0", + "software_version": "2.0", + "resource_entry_url": "http://vulcan.cs.uga.edu/prokino/", + "release_date": "10/02/2017", + "pdb_id": "2gs6", + "chains": [ + { + "additional_chain_annotations": {}, + "residues": [ + { + "additional_residue_annotations": {}, + "pdb_res_label": 811, + "aa_type": "HIS", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 811, + "confidence_classification": "high", + "raw_score": 1 + } + ] + }, + { + "additional_residue_annotations": {}, + "pdb_res_label": 812, + "aa_type": "ARG", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 812, + "confidence_classification": "high", + "raw_score": 1 + } + ] + }, + { + "additional_residue_annotations": {}, + "pdb_res_label": 813, + "aa_type": "ASP", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 813, + "confidence_classification": "high", + "raw_score": 1 + } + ] + } + ], + "chain_label": "A" + } + ], + "sites": [ + { + "additional_site_annotations": {}, + "source_release_date": "06/20/2006", + "site_id": 811, + "label": "HRD motif", + "source_accession": "2gs6", + "source_database": "pdb" + }, + { + "additional_site_annotations": {}, + "source_release_date": "06/20/2006", + "site_id": 812, + "label": "HRD motif", + "source_accession": "2gs6", + "source_database": "pdb" + }, + { + "additional_site_annotations": {}, + "source_release_date": "06/20/2006", + "site_id": 813, + "label": "HRD motif", + "source_accession": "2gs6", + "source_database": "pdb" + } + ], + "additional_entry_annotations": {}, + "evidence_code_ontology": [ + { + "eco_term": "computational combinatorial evidence", + "eco_code": "ECO_0000246" + } + ] +} \ No newline at end of file diff --git a/tests/test_validator.py b/tests/test_validator.py index 00a3c1e..aa9d568 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -28,15 +28,14 @@ class TestValidator(unittest.TestCase): def test_json_parser(self): validator = Validator("resource_name") - data = validator.parse_json("../data/test_data.json") + data = validator.parse_json("data/test_data.json") self.assertIsNotNone(data) - validator.parse_json("../data/test_data_malformed.json") + validator.parse_json("data/test_data_malformed.json") self.assertIn("JSON error", validator.error_log) def test_basic_checks(self): validator = Validator("test") validator.json_data = {"data_resource": "test", "pdb_id": "1abc"} - print(validator.json_data) self.assertTrue(validator.basic_checks()) validator.json_data = {"data_resource": "test"} self.assertFalse(validator.basic_checks()) @@ -61,4 +60,14 @@ class TestValidator(unittest.TestCase): def test_invalid_pdb_id(self): validator = Validator("test") validator.json_data = {"data_resource": "test", "pdb_id": "invalid"} - self.assertFalse(validator.test_pdb_id()) \ No newline at end of file + self.assertFalse(validator.test_pdb_id()) + + def test_json_validation(self): + validator = Validator("ProKinO") + validator.load_json("data/test_data.json") + validator.load_schema("data/funpdbe_schema.json") + validation = validator.validate_against_schema() + self.assertTrue(validation) + validator.load_json("data/test_data_invalid.json") + validation = validator.validate_against_schema() + self.assertFalse(validation) \ No newline at end of file