From 79e31fa121061592a5e0276df83434d206b077ae Mon Sep 17 00:00:00 2001 From: Anushya Muruganujan Date: Thu, 30 Nov 2023 15:12:25 -0800 Subject: [PATCH] For #346 --- ontobio/io/gpadparser.py | 11 ++++++++++- tests/test_gpad_parser.py | 19 +++++++++++++++++++ tests/test_qc.py | 6 +----- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ontobio/io/gpadparser.py b/ontobio/io/gpadparser.py index 0c5259a9..4876fa88 100644 --- a/ontobio/io/gpadparser.py +++ b/ontobio/io/gpadparser.py @@ -157,8 +157,17 @@ def parse_line(self, line): split_line = assocparser.SplitLine(line=line, values=vals, taxon="") + #With/From + for wf in assoc.evidence.with_support_from: + validated = self.validate_curie_ids(wf.elements, split_line) + if validated is None: + return assocparser.ParseResult(line, [], True) + # repair any GO terms in the with/from field that may be obsolete - assoc.evidence.with_support_from = self._unroll_withfrom_and_replair_obsoletes(split_line, 'gpad') + with_support_from = self._unroll_withfrom_and_replair_obsoletes(split_line, 'gpad') + if with_support_from is None: + return assocparser.ParseResult(line, [], True) + assoc.evidence.with_support_from = with_support_from # repair, if possible any GO terms in the extensions that may be obsolete if (0 < len(assoc.object_extensions)): diff --git a/tests/test_gpad_parser.py b/tests/test_gpad_parser.py index 2628795a..b07beaba 100644 --- a/tests/test_gpad_parser.py +++ b/tests/test_gpad_parser.py @@ -41,6 +41,25 @@ def test_obsolete_term_repair_withfrom(): Curie(namespace='MGI', identity='1232453')])] == assoc.evidence.with_support_from + obsolete_go_with_from_no_replacement = ["ZFIN", + "ZFIN:ZDB-GENE-980526-362", + "acts_upstream_of_or_within", + "GO:0007155", + "PMID:15494018", + "ECO:0000305", + "GO:0016458|GO:1,GO:4|ZFIN:ZDB-MRPHLNO-010101-1,MGI:1232453", + "", + "20041026", + "ZFIN", + "", + "contributor=GOC:zfin_curators|model-state=production|noctua-model-id=gomodel:ZFIN_ZDB-GENE-980526-362" + ] + ont = OntologyFactory().create(ALT_ID_ONT) + config = assocparser.AssocParserConfig(ontology=ont, rule_set=assocparser.RuleSet.ALL) + parser = GpadParser(config=config) + result = parser.parse_line("\t".join(obsolete_go_with_from_no_replacement)) + assert result.associations == [] + def test_obsolete_term_repair_extensions(): vals = ["ZFIN", diff --git a/tests/test_qc.py b/tests/test_qc.py index bd72ec59..a5016483 100644 --- a/tests/test_qc.py +++ b/tests/test_qc.py @@ -254,7 +254,6 @@ def test_go_rule_16(): # GO term same as with/ID assoc = make_annotation(goid="GO:0044419", evidence="IC", withfrom="GO:0044419").associations[0] - #GO term same as withfrom test_result = qc.GoRule16().test(assoc, all_rules_config()) assert test_result.result_type == qc.ResultType.WARNING @@ -268,10 +267,7 @@ def test_go_rule_16(): parser = GpadParser(obs_config) gpadLine = "MGI\tMGI:1916040\tlocated_in\tGO:0005634\tPMID:23369715\tECO:0000305\tGO:0016458\t\t20200518\tMGI\t\tcontributor=https://orcid.org/0000-0001-7476-6306|noctua-model-id=gomodel:MGI_MGI_1916040|contributor=https://orcid.org/0000-0003-2689-5511|model-state=production" result = parser.parse_line(gpadLine) - assoc = result.associations[0] - test_result = qc.GoRule16().test(assoc, obs_config) - assert test_result.result_type == qc.ResultType.WARNING - + assert result.associations == [] # No GO term w/ID assoc = make_annotation(evidence="IC", withfrom="BLAH:12345").associations[0]