Skip to content

Commit

Permalink
Merge pull request #656 from biolink/go-site-1523-gorule-0000016-uniq…
Browse files Browse the repository at this point in the history
…ue-goid

For #1523 check for unique GO ID
  • Loading branch information
mugitty authored Nov 10, 2023
2 parents 0b86178 + 4c4ac18 commit 625ee02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,17 @@ 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


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
go_id = annotation.object.id
only_go = [t for conjunctions in withfrom for t in conjunctions.elements if (t.namespace == "GO" and go_id.namespace == "GO" and t.identity != go_id.identity)] # Filter terms that aren't GO terms and different from GO ID
okay = len(only_go) >= 1

return self._result(okay)
Expand Down
13 changes: 12 additions & 1 deletion tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,20 @@ 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]

#GO term same as withfrom
test_result = qc.GoRule16().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.WARNING

#GO term same as one of the withfrom terms
assoc = make_annotation(goid="GO:0044419", evidence="IC", withfrom="GO:0044419|GO:0035821").associations[0]
test_result = qc.GoRule16().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.PASS

# 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 625ee02

Please sign in to comment.