Skip to content

Commit

Permalink
Add OMIM getter and update CI (#42)
Browse files Browse the repository at this point in the history
Closes #41, updates to use tox-uv, and updates to test on py312
  • Loading branch information
cthoyt authored Mar 25, 2024
1 parent a9e6414 commit f1a7879
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11", "3.8" ]
python-version: [ "3.12", "3.8" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
run: pip install tox tox-uv
- name: Check manifest
run: tox -e manifest
- name: Check code quality with flake8
Expand All @@ -35,15 +35,15 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.11", "3.8" ]
python-version: [ "3.12", "3.8" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
run: pip install tox tox-uv
- name: Test with pytest
run:
tox -e py
4 changes: 4 additions & 0 deletions src/bioversions/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from .npass import NPASSGetter
from .obo import iter_obo_getters
from .ols import extend_ols_getters
from .omim import OMIMGetter
from .oncotree import OncoTreeGetter
from .pathbank import PathBankGetter
from .pathwaycommons import PathwayCommonsGetter
Expand Down Expand Up @@ -127,6 +128,7 @@ def get_getters() -> List[Type[Getter]]:
RGDGetter,
CellosaurusGetter,
MGIGetter,
OMIMGetter,
]
getters.extend(iter_obo_getters())
extend_ols_getters(getters)
Expand All @@ -143,6 +145,8 @@ def get_getter_dict() -> Mapping[str, Type[Getter]]:
rv[norm(getter.bioregistry_id)] = getter
rv[getter.name] = getter
rv[norm(getter.name)] = getter
# TODO engineer this into the data model and backfill them
rv["omim.ps"] = OMIMGetter
return rv


Expand Down
34 changes: 34 additions & 0 deletions src/bioversions/sources/omim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

"""A getter for the OMIM."""


from bioversions.utils import Getter, VersionType, get_soup

__all__ = [
"OMIMGetter",
]


class OMIMGetter(Getter):
"""A getter for OMIM."""

bioregistry_id = "omim"
name = "Online Mendelian Inheritance in Man"
date_version_fmt = "%B %d, %Y"
version_type = VersionType.date

def get(self) -> str:
"""Get the latest OMIM version number."""
soup = get_soup("https://omim.org/")
for tag in soup.find_all("h5"):
text = tag.text.strip()
if text.startswith("Updated"):
rv = text[len("Updated") :].strip()
rv = rv.replace("nd", "").replace("st", "").replace("rd", "").replace("th", "")
return rv
raise ValueError


if __name__ == "__main__":
OMIMGetter.print()
9 changes: 7 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ description = Run black.
skip_install = true
deps =
darglint
flake8<5.0.0
flake8
# flake8-bandit
flake8-black
flake8-bugbear
Expand All @@ -95,7 +95,11 @@ commands =
description = Run the flake8 tool with several plugins (bandit, docstrings, import order, pep8 naming).

[testenv:mypy]
deps = mypy
deps =
mypy
types-PyYAML
types-requests
types-tabulate
skip_install = true
commands = mypy --install-types --non-interactive --ignore-missing-imports src/bioversions/
description = Run the mypy tool to check static typing on the project.
Expand Down Expand Up @@ -159,6 +163,7 @@ skip_install = true
deps =
wheel
build
setuptools
commands =
python -m build --sdist --wheel --no-isolation

Expand Down

0 comments on commit f1a7879

Please sign in to comment.