Skip to content

Commit

Permalink
For #1553
Browse files Browse the repository at this point in the history
  • Loading branch information
mugitty committed Feb 22, 2024
1 parent 57adf9c commit 5d332fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 71 deletions.
30 changes: 0 additions & 30 deletions ontobio/io/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,35 +687,6 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
return self._result(True)


class GoRule57(GoRule):

def __init__(self):
super().__init__("GORULE:0000057", "Group specific filter rules should be applied to annotations", FailMode.HARD, tags=["context-import"])

def test(self, annotation: association.GoAssociation, config: assocparser.AssocParserConfig, group=None) -> TestResult:
# Check group_metadata is present
if config.group_metadata is None:
return self._result(True)

evidence_codes = config.group_metadata.get("filter_out", {}).get("evidence", [])
if str(annotation.evidence.type) in evidence_codes:
return self._result(False)

evidences_references = config.group_metadata.get("filter_out", {}).get("evidence_reference", [])
for er in evidences_references:
evidence_code = er["evidence"]
reference = er["reference"]
if str(annotation.evidence.type) == evidence_code and [str(ref) for ref in annotation.evidence.has_supporting_reference] == [reference]:
return self._result(False)

properties = config.group_metadata.get("filter_out", {}).get("annotation_properties", [])
for p in properties:
if p in annotation.properties.keys():
return self._result(False)

return self._result(True)


class GoRule58(RepairRule):

def __init__(self):
Expand Down Expand Up @@ -947,7 +918,6 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP
"GoRule50": GoRule50(),
#"GoRule51": GoRule51(), Do not run test
"GoRule55": GoRule55(),
"GoRule57": GoRule57(),
"GoRule58": GoRule58(),
"GoRule61": GoRule61(),
# GoRule13 at the bottom in order to make all other rules clean up an annotation before reaching 13
Expand Down
43 changes: 2 additions & 41 deletions tests/test_qc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
import datetime
import yaml
import json

from ontobio.model import association
from ontobio.model.association import Curie
Expand All @@ -12,7 +11,7 @@
from ontobio.io import gafparser
from ontobio.io.gafparser import GafParser
from ontobio.io import gpadparser
from ontobio import ontol, ontol_factory, ecomap
from ontobio import ontol_factory, ecomap

import copy

Expand Down Expand Up @@ -629,44 +628,6 @@ def test_gorule55():
assert test_result.result_type == qc.ResultType.WARNING


def test_gorule57():
assoc = make_annotation(db="HELLO", db_id="123", qualifier="contributes_to", goid="GO:0003674", evidence=iea_eco, taxon="taxon:2", from_gaf=False).associations[0]
# Look at evidence_code, reference, annotation_properties
config = assocparser.AssocParserConfig(
group_metadata={
"id": "mgi",
"label": "Mouse Genome Informatics",
"filter_out": {
"evidence": [iea_eco],
"evidence_reference": [
{
"evidence": ikr_eco,
"reference": "PMID:21873635"
}
],
"annotation_properties": ["noctua-model-id"]
}
},
rule_set=assocparser.RuleSet.ALL
)
test_result = qc.GoRule57().test(assoc, config)
assert test_result.result_type == qc.ResultType.ERROR

assoc.evidence.type = Curie.from_str(ikr_eco)
assoc.evidence.has_supporting_reference = [Curie.from_str("PMID:21873635")]
test_result = qc.GoRule57().test(assoc, config)
assert test_result.result_type == qc.ResultType.ERROR

assoc.evidence.type = Curie.from_str("ECO:some_garbage")
assoc.evidence.has_supporting_reference = [Curie.from_str("PMID:some_garbage")]
assoc.properties = {"noctua-model-id": "some_garbage"}
test_result = qc.GoRule57().test(assoc, config)
assert test_result.result_type == qc.ResultType.ERROR

assoc.properties = {}
test_result = qc.GoRule57().test(assoc, config)
assert test_result.result_type == qc.ResultType.PASS

def test_gorule58():

with open("tests/resources/extensions-constraints.yaml") as exs_cons:
Expand Down Expand Up @@ -778,7 +739,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()) == 23
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 5d332fa

Please sign in to comment.