Skip to content

Commit 90cd58b

Browse files
authored
Add ICONCLASS source (#433)
Closes #432
1 parent 6a5e92b commit 90cd58b

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

src/pyobo/sources/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from .hgnc import HGNCGetter, HGNCGroupGetter
3535
from .iana_media_type import IANAGetter
3636
from .icd import ICD10Getter, ICD11Getter
37+
from .iconclass import IconclassGetter
3738
from .intact import IntactGetter
3839
from .interpro import InterProGetter
3940
from .itis import ITISGetter
@@ -115,6 +116,7 @@
115116
"ICD10Getter",
116117
"ICD11Getter",
117118
"ITISGetter",
119+
"IconclassGetter",
118120
"IntactGetter",
119121
"InterProGetter",
120122
"KEGGGeneGetter",

src/pyobo/sources/chembl/chembl_target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def iter_terms(version: str) -> Iterable[Term]:
138138
def get_chembl_protein_equivalences(version: str | None = None) -> dict[str, list[str]]:
139139
"""Get ChEMBL protein equivalences."""
140140
if version is None:
141-
version = chembl_downloader.latest()
141+
version = chembl_downloader.latest(full=False)
142142
url = f"ftp://ftp.ebi.ac.uk/pub/databases/chembl/ChEMBLdb/releases/chembl_{version}/chembl_uniprot_mapping.txt"
143143
df = ensure_df(
144144
PREFIX,

src/pyobo/sources/iconclass.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""Get ICONCLASS as OBO."""
2+
3+
from collections.abc import Iterable
4+
from urllib.parse import quote
5+
6+
import pandas as pd
7+
8+
from pyobo.struct import Obo, Term
9+
from pyobo.utils.path import ensure_df
10+
11+
__all__ = [
12+
"IconclassGetter",
13+
]
14+
15+
PREFIX = "iconclass"
16+
BASE_URL = "https://github.com/iconclass/data/raw/refs/heads/main/txt/en/txt_en_{}.txt"
17+
URLS = [
18+
BASE_URL.format("0_1"),
19+
BASE_URL.format("2_3"),
20+
BASE_URL.format("4"),
21+
BASE_URL.format("5_6_7_8"),
22+
BASE_URL.format("9"),
23+
BASE_URL.format("keys"),
24+
# shakespeare
25+
]
26+
27+
28+
def get_df() -> pd.DataFrame:
29+
"""Get an ICONCLASS terms dataframe."""
30+
df = pd.concat(
31+
ensure_df(prefix=PREFIX, url=url, sep="|", names=["luid", "name"]) for url in URLS
32+
)
33+
return df
34+
35+
36+
def iter_terms() -> Iterable[Term]:
37+
"""Iterate over terms in ICONCLASS."""
38+
for luid, name in get_df().values:
39+
yv = Term.from_triple(prefix=PREFIX, identifier=quote(luid), name=name)
40+
yield yv
41+
42+
43+
class IconclassGetter(Obo):
44+
"""An ontology representation of ICONCLASS."""
45+
46+
ontology = PREFIX
47+
dynamic_version = True
48+
49+
def iter_terms(self, force: bool = False) -> Iterable[Term]:
50+
"""Iterate over terms in the ontology."""
51+
return iter_terms()
52+
53+
54+
if __name__ == "__main__":
55+
IconclassGetter.cli()

tests/test_struct/test_obo/test_typedef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def test_32_relationship(self) -> None:
835835

836836
def test_33_is_obsolete(self) -> None:
837837
"""Test the ``is_obsolete`` tag."""
838-
td_true, td_false = self.assert_boolean_tag("is_obsolete", funowl_curie="owl:deprecated")
838+
self.assert_boolean_tag("is_obsolete", funowl_curie="owl:deprecated")
839839

840840
def test_34_created_by(self) -> None:
841841
"""Test the ``created_by`` tag."""

0 commit comments

Comments
 (0)