From a3b791907bbb76a3deac96d2118ae64590a58f27 Mon Sep 17 00:00:00 2001 From: dustine32 Date: Tue, 15 Sep 2020 16:17:51 -0700 Subject: [PATCH] GoRule 57 update and test for issue #473 --- ontobio/io/qc.py | 4 ++++ tests/test_qc.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ontobio/io/qc.py b/ontobio/io/qc.py index 34799418..ab7cca5a 100644 --- a/ontobio/io/qc.py +++ b/ontobio/io/qc.py @@ -576,6 +576,10 @@ def test(self, annotation: association.GoAssociation, config: assocparser.AssocP if annotation.evidence.type in evidence_codes: return self._result(False) + provided_bys = config.group_metadata.get("filter_for", {}).get("provided_by", []) + if provided_bys and str(annotation.provided_by) not in provided_bys: + return self._result(False) + evidences_references = config.group_metadata.get("filter_out", {}).get("evidence_reference", []) for er in evidences_references: evidence_code = er["evidence"] diff --git a/tests/test_qc.py b/tests/test_qc.py index 68604b65..6bc2ed6e 100644 --- a/tests/test_qc.py +++ b/tests/test_qc.py @@ -638,6 +638,9 @@ def test_gorule57(): } ], "annotation_properties": ["noctua-model-id"] + }, + "filter_for": { + "provided_by": ["MGI"] } }) test_result = qc.GoRule57().test(assoc, config) @@ -658,6 +661,17 @@ def test_gorule57(): test_result = qc.GoRule57().test(assoc, config) assert test_result.result_type == qc.ResultType.PASS + assoc.provided_by = "UniProt" + test_result = qc.GoRule57().test(assoc, config) + assert test_result.result_type == qc.ResultType.ERROR + + # Ensure null "filter_for" doesn't break anything + assoc.provided_by = "MGI" + config.group_metadata.pop("filter_for") + test_result = qc.GoRule57().test(assoc, config) + assert test_result.result_type == qc.ResultType.PASS + + def test_gorule58(): a = ["blah"] * 16