Skip to content

Commit

Permalink
For #1523 check for unique GO ID
Browse files Browse the repository at this point in the history
  • Loading branch information
mugitty committed Nov 9, 2023
1 parent 0b86178 commit 77d8aa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,16 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
class GoRule16(GoRule):

def __init__(self):
super().__init__("GORULE:0000016", "All IC annotations should include a GO ID in the \"With/From\" column", FailMode.SOFT)
super().__init__("GORULE:0000016", "All IC annotations should include a GO ID in the \"With/From\" column that is also different from the entry in the \"GO ID\" column", FailMode.SOFT)

def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult:
evidence = str(annotation.evidence.type)
withfrom = annotation.evidence.with_support_from
goId = annotation.object.id

okay = True
if evidence == ic_eco:
only_go = [t for conjunctions in withfrom for t in conjunctions.elements if t.namespace == "GO"] # Filter terms that aren't GO terms
only_go = [t for conjunctions in withfrom for t in conjunctions.elements if (t.namespace == "GO" and goId is not None and t.identity != goId.identity)] # Filter terms that aren't GO terms and different from GO ID
okay = len(only_go) >= 1

return self._result(okay)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,14 @@ def test_go_rules_15():
assert test_result.result_type == qc.ResultType.WARNING

def test_go_rule_16():
# GO term same as with/ID
assoc = make_annotation(goid="GO:0044419", evidence="IC", withfrom="GO:0044419").associations[0]

test_result = qc.GoRule16().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.WARNING

# No GO term w/ID
assoc = make_annotation(evidence="IC", withfrom="BLAH:12345").associations[0]

test_result = qc.GoRule16().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.WARNING

Expand Down

0 comments on commit 77d8aa8

Please sign in to comment.