Skip to content

Commit

Permalink
Merge pull request #49 from grexor/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
grexor authored Nov 12, 2024
2 parents f6bfb03 + c2176d1 commit ba22f61
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pybio/core/genomes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ensembl REST API, https://rest.ensembl.org

import sys
import os
import bisect
import pybio
Expand All @@ -14,8 +15,8 @@
import pickle
import math
import requests
import sys
requests.packages.urllib3.disable_warnings()
import urllib3
urllib3.disable_warnings()

process = psutil.Process(os.getpid())

Expand Down Expand Up @@ -465,9 +466,11 @@ def list_species_ensembl(prepared=True):
if prepared:
if not os.path.exists(pybio.config.genomes_folder):
os.makedirs(pybio.config.genomes_folder)
genome_species_online = "https://raw.githubusercontent.com/grexor/pybio/master/ensembl/ensembl.json"
genome_species_online = "http://raw.githubusercontent.com/grexor/pybio/master/ensembl/ensembl.json"
r = requests.get(genome_species_online, allow_redirects=True, verify=False)
open(os.path.join(pybio.config.genomes_folder, "ensembl.json"), "wb").write(r.content)
f = open(os.path.join(pybio.config.genomes_folder, "ensembl.json"), "wb")
f.write(r.content)
f.close()
else:
print("[pybio.core.genomes] Species list from Ensembl; done once and takes ~ 1 minute")
ensembl_version = get_latest_ensembl()
Expand Down Expand Up @@ -520,8 +523,8 @@ def listFD(url, ext=''):
assert(species.capitalize()==species_long)
db[species] = {"display_name":genome_data.get('display_name', ''), "assembly": f"{species_assembly}", "genome_version": f"ensemblgenomes{ensemblgenomes_version}", "provider": "ensemblgenomes", "provider_subfolder": f"{subfolder}"}
f.close()
# save db to ensembl.json
json.dump(db, open(os.path.join(pybio.config.genomes_folder, "ensembl.json"), "wt"), indent=4)
# save db to ensembl.json
json.dump(db, open(os.path.join(pybio.config.genomes_folder, "ensembl.json"), "wt"), indent=4)

print()
print("[pybio.core.genomes] Complete species list downloaded to:", os.path.join(pybio.config.genomes_folder, "ensembl.json"))
Expand Down

0 comments on commit ba22f61

Please sign in to comment.