Skip to content

Commit

Permalink
Add GTDB (#46)
Browse files Browse the repository at this point in the history
Adding "Getter" for GTDB to be used in pyOBO module for GTDB I have in
development.

---------

Co-authored-by: Jose Pedro Lopes Faria <[email protected]>
Co-authored-by: Charles Tapley Hoyt <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent c23a6f1 commit 7455e73
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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 .ensembl import EnsemblGetter
from .expasy import ExPASyGetter
from .flybase import FlybaseGetter
from .gtdb import GTDBGetter
from .guidetopharmacology import GuideToPharmacologyGetter
from .hgnc import HGNCGetter
from .homologene import HomoloGeneGetter
Expand Down Expand Up @@ -137,6 +138,7 @@ def get_getters() -> list[type[Getter]]:
ICD10Getter,
ICD11Getter,
CiVICGetter,
GTDBGetter,
]
getters.extend(iter_obo_getters())
extend_ols_getters(getters)
Expand Down
35 changes: 35 additions & 0 deletions src/bioversions/sources/gtdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""A getter for GTDB."""

import requests

from bioversions.utils import Getter, VersionType

__all__ = [
"GTDBGetter",
]

URL = "https://data.gtdb.ecogenomic.org/releases/latest/VERSION.txt"


class GTDBGetter(Getter):
"""A getter for the Genome Taxonomy Database (GTDB)."""

bioregistry_id = "gtdb"
name = "Genome Taxonomy Database"
version_type = VersionType.sequential
date_fmt = "%b %d, %Y" # Format to match "Apr 24, 2024"
homepage_fmt = "https://gtdb.ecogenomic.org/"

def get(self):
"""Get the latest GTDB version number from VERSION.txt."""
res = requests.get(URL, timeout=15)
lines = res.text.strip().split("\n")
# First line contains version like "v220"
version = lines[0].strip().lstrip("v")
# Third line contains date like "Released Apr 24, 2024"
date = lines[2].strip().removeprefix("Released ")
return {"version": version, "date": date}


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

0 comments on commit 7455e73

Please sign in to comment.