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 oncotree #20

Merged
merged 6 commits into from
Oct 3, 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 @@ -33,6 +33,7 @@
from .npass import NPASSGetter
from .obo import iter_obo_getters
from .ols import extend_ols_getters
from .oncotree import OncoTreeGetter
from .pathbank import PathBankGetter
from .pfam import PfamGetter
from .pombase import PombaseGetter
Expand Down Expand Up @@ -94,6 +95,7 @@ def get_getters() -> List[Type[Getter]]:
NCItGetter,
RxNormGetter,
ChemIDplusGetter,
OncoTreeGetter,
MOAlmanacGetter,
]
getters.extend(iter_obo_getters())
Expand Down
40 changes: 40 additions & 0 deletions src/bioversions/sources/oncotree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-

"""A getter for OncoTree."""

import requests

from ..utils import Getter, VersionType


__all__ = [
"OncoTreeGetter",
]


class OncoTreeGetter(Getter):
"""A getter for OncoTree."""

bioregistry_id = "oncotree"
name = "OncoTree"
homepage_fmt = "http://oncotree.mskcc.org/api/tumorTypes?version=oncotree_{version}"
version_type = VersionType.date
date_version_fmt = "%Y-%m-%d"

def get(self) -> str:
"""Get the latest OncoTree version number."""
res = requests.get("http://oncotree.mskcc.org/api/versions", params={"format": "json"})
res_json = res.json()
version = next(
(r["release_date"] for r in res_json if r["api_identifier"] == "oncotree_latest_stable")
)
return version

@staticmethod
def homepage_version_transform(version: str) -> str:
"""Reformat version value for OncoTree data URL."""
return version.replace("-", "_")


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