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

ENA request: fix new URL + better check #323

Merged
merged 1 commit into from
Mar 18, 2024
Merged
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
7 changes: 6 additions & 1 deletion src/python/ensembl/io/genomio/seq_region/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,14 @@ def add_mitochondrial_codon_table(seq_regions: List[SeqRegion], taxon_id: int) -
taxon_id: The species taxon ID.

"""
url = f"https://www.ebi.ac.uk/ena/data/taxonomy/v1/taxon/tax-id/{str(taxon_id)}"
url = f"https://www.ebi.ac.uk/ena/taxonomy/rest/tax-id/{str(taxon_id)}"
response = requests.get(url, headers={"Content-Type": "application/json"}, timeout=60)
response.raise_for_status()
# In case we've been redirected, check for html opening tag
if response.text.startswith("<"):
raise ValueError(f"Response from {url} is not JSON")
decoded = response.json()

if "mitochondrialGeneticCode" not in decoded:
logging.warning("No mitochondria genetic code found for taxon {taxon_id}")
else:
Expand Down
Loading