diff --git a/tests/test_gafparser.py b/tests/test_gafparser.py index a9dc907d..02f6c059 100644 --- a/tests/test_gafparser.py +++ b/tests/test_gafparser.py @@ -633,7 +633,11 @@ def test_id_syntax(): database_id_syntax_lookups['PomBase'] = pombase_types wb_ref_types = {} - database_id_syntax_lookups['WB_REF'] = wb_ref_types + database_id_syntax_lookups['WB_REF'] = wb_ref_types + + mgi_types = {} + mgi_types['entity'] = re.compile('MGI:[0-9]{5,}') + database_id_syntax_lookups['MGI'] = mgi_types p = GafParser(config=assocparser.AssocParserConfig( ontology=OntologyFactory().create(ONT), db_type_name_regex_id_syntax=database_id_syntax_lookups)) @@ -648,7 +652,13 @@ def test_id_syntax(): assert len(assoc_result.associations) == 1 assert assoc_result.skipped == False messages = p.report.to_report_json()["messages"] - assert "gorule-0000027" not in messages + assert "gorule-0000027" not in messages + + assoc_result = p.parse_line("PomBase\tSPBC1289.03c\tspi1\t\tGO:0005515\tWB_REF:WBPaper00006408|PMID:18422602\tIPI\tMGI:MGI:1298204\tF\tRan GTPase Spi1\t\tprotein\ttaxon:4896\t20080718\tPomBase\t") + assert len(assoc_result.associations) == 1 + assert assoc_result.skipped == False + messages = p.report.to_report_json()["messages"] + assert "gorule-0000027" not in messages p = GafParser(config=assocparser.AssocParserConfig( ontology=OntologyFactory().create(ONT), db_type_name_regex_id_syntax=database_id_syntax_lookups)) @@ -686,6 +696,15 @@ def test_id_syntax(): assert len(messages["gorule-0000027"]) == 1 assert messages["gorule-0000027"][0]["obj"] == "BLA:18422602" + p = GafParser(config=assocparser.AssocParserConfig( + ontology=OntologyFactory().create(ONT), db_type_name_regex_id_syntax=database_id_syntax_lookups)) + assoc_result = p.parse_line("PomBase\tSPBC1289.03c\tspi1\t\tGO:0005515\tWB_REF:WBPaper00006408|PMID:18422602\tIPI\tMGI:1298204\tF\tRan GTPase Spi1\t\tprotein\ttaxon:4896\t20080718\tPomBase\t") + assert len(assoc_result.associations) == 1 + assert assoc_result.skipped == False + messages = p.report.to_report_json()["messages"] + assert len(messages["gorule-0000027"]) == 1 + assert messages["gorule-0000027"][0]["obj"] == "MGI:1298204" + def test_gaf_gpi_bridge(): gaf = ["MGI", "MGI:1923503", "0610006L08Rik", "enables", "GO:0003674", "MGI:MGI:2156816|GO_REF:0000015", "ND", "", diff --git a/tests/test_gpad_parser.py b/tests/test_gpad_parser.py index c38a727d..d19592d5 100644 --- a/tests/test_gpad_parser.py +++ b/tests/test_gpad_parser.py @@ -345,6 +345,10 @@ def test_id_syntax(): pombase_types['entity'] = re.compile('S\\w+(\\.)?\\w+(\\.)?') database_id_syntax_lookups['PomBase'] = pombase_types + mgi_types = {} + mgi_types['entity'] = re.compile('MGI:[0-9]{5,}') + database_id_syntax_lookups['MGI'] = mgi_types + eco_types = {} eco_types['entity'] = re.compile(pattern) database_id_syntax_lookups['ECO'] = eco_types @@ -396,7 +400,31 @@ def test_id_syntax(): assert len(result.associations) == 1 assert result.skipped == False messages = p.report.to_report_json()["messages"] - assert "gorule-0000027" not in messages + assert "gorule-0000027" not in messages + + vals = ["PomBase", + "SPAC25A8.01c", + "acts_upstream_of_or_within", + "GO:0007155", + "MGI:MGI:1298204", + "ECO:0000305", + "GO:0005913", + "", + "20041026", + "ZFIN", + "", + "PomBase" + ] + + config = assocparser.AssocParserConfig( + ontology=OntologyFactory().create(ALT_ID_ONT), db_type_name_regex_id_syntax=database_id_syntax_lookups) + p = GpadParser(config=config) + result = p.parse_line("\t".join(vals)) + assert len(result.associations) == 1 + assert result.skipped == False + messages = p.report.to_report_json()["messages"] + assert "gorule-0000027" not in messages + vals = ["PomBase", "SPAC25A8.01c", @@ -487,6 +515,28 @@ def test_id_syntax(): assert len(messages["gorule-0000027"]) == 1 assert messages["gorule-0000027"][0]["obj"] == "BLA:15494018" + vals = ["PomBase", + "SPAC25A8.01c", + "acts_upstream_of_or_within", + "GO:0007155", + "MGI:15494018", + "ECO:0000305", + "GO:0005913", + "", + "20041026", + "ZFIN", + "", + "PomBase" + ] + p = GpadParser(config=config) + result = p.parse_line("\t".join(vals)) + assert len(result.associations) == 1 + assert result.skipped == False + messages = p.report.to_report_json()["messages"] + assert len(messages["gorule-0000027"]) == 1 + assert messages["gorule-0000027"][0]["obj"] == "MGI:15494018" + + def test_gpi_check(): report = assocparser.Report(group="unknown", dataset="unknown") vals = [