Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mugitty committed Dec 13, 2024
1 parent 0aac630 commit 69e0b37
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
23 changes: 21 additions & 2 deletions tests/test_gafparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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", "",
Expand Down
52 changes: 51 additions & 1 deletion tests/test_gpad_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 69e0b37

Please sign in to comment.