diff --git a/ontobio/io/qc.py b/ontobio/io/qc.py index 1e98761c..e826d654 100644 --- a/ontobio/io/qc.py +++ b/ontobio/io/qc.py @@ -36,6 +36,8 @@ iss_eco = ecomapping.coderef_to_ecoclass("ISS") isa_eco = ecomapping.coderef_to_ecoclass("ISA") iso_eco = ecomapping.coderef_to_ecoclass("ISO") +ism_eco = ecomapping.coderef_to_ecoclass("ISM") +rca_eco = ecomapping.coderef_to_ecoclass("RCA") # TestResult = collections.namedtuple("TestResult", ["result_type", "message", "result"]) class TestResult(object): @@ -187,6 +189,16 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP fails = ((annotation_obj_id == "GO:0005488" or annotation_obj_id == "GO:0005515") and annotation.negated) return self._result(not fails) +class GoRule05(GoRule): + + def __init__(self): + super().__init__("GORULE:0000005", "IEA, ISS, ISO, ISM, ISA, IBA, RCA annotations ae not allowed for direct annotations to 'binding ; GO:0005488' or 'protein binding ; GO:0005515'", FailMode.SOFT) + + def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult: + evidence = str(annotation.evidence.type) + annotation_obj_id = str(annotation.object.id) + fails = ((annotation_obj_id == "GO:0005488" or annotation_obj_id == "GO:0005515") and evidence in [iea_eco, iss_eco, iso_eco, ism_eco, isa_eco, iba_eco, rca_eco]) + return self._result(not fails) class GoRule06(GoRule): @@ -915,6 +927,7 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP GoRules = enum.Enum("GoRules", { "GoRule02": GoRule02(), + "GoRule05": GoRule05(), "GoRule06": GoRule06(), "GoRule07": GoRule07(), "GoRule08": GoRule08(), diff --git a/tests/test_qc.py b/tests/test_qc.py index af02f98c..35facea7 100644 --- a/tests/test_qc.py +++ b/tests/test_qc.py @@ -93,7 +93,29 @@ def test_go_rule02(): assoc.object.id = Curie.from_str("GO:0003674") test_result = qc.GoRule02().test(assoc, all_rules_config()) assert test_result.result_type == qc.ResultType.PASS - + +def test_go_rule_05(): + fail_terms = ["GO:0005488", "GO:0005515"] + fail_codes = ["IEA", "ISS", "ISO", "ISM", "ISA", "IBA", "RCA"] + for term in fail_terms: + for code in fail_codes: + assoc = make_annotation(goid=term, evidence=code).associations[0] + test_result = qc.GoRule05().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.WARNING + + assoc = make_annotation(goid="GO:0034655", evidence="IEA").associations[0] + test_result = qc.GoRule05().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.PASS + + + assoc = make_annotation(goid="GO:0005488", evidence="HEP").associations[0] + test_result = qc.GoRule05().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.PASS + + assoc = make_annotation(goid="GO:0034655", evidence="HEP").associations[0] + test_result = qc.GoRule05().test(assoc, all_rules_config(ontology=ontology)) + assert test_result.result_type == qc.ResultType.PASS + def test_go_rule_06(): assoc = make_annotation(goid="GO:0005575", evidence="HEP", aspect="C").associations[0] @@ -769,7 +791,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()) == 24 + assert len(test_results.keys()) == 25 assert test_results[qc.GoRules.GoRule26.value].result_type == qc.ResultType.PASS assert test_results[qc.GoRules.GoRule29.value].result_type == qc.ResultType.PASS