Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #887 #669

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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(),
Expand Down
26 changes: 24 additions & 2 deletions tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down
Loading