From b42b452202759397d41fcdb0fc911dfa069e53a4 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 7 Dec 2023 14:20:16 -0500 Subject: [PATCH] Re-create data folder --- jbrowse_jupyter/data/__init__.py | 0 jbrowse_jupyter/{ => data}/hg19.json | 0 jbrowse_jupyter/{ => data}/hg19_cgv.json | 0 jbrowse_jupyter/{ => data}/hg38.json | 0 jbrowse_jupyter/{ => data}/hg38_cgv.json | 0 jbrowse_jupyter/util.py | 15 +++++++-------- 6 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 jbrowse_jupyter/data/__init__.py rename jbrowse_jupyter/{ => data}/hg19.json (100%) rename jbrowse_jupyter/{ => data}/hg19_cgv.json (100%) rename jbrowse_jupyter/{ => data}/hg38.json (100%) rename jbrowse_jupyter/{ => data}/hg38_cgv.json (100%) 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..6b31b1e 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):