From 9094acef592a3e39fae0966a415aeae1cd43b0d1 Mon Sep 17 00:00:00 2001 From: jessbade Date: Fri, 23 Feb 2024 10:44:46 -0800 Subject: [PATCH] Add tinkerxyz reference lookup function --- isicle/utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/isicle/utils.py b/isicle/utils.py index c6754b3..c82a27e 100644 --- a/isicle/utils.py +++ b/isicle/utils.py @@ -5,6 +5,7 @@ from importlib import resources import shutil import tempfile +from ast import literal_eval def safelist(x): @@ -130,6 +131,13 @@ def tinker_lookup(): return pd.read_csv(path, sep="\t") +def tinkerxyz_lookup(): + path = resources.files("isicle") / "resources/tinkerxyz_lookup.tsv" + df = pd.read_csv(path, sep="\t", index_col=[0, 1]) + df["lookup"] = df["lookup"].apply(lambda x: literal_eval(x)) + return df + + def gettempdir(): """ Return the name of the directory used for temporary files. @@ -140,16 +148,16 @@ def gettempdir(): Path to temporary directory. """ - - root = os.path.join(tempfile.gettempdir(), 'isicle') + + root = os.path.join(tempfile.gettempdir(), "isicle") os.makedirs(root, exist_ok=True) - + return root def mkdtemp(prefix=None, suffix=None): """ - An ISiCLE-specific wrapper of :func:`~tempfile.mkdtemp` to create a + An ISiCLE-specific wrapper of :func:`~tempfile.mkdtemp` to create a temporary directory for temporary ISiCLE files. The temporary directory is not automatically removed.