From 76e6dc1e33b8eb7e561efcda6441789e54b90f19 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Wed, 20 Nov 2024 10:54:05 +0100 Subject: [PATCH] Cleanup --- src/bioversions/sources/__init__.py | 2 ++ src/bioversions/sources/gtdb.py | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/bioversions/sources/__init__.py b/src/bioversions/sources/__init__.py index 9d297a74..502aaafa 100644 --- a/src/bioversions/sources/__init__.py +++ b/src/bioversions/sources/__init__.py @@ -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 @@ -137,6 +138,7 @@ def get_getters() -> List[Type[Getter]]: ICD10Getter, ICD11Getter, CiVICGetter, + GTDBGetter, ] getters.extend(iter_obo_getters()) extend_ols_getters(getters) diff --git a/src/bioversions/sources/gtdb.py b/src/bioversions/sources/gtdb.py index 6ea5cfa3..80338165 100644 --- a/src/bioversions/sources/gtdb.py +++ b/src/bioversions/sources/gtdb.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """A getter for GTDB.""" @@ -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__":