diff --git a/.gitignore b/.gitignore index c86f6e3..aa78de7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea* .cache* -*vcs.xml \ No newline at end of file +*vcs.xml +sample_data/* \ No newline at end of file diff --git a/data/test_data_multichain.json b/data/test_data_multichain.json new file mode 100644 index 0000000..f60bbd8 --- /dev/null +++ b/data/test_data_multichain.json @@ -0,0 +1,71 @@ +{ + "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": "1yj9", + "chains": [ + { + "residues": [ + { + "pdb_res_label": "0", + "aa_type": "MET", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 1, + "confidence_classification": "high", + "raw_score": 1 + } + ] + }, + { + "pdb_res_label": "1", + "aa_type": "GLY", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 2, + "confidence_classification": "high", + "raw_score": 1 + } + ] + }, + { + "pdb_res_label": "2", + "aa_type": "ARG", + "site_data": [ + { + "confidence_score": 1, + "site_id_ref": 2, + "confidence_classification": "high", + "raw_score": 1 + } + ] + } + ], + "chain_label": "A" + } + ], + "sites": [ + { + "site_id": 1, + "label": "HRD motif" + }, + { + "site_id": 2, + "label": "HRD motif" + }, + { + "site_id": 3, + "label": "HRD motif" + } + ], + "evidence_code_ontology": [ + { + "eco_term": "computational combinatorial evidence", + "eco_code": "ECO_0000246" + } + ] +} \ No newline at end of file diff --git a/tests/test_residue_index.py b/tests/test_residue_index.py index d6689f5..64fd50c 100644 --- a/tests/test_residue_index.py +++ b/tests/test_residue_index.py @@ -23,6 +23,9 @@ from validator.residue_index import ResidueIndexes with open("data/test_data.json", "r") as mock_data_file: mock_data = json.load(mock_data_file) +with open("data/test_data_multichain.json", "r") as mock_data_file_multichain: + mock_data_multichain = json.load(mock_data_file_multichain) + mock_data_no_pdb_id = {"foo": "bar"} mock_data_bad_numbering = {"pdb_id": "2aqa", @@ -101,4 +104,9 @@ class TestCheckResidueIndices(TestCase): self.assertFalse(result) result = self.cri._process_residues( [{"author_residue_number": 1, "residue_name": "ALA", "author_insertion_code": ""}], "1", "HIS") - self.assertFalse(result) \ No newline at end of file + self.assertFalse(result) + + def test_with_multichain(self): + self.cri = ResidueIndexes(mock_data_multichain) + result = self.cri.check_every_residue() + self.assertTrue(result) \ No newline at end of file diff --git a/validator/residue_index.py b/validator/residue_index.py index 57dc6cc..f19c75d 100644 --- a/validator/residue_index.py +++ b/validator/residue_index.py @@ -116,13 +116,15 @@ class ResidueIndexes(object): :param depositor_aa_type: Residue amino acid code provided by user :return: True is residue numbering is valid, False if not """ + flag = None for item in data: sub_data = item[label] if label == "chains": - return self._recursive_loop(sub_data, "residues", depositor_residue_number, depositor_aa_type) + flag = self._recursive_loop(sub_data, "residues", depositor_residue_number, depositor_aa_type) elif label == "residues": return self._process_residues(sub_data, depositor_residue_number, depositor_aa_type) - return False + if label == "chains": + return flag def _process_residues(self, residues, depositor_residue_number, depositor_aa_type): """