Merging improvements from https://github.com/skodapetr/funpdbe-validator skodapetr@github - "fix multiple molecules issue"

This commit is contained in:
Mihaly Varadi 2019-03-22 13:04:00 +00:00
parent 89ac85e304
commit 78b3f53a5f
2 changed files with 28 additions and 19 deletions

View file

@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-06/schema#", "$schema": "http://json-schema.org/draft-06/schema#",
"$id": "https://github.com/funpdbe-consortium/funpdbe_schema/blob/master/funpdbe_schema.v0.0.1.json", "$id": "https://gitlab.ebi.ac.uk/pdbe-kb/funpdbe/funpdbe-schema/raw/master/funpdbe_schema.json",
"title": "funpdbe_schema", "title": "funpdbe_schema",
"type": "object", "type": "object",
"properties": { "properties": {
@ -32,7 +32,8 @@
}, },
"additional_entry_annotations": { "additional_entry_annotations": {
"type": "object", "type": "object",
"description": "Additional entry-level annotations" "description": "Additional entry-level annotations",
"additionalProperties": true
}, },
"chains": { "chains": {
"type": "array", "type": "array",
@ -45,7 +46,8 @@
}, },
"additional_chain_annotations": { "additional_chain_annotations": {
"type": "object", "type": "object",
"description": "Additional chain-level annotations" "description": "Additional chain-level annotations",
"additionalProperties": true
}, },
"residues": { "residues": {
"type": "array", "type": "array",
@ -63,7 +65,8 @@
}, },
"additional_residue_annotations": { "additional_residue_annotations": {
"type": "object", "type": "object",
"description": "Additional residue-level annotations" "description": "Additional residue-level annotations",
"additionalProperties": true
}, },
"site_data": { "site_data": {
"type": "array", "type": "array",
@ -80,9 +83,8 @@
}, },
"confidence_score": { "confidence_score": {
"type": "number", "type": "number",
"description": "Confidence level of the annotation (0-1)", "description": "Confidence level of the annotation (0-1, except if the method justifies otherwise)",
"minimum": 0.0, "minimum": 0.0
"maximum": 1.0
}, },
"confidence_classification": { "confidence_classification": {
"type": "string", "type": "string",
@ -91,14 +93,18 @@
"high", "high",
"medium", "medium",
"low", "low",
"null" "null",
"curated"
] ]
},
"aa_variant": {
"type": "string",
"description": "Three-letter amino acid code of variant/mutant",
"pattern": "^[A-Za-z0-9]+$"
} }
}, },
"required": [ "required": [
"site_id_ref", "site_id_ref",
"raw_score",
"confidence_score",
"confidence_classification" "confidence_classification"
], ],
"additionalProperties": false "additionalProperties": false
@ -155,7 +161,8 @@
}, },
"additional_site_annotations": { "additional_site_annotations": {
"type": "object", "type": "object",
"description": "Additional site-level annotations" "description": "Additional site-level annotations",
"additionalProperties": true
} }
}, },
"required": [ "required": [
@ -199,4 +206,4 @@
"sites" "sites"
], ],
"additionalProperties": false "additionalProperties": false
} }

View file

@ -2,11 +2,9 @@
""" """
Copyright 2018 EMBL - European Bioinformatics Institute Copyright 2018 EMBL - European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
@ -27,7 +25,6 @@ class ResidueIndexes(object):
and each has to match the indices in the official PDB entry and each has to match the indices in the official PDB entry
This class relies on the PDBe API to get the current residue This class relies on the PDBe API to get the current residue
indices indices
Example usage: Example usage:
check_indexes = ResidueIndexes(your_json_object) check_indexes = ResidueIndexes(your_json_object)
if check_indexes.check_every_residue(): if check_indexes.check_every_residue():
@ -119,17 +116,22 @@ class ResidueIndexes(object):
:param depositor_aa_type: Residue amino acid code provided by user :param depositor_aa_type: Residue amino acid code provided by user
:return: True is residue numbering is valid, False if not :return: True is residue numbering is valid, False if not
""" """
flag = None flag = False
for item in data: for item in data:
sub_data = item[label] sub_data = item[label]
if label == "chains": if label == "chains":
flag = 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,
depositor_chain_id) depositor_chain_id)
elif label == "residues": elif label == "residues":
return self._process_residues(sub_data, depositor_residue_number, depositor_aa_type, depositor_chain_id) return self._process_residues(sub_data, depositor_residue_number, depositor_aa_type, depositor_chain_id)
if label == "chains": if label == "chains":
return flag return flag
if label == "residues":
# We were checking residues and none was found, so not match found -> False.
return False
def _process_residues(self, residues, depositor_residue_number, depositor_aa_type, depositor_chain_id): def _process_residues(self, residues, depositor_residue_number, depositor_aa_type, depositor_chain_id):
""" """
This method grabs the residue information and call the comparator if the This method grabs the residue information and call the comparator if the
@ -158,9 +160,9 @@ class ResidueIndexes(object):
:param depositor_residue_number: Residue number provided by the user :param depositor_residue_number: Residue number provided by the user
:return: True is residue numbering is valid, False if not :return: True is residue numbering is valid, False if not
""" """
if residue_name == depositor_aa_type: if residue_name.lower() == depositor_aa_type.lower():
return True return True
mismatch = "residue %s_%s (%s) in data does not match residue %s (%s) in PDB" % ( mismatch = "residue %s_%s (%s) in data does not match residue %s (%s) in PDB" % (
depositor_chain_id, depositor_residue_number, depositor_aa_type, depositor_residue_number, residue_name) depositor_chain_id, depositor_residue_number, depositor_aa_type, depositor_residue_number, residue_name)
self.mismatches.append(mismatch) self.mismatches.append(mismatch)
return False return False