diff --git a/jbrowse_jupyter/data/__init__.py b/jbrowse_jupyter/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jbrowse_jupyter/hg19.json b/jbrowse_jupyter/data/hg19.json similarity index 100% rename from jbrowse_jupyter/hg19.json rename to jbrowse_jupyter/data/hg19.json diff --git a/jbrowse_jupyter/hg19_cgv.json b/jbrowse_jupyter/data/hg19_cgv.json similarity index 100% rename from jbrowse_jupyter/hg19_cgv.json rename to jbrowse_jupyter/data/hg19_cgv.json diff --git a/jbrowse_jupyter/hg38.json b/jbrowse_jupyter/data/hg38.json similarity index 100% rename from jbrowse_jupyter/hg38.json rename to jbrowse_jupyter/data/hg38.json diff --git a/jbrowse_jupyter/hg38_cgv.json b/jbrowse_jupyter/data/hg38_cgv.json similarity index 100% rename from jbrowse_jupyter/hg38_cgv.json rename to jbrowse_jupyter/data/hg38_cgv.json diff --git a/jbrowse_jupyter/util.py b/jbrowse_jupyter/util.py index 55a25a7..49e888c 100644 --- a/jbrowse_jupyter/util.py +++ b/jbrowse_jupyter/util.py @@ -1,7 +1,8 @@ import re import os import json -import pkg_resources +from importlib_resources import files + import dash_jbrowse as jb from dash import html, Dash from urllib.parse import urlparse @@ -55,14 +56,12 @@ def get_name_regex(assembly_file): def get_default(name, view_type="LGV"): """Returns the configuration object given a genome name.""" - base = pkg_resources.resource_filename("jbrowse_jupyter") - file_name = f"{base}/{name}.json" + base = pkg_resources.resource_filename("jbrowse_jupyter", "data") + # Reads contents with UTF-8 encoding and returns str. if view_type == "CGV": - file_name = f"{base}/{name}_cgv.json" - conf = {} - with open(file_name) as json_data: - conf = json.load(json_data) - return conf + return files(f"jbrowse_jupyter.data.${name}_cgv.json").read_json() + else: + return files(f"jbrowse_jupyter.data.${name}.json").read_json() def create_component(conf, **kwargs):