Skip to content

Commit

Permalink
Merge pull request #679 from biolink/go-site-2210-gorule-0000027-full…
Browse files Browse the repository at this point in the history
…-regex-match

For #2210
  • Loading branch information
mugitty authored Jul 19, 2024
2 parents 726162e + 19b72a0 commit 5f865b1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ontobio/io/assocparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def _validate_id(self, id, line: SplitLine, allowed_ids=None, context=None):
type_name_regex_patterns = self.config.db_type_name_regex_id_syntax[id_prefix]
identity_matches_pattern = False
for regex in type_name_regex_patterns.values():
if regex.match(right):
if regex.fullmatch(right):
identity_matches_pattern = True
break
if identity_matches_pattern == False:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_gafparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,24 @@ def test_id_syntax():
messages = p.report.to_report_json()["messages"]
assert len(messages["gorule-0000027"]) == 1
assert messages["gorule-0000027"][0]["obj"] == "PMID:PMID: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\tPMID:0.\tIPI\tPomBase:SPAC25A8.01c\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"] == "PMID:0."

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\tPMID:x18422602\tIPI\tPomBase:SPAC25A8.01c\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"] == "PMID:x18422602"

p = GafParser(config=assocparser.AssocParserConfig(
ontology=OntologyFactory().create(ONT), db_type_name_regex_id_syntax=database_id_syntax_lookups))
Expand Down
48 changes: 47 additions & 1 deletion tests/test_gpad_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,53 @@ def test_id_syntax():
assert result.skipped == False
messages = p.report.to_report_json()["messages"]
assert len(messages["gorule-0000027"]) == 1
assert messages["gorule-0000027"][0]["obj"] == "PMID:PMID:15494018"
assert messages["gorule-0000027"][0]["obj"] == "PMID:PMID:15494018"

vals = ["PomBase",
"SPAC25A8.01c",
"acts_upstream_of_or_within",
"GO:0007155",
"PMID:9.",
"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"] == "PMID:9."


vals = ["PomBase",
"SPAC25A8.01c",
"acts_upstream_of_or_within",
"GO:0007155",
"PMID:a1549418",
"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"] == "PMID:a1549418"


vals = ["PomBase",
"SPAC25A8.01c",
Expand Down

0 comments on commit 5f865b1

Please sign in to comment.