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 #1523 check for unique GO ID #656

Merged
merged 2 commits into from
Nov 10, 2023
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
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]
mugitty marked this conversation as resolved.
Show resolved Hide resolved

#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
Loading