Skip to content

Commit

Permalink
Merge pull request #644 from biolink/go-site-2058-gorule-0000051-firs…
Browse files Browse the repository at this point in the history
…t-implementation

For #2058 gorule-0000051 first implementation
  • Loading branch information
mugitty committed Sep 13, 2023
2 parents 3dd9050 + d29d031 commit 5d15999
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
12 changes: 12 additions & 0 deletions ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,17 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP

return result

class GoRule51(GoRule):

def __init__(self):
super().__init__("GORULE:0000051", "Some GO terms require a value in the Annotation Extension field", FailMode.SOFT)

def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult:

term = str(annotation.object.id)
no_extensions = (annotation.object_extensions is None or len(annotation.object_extensions) == 0)
fails = (term == "GO:0005488" or term == "GO:0005515") and no_extensions
return self._result(not fails)

class GoRule55(GoRule):

Expand Down Expand Up @@ -908,6 +919,7 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
"GoRule43": GoRule43(),
"GoRule46": GoRule46(),
"GoRule50": GoRule50(),
"GoRule51": GoRule51(),
"GoRule55": GoRule55(),
"GoRule57": GoRule57(),
"GoRule58": GoRule58(),
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/errors.gaf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
!
! bad GO ID
PomBase SPAC25B8.17 ypf1 BAD_GO_ID GO_REF:0000024 ISO SGD:S000001583 C intramembrane aspartyl protease of the perinuclear ER membrane Ypf1 (predicted) ppp81 protein taxon:4896 20150305 PomBase
! No gene symbol
! No gene symbol, fail since gene symbol is a required field
PomBase SPAC977.10 GO:1990578 PMID:19171118 IDA C plasma membrane sodium ion/proton antiporter Nhe1/Sod2 sod2 protein taxon:4896 20151201 PomBase
! Blank lines

Expand Down
2 changes: 1 addition & 1 deletion tests/test_gafparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_errors_gaf():
n_invalid_idspace += 1
assert len(msgs) == 13
assert n_invalid_idspace == 1
assert len(assocs) == 2
assert len(assocs) == 1

w = GafWriter()
w.write(assocs)
Expand Down
12 changes: 11 additions & 1 deletion tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,16 @@ def test_gorule50():
assoc.evidence.type = Curie.from_str(iea_eco)
test_result = qc.GoRule50().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.PASS

def test_gorule51():
assoc = make_annotation(goid="GO:0005515", extension="has_input(GO:0003674),occurs_in(CL:123456)").associations[0]

test_result = qc.GoRule51().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.PASS

assoc = make_annotation(goid="GO:0005488").associations[0]
test_result = qc.GoRule51().test(assoc, all_rules_config())
assert test_result.result_type == qc.ResultType.WARNING

def test_gorule55():
a = ["blah"] * 15
Expand Down Expand Up @@ -722,7 +732,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

0 comments on commit 5d15999

Please sign in to comment.