diff --git a/ontobio/io/qc.py b/ontobio/io/qc.py index f08668a2..14fd8d33 100644 --- a/ontobio/io/qc.py +++ b/ontobio/io/qc.py @@ -954,7 +954,31 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP return self._result(False) return self._result(True) + +class GoRule65(GoRule): + + def __init__(self): + super().__init__("GORULE:0000065", "Annotations to term that are candidates for obsoletion should be removed", FailMode.SOFT) + self.candidate_for_obsoletion = None + def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult: + # Cache the subsets + if config.ontology is None: + return self._result(True) + + if self.candidate_for_obsoletion is None and config.ontology is not None: + self.candidate_for_obsoletion = set(config.ontology.extract_subset("gocheck_obsoletion_candidate")) + elif self.candidate_for_obsoletion is None and config.ontology is None: + self.candidate_for_obsoletion = [] + + goid = str(annotation.object.id) + + annotated_to_obsoletion_candidate = goid in self.candidate_for_obsoletion + not_obsoletion_candidate = not(annotated_to_obsoletion_candidate) + + t = result(not_obsoletion_candidate, self.fail_mode) + return TestResult(t, self.title, not_obsoletion_candidate) + GoRules = enum.Enum("GoRules", { "GoRule02": GoRule02(), "GoRule05": GoRule05(), @@ -982,7 +1006,8 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP "GoRule58": GoRule58(), "GoRule61": GoRule61(), "GoRule63": GoRule63(), - "GoRule64": GoRule64(), + "GoRule64": GoRule64(), + "GoRule65": GoRule65(), # GoRule13 at the bottom in order to make all other rules clean up an annotation before reaching 13 "GoRule13": GoRule13() }) diff --git a/tests/resources/goslim_generic.json b/tests/resources/goslim_generic.json index 71333612..3b4909fc 100644 --- a/tests/resources/goslim_generic.json +++ b/tests/resources/goslim_generic.json @@ -4834,6 +4834,21 @@ }, "type" : "CLASS", "lbl" : "hydrolase activity, acting on carbon-nitrogen (but not peptide) bonds" + }, { + "id" : "http://purl.obolibrary.org/obo/GO_0099531", + "meta" : { + "definition" : { + "val" : "The pathway leading to secretion of a neurotransmitter from the presynapse as part of synaptic transmission.", + "xrefs" : [ "GOC:dos" ] + }, + "subsets" : [ "http://purl.obolibrary.org/obo/go#gocheck_obsoletion_candidate", "http://purl.obolibrary.org/obo/go#goslim_synapse" ], + "basicPropertyValues" : [ { + "pred" : "http://www.geneontology.org/formats/oboInOwl#hasOBONamespace", + "val" : "biological_process" + } ] + }, + "type" : "CLASS", + "lbl" : "presynaptic process involved in chemical synaptic transmission" }, { "id" : "http://purl.obolibrary.org/obo/GO_0005929", "meta" : { diff --git a/tests/test_qc.py b/tests/test_qc.py index ef4bd800..d06c9238 100644 --- a/tests/test_qc.py +++ b/tests/test_qc.py @@ -816,7 +816,20 @@ def test_go_rule_64(): assoc = make_annotation(evidence="IEA", references="GO_REF:0000118").associations[0] assoc.subject.taxon = Curie.from_str("NCBITaxon:7227") test_result = qc.GoRule64().test(assoc, config) - assert test_result.result_type == qc.ResultType.ERROR + assert test_result.result_type == qc.ResultType.ERROR + +def test_go_rule65(): + + assoc = make_annotation(goid="GO:0099531").associations[0] + + test_result = qc.GoRule65().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.WARNING + + assoc = make_annotation(goid="GO:0016192").associations[0] + test_result = qc.GoRule65().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.PASS + + def test_all_rules(): # pass @@ -833,7 +846,7 @@ def test_all_rules(): assoc = gafparser.to_association(a).associations[0] test_results = qc.test_go_rules(assoc, config).all_results - assert len(test_results.keys()) == 27 + assert len(test_results.keys()) == 28 assert test_results[qc.GoRules.GoRule26.value].result_type == qc.ResultType.PASS assert test_results[qc.GoRules.GoRule29.value].result_type == qc.ResultType.PASS