Skip to content

Commit

Permalink
Handle preferred curies
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 4, 2024
1 parent d1f435e commit f5d6779
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pyobo/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ def _extract_synonym(
rest = rest[len(_stype.curie) :].strip()
stype = _stype
break
elif rest.startswith(_stype.preferred_curie):
rest = rest[len(_stype.preferred_curie) :].strip()
stype = _stype
break
elif rest.startswith(_stype.identifier):
rest = rest[len(_stype.identifier) :].strip()
stype = _stype
Expand Down
13 changes: 13 additions & 0 deletions tests/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_extract_synonym(self):
iupac_name = SynonymTypeDef.from_text("IUPAC NAME", lower=False)
synoynym_typedefs = {
"IUPAC_NAME": iupac_name,
acronym.curie: acronym,
}

for expected_synonym, text in [
Expand Down Expand Up @@ -142,6 +143,18 @@ def test_extract_synonym(self):
Synonym(name="HAdV-A", specificity="BROAD", type=acronym),
'"HAdV-A" BROAD OMO:0003012 []',
),
(
Synonym(name="HAdV-A", specificity="BROAD", type=acronym),
'"HAdV-A" BROAD omo:0003012 []',
),
(
Synonym(name="HAdV-A", specificity="EXACT", type=acronym),
'"HAdV-A" OMO:0003012 []',
),
(
Synonym(name="HAdV-A", specificity="EXACT", type=acronym),
'"HAdV-A" omo:0003012 []',
),
]:
with self.subTest(s=text):
actual_synonym = _extract_synonym(
Expand Down

0 comments on commit f5d6779

Please sign in to comment.