Skip to content

Commit

Permalink
Update gtdb.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 20, 2024
1 parent 63cb022 commit 6221cf3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/bioversions/sources/gtdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@
"""A getter for GTDB."""

import requests

from bioversions.utils import Getter, VersionType

__all__ = [
"GTDBGetter",
]


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

bioregistry_id = "gtdb"
name = "GTDB"
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')
lines = res.text.strip().split("\n")
# First line contains version like "v220"
version = lines[0].strip().lstrip('v')
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
}
date = lines[2].strip().replace("Released ", "")
return {"version": version, "date": date}
raise ValueError(f"Could not determine latest GTDB version. Status: {res.status_code}")


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

0 comments on commit 6221cf3

Please sign in to comment.