Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 20, 2024
1 parent 6221cf3 commit 76e6dc1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/bioversions/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .chebi import ChEBIGetter
from .chembl import ChEMBLGetter
from .chemidplus import ChemIDplusGetter
from .gtdb import GTDBGetter
from .civic import CiVICGetter
from .complexportal import ComplexPortalGetter
from .daily import NCBIGeneGetter
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
23 changes: 10 additions & 13 deletions src/bioversions/sources/gtdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""A getter for GTDB."""

Expand All @@ -10,29 +9,27 @@
"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 = "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."""
url = "https://data.gtdb.ecogenomic.org/releases/latest/VERSION.txt"
with requests.Session() as session:
res = session.get(url)
if res.ok:
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().replace("Released ", "")
return {"version": version, "date": date}
raise ValueError(f"Could not determine latest GTDB version. Status: {res.status_code}")
res = requests.get(URL)
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().replace("Released ", "")
return {"version": version, "date": date}


if __name__ == "__main__":
Expand Down

0 comments on commit 76e6dc1

Please sign in to comment.