From 9a1e90b15492bf667d33fb85fcc1178994fa729c Mon Sep 17 00:00:00 2001 From: Anushya Muruganujan Date: Thu, 18 May 2023 09:46:51 -0700 Subject: [PATCH] For geneontology/go-site#1519 exclude annots for GOC --- ontobio/io/qc.py | 6 +++++- tests/test_qc.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ontobio/io/qc.py b/ontobio/io/qc.py index 4ba289b3..0bae6cb0 100644 --- a/ontobio/io/qc.py +++ b/ontobio/io/qc.py @@ -195,8 +195,12 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP if config.ontology is None: return self._result(True) - go_namespace = [predval for predval in config.ontology.get_graph().nodes.get(str(annotation.object.id), {}).get("meta", {}).get("basicPropertyValues", []) if predval["pred"]=="OIO:hasOBONamespace"] evidence = str(annotation.evidence.type) + assigned_by = annotation.provided_by + #Annotations with code IEP and HEP assigned by GOC are not restricted to Biological Process terms + if evidence in [iep_eco, hep_eco] and assigned_by == "GOC": + return self._result(True) + go_namespace = [predval for predval in config.ontology.get_graph().nodes.get(str(annotation.object.id), {}).get("meta", {}).get("basicPropertyValues", []) if predval["pred"]=="OIO:hasOBONamespace"] fails = evidence in [iep_eco, hep_eco] and "biological_process" not in [o["val"] for o in go_namespace] return self._result(not fails) diff --git a/tests/test_qc.py b/tests/test_qc.py index d58a7b5b..07c1ea8b 100644 --- a/tests/test_qc.py +++ b/tests/test_qc.py @@ -17,6 +17,7 @@ ontology = ontol_factory.OntologyFactory().create("tests/resources/goslim_generic.json") ecomapping = ecomap.EcoMap() iea_eco = ecomapping.coderef_to_ecoclass("IEA") +hep_eco = ecomapping.coderef_to_ecoclass("HEP") ic_eco = ecomapping.coderef_to_ecoclass("IC") ikr_eco = ecomapping.coderef_to_ecoclass("IKR") iba_eco = ecomapping.coderef_to_ecoclass("IBA") @@ -104,7 +105,18 @@ def test_go_rule_06(): assoc.evidence.type = Curie.from_str(iea_eco) test_result = qc.GoRule06().test(assoc, all_rules_config(ontology=ontology)) assert test_result.result_type == qc.ResultType.PASS + + assoc.evidence.type = Curie.from_str(hep_eco) + assoc.provided_by = "GOC" + assoc.aspect = "F" + assoc.object.id = Curie.from_str("GO:0003674"); + test_result = qc.GoRule06().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.PASS + assoc.provided_by = "WB" + test_result = qc.GoRule06().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.ERROR + def test_go_rule_07(): assoc = make_annotation(goid="GO:0003824", evidence="IPI").associations[0]