Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NCI Thesaurus #10

Merged
merged 8 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bioversions/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .mesh import MeshGetter
from .mirbase import MirbaseGetter
from .msigdb import MSigDBGetter
from .ncit import NCItGetter
from .npass import NPASSGetter
from .obo import iter_obo_getters
from .ols import extend_ols_getters
Expand Down Expand Up @@ -87,6 +88,7 @@ def get_getters() -> List[Type[Getter]]:
PombaseGetter,
SgdGetter,
ZfinGetter,
NCItGetter,
]
getters.extend(iter_obo_getters())
extend_ols_getters(getters)
Expand Down
40 changes: 40 additions & 0 deletions src/bioversions/sources/ncit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-

"""A getter for the NCI Thesaurus."""

import re
from typing import Dict

from ..utils import Getter, VersionType, get_soup

__all__ = [
"NCItGetter",
]

URL = "https://ncithesaurus.nci.nih.gov/ncitbrowser/"
PATTERN = re.compile(
r"Version:([0-9]{2}\.[0-9]{2}[a-z]) " r"\(Release date:([0-9]{4}-[0-9]{2}-[0-9]{2})"
)


class NCItGetter(Getter):
"""A getter for the NCI Thesaurus."""

bioregistry_id = "ncit"
name = "National Cancer Institute Thesaurus"
date_fmt = "%Y-%m-%d"
version_type = VersionType.other

def get(self) -> Dict[str, str]:
"""Get the latest NCIt version number."""
soup = get_soup(URL)
version_str = soup.find("span", {"class": "vocabularynamelong_ncit"}).contents[0]
match = re.search(PATTERN, version_str)
return {
"version": match.group(1),
"date": match.group(2),
}


if __name__ == "__main__":
NCItGetter.print()