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 geneontology/go-site#2392 #703

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
27 changes: 26 additions & 1 deletion ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,31 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
return self._result(False)

return self._result(True)

class GoRule65(GoRule):

def __init__(self):
super().__init__("GORULE:0000065", "Annotations to term that are candidates for obsoletion should be removed", FailMode.SOFT)
self.candidate_for_obsoletion = None

def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult:
# Cache the subsets
if config.ontology is None:
return self._result(True)

if self.candidate_for_obsoletion is None and config.ontology is not None:
self.candidate_for_obsoletion = set(config.ontology.extract_subset("gocheck_obsoletion_candidate"))
elif self.candidate_for_obsoletion is None and config.ontology is None:
self.candidate_for_obsoletion = []

goid = str(annotation.object.id)

annotated_to_obsoletion_candidate = goid in self.candidate_for_obsoletion
not_obsoletion_candidate = not(annotated_to_obsoletion_candidate)

t = result(not_obsoletion_candidate, self.fail_mode)
return TestResult(t, self.title, not_obsoletion_candidate)

GoRules = enum.Enum("GoRules", {
"GoRule02": GoRule02(),
"GoRule05": GoRule05(),
Expand Down Expand Up @@ -982,7 +1006,8 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
"GoRule58": GoRule58(),
"GoRule61": GoRule61(),
"GoRule63": GoRule63(),
"GoRule64": GoRule64(),
"GoRule64": GoRule64(),
"GoRule65": GoRule65(),
# GoRule13 at the bottom in order to make all other rules clean up an annotation before reaching 13
"GoRule13": GoRule13()
})
Expand Down
15 changes: 15 additions & 0 deletions tests/resources/goslim_generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -4834,6 +4834,21 @@
},
"type" : "CLASS",
"lbl" : "hydrolase activity, acting on carbon-nitrogen (but not peptide) bonds"
}, {
"id" : "http://purl.obolibrary.org/obo/GO_0099531",
"meta" : {
"definition" : {
"val" : "The pathway leading to secretion of a neurotransmitter from the presynapse as part of synaptic transmission.",
"xrefs" : [ "GOC:dos" ]
},
"subsets" : [ "http://purl.obolibrary.org/obo/go#gocheck_obsoletion_candidate", "http://purl.obolibrary.org/obo/go#goslim_synapse" ],
"basicPropertyValues" : [ {
"pred" : "http://www.geneontology.org/formats/oboInOwl#hasOBONamespace",
"val" : "biological_process"
} ]
},
"type" : "CLASS",
"lbl" : "presynaptic process involved in chemical synaptic transmission"
}, {
"id" : "http://purl.obolibrary.org/obo/GO_0005929",
"meta" : {
Expand Down
17 changes: 15 additions & 2 deletions tests/test_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,20 @@ def test_go_rule_64():
assoc = make_annotation(evidence="IEA", references="GO_REF:0000118").associations[0]
assoc.subject.taxon = Curie.from_str("NCBITaxon:7227")
test_result = qc.GoRule64().test(assoc, config)
assert test_result.result_type == qc.ResultType.ERROR
assert test_result.result_type == qc.ResultType.ERROR

def test_go_rule65():

assoc = make_annotation(goid="GO:0099531").associations[0]

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

assoc = make_annotation(goid="GO:0016192").associations[0]
test_result = qc.GoRule65().test(assoc, all_rules_config(ontology=ontology))
assert test_result.result_type == qc.ResultType.PASS



def test_all_rules():
# pass
Expand All @@ -833,7 +846,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()) == 27
assert len(test_results.keys()) == 28
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