Skip to content

Commit

Permalink
Merge pull request #49 from hannamlmv/main
Browse files Browse the repository at this point in the history
Project Work
  • Loading branch information
tforest authored Jan 17, 2025
2 parents cb8efef + 566c4d5 commit aeb7693
Show file tree
Hide file tree
Showing 25 changed files with 2,325 additions and 600 deletions.
Binary file added .DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: tseda serve",
"type": "debugpy",
"request": "launch",
"module": "tseda", // Use the module 'tseda' directly
"args": [
"serve", "tests/data/test.trees.tseda" // Arguments to the module
],
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"justMyCode": true,
"python": "${workspaceFolder}/.venv/bin/python"
}
]
}

10 changes: 4 additions & 6 deletions src/tseda/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def cli():
),
)
def preprocess(tszip_path, output):
"""
Preprocess a tskit tree sequence or tszip file, producing a .tseda file.
"""Preprocess a tskit tree sequence or tszip file, producing a .tseda file.
Calls tsbrowse.preprocess.preprocess.
"""
tszip_path = pathlib.Path(tszip_path)
Expand Down Expand Up @@ -79,9 +79,7 @@ def preprocess(tszip_path, output):
help="Do not filter the output log (advanced debugging only)",
)
def serve(path, port, show, log_level, no_log_filter, admin):
"""
Run the tseda datastore server, version based on View base class.
"""
"""Run the tseda datastore server, version based on View base class."""
setup_logging(log_level, no_log_filter)

tsm = TSModel(path)
Expand All @@ -91,8 +89,8 @@ def serve(path, port, show, log_level, no_log_filter, admin):
app_ = app.DataStoreApp(
datastore=datastore.DataStore(
tsm=tsm,
individuals_table=individuals_table,
sample_sets_table=sample_sets_table,
individuals_table=individuals_table,
),
title="TSEda Datastore App",
views=[IndividualsTable],
Expand Down
56 changes: 39 additions & 17 deletions src/tseda/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Main application for tseda.
Provides the DataStoreApp class that is the main application for
tseda. The DataStoreApp subclasses the Viewer class from panel and
renders a panel.FastListTemplate object.
Provides the DataStoreApp class that is the main application for tseda. The
DataStoreApp subclasses the Viewer class from panel and renders a
panel.FastListTemplate object.
"""

import time
Expand All @@ -20,7 +20,7 @@

RAW_CSS = """
.sidenav#sidebar {
background-color: #15E3AC;
background-color: WhiteSmoke;
}
.title {
font-size: var(--type-ramp-plus-2-font-size);
Expand Down Expand Up @@ -50,7 +50,20 @@


class DataStoreApp(Viewer):
"""Main application class for tseda visualization app."""
"""Main application class for tseda visualization app.
Attributes:
datastore (DataStore): The data store instance for accessing and
managing data.
title (str): The title of the application.
views (List[str]): A list of views to show on startup.
Methods:
__init__(**params): Initializes the application, loads pages, and sets
up data update listeners.
view(): Creates the main application view, including a header selector
for switching between different pages.
"""

datastore = param.ClassSelector(class_=datastore.DataStore)

Expand All @@ -71,21 +84,28 @@ def __init__(self, **params):
logger.info(f"Initialised pages in {time.time() - t:.2f}s")

updating = (
self.datastore.individuals_table.data.rx.updating()
| self.datastore.sample_sets_table.data.rx.updating()
self.datastore.sample_sets_table.data.rx.updating()
| self.datastore.individuals_table.data.rx.updating()
)
updating.rx.watch(
lambda updating: pn.state.curdoc.hold()
if updating
else pn.state.curdoc.unhold()
lambda updating: (
pn.state.curdoc.hold()
if updating
else pn.state.curdoc.unhold()
)
)

@param.depends("views")
def view(self):
"""Main application view that renders a radio button group on
top with links to pages. Each page consists of a main content
page with plots and sidebars that provide user options for
configuring plots and outputs."""
"""Creates the main application view. Main application view that
renders a radio button group on top with links to pages. Each page
consists of a main content page with plots and sidebars that provide
user options for configuring plots and outputs.
Returns:
pn.template.FastListTemplate: A Panel template containing the
header selector, sidebar, and main content.
"""
page_titles = list(self.pages.keys())
header_selector = pn.widgets.RadioButtonGroup(
options=page_titles,
Expand All @@ -105,9 +125,11 @@ def get_sidebar(selected_page):
yield self.pages[selected_page].sidebar

self._template = pn.template.FastListTemplate(
title=self.datastore.tsm.name[:75] + "..."
if len(self.datastore.tsm.name) > 75
else self.datastore.tsm.name,
title=(
self.datastore.tsm.name[:75] + "..."
if len(self.datastore.tsm.name) > 75
else self.datastore.tsm.name
),
header=[header_selector],
sidebar=get_sidebar,
main=get_content,
Expand Down
12 changes: 11 additions & 1 deletion src/tseda/cache.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""This module provides a caching mechanism for the TSeDA application,
utilizing the `diskcache` library."""

import pathlib

import appdirs
Expand All @@ -7,7 +10,14 @@
logger = daiquiri.getLogger("cache")


def get_cache_dir():
def get_cache_dir() -> pathlib.Path:
"""Retrieves the user's cache directory for the TSeDA application. Creates
the directory if it doesn't exist, ensuring its creation along with any
necessary parent directories.
Returns:
pathlib.Path: The path to the cache directory.
"""
cache_dir = pathlib.Path(appdirs.user_cache_dir("tseda", "tseda"))
cache_dir.mkdir(exist_ok=True, parents=True)
return cache_dir
Expand Down
10 changes: 8 additions & 2 deletions src/tseda/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""Config file.
This file stores configurations for the entire application such as figure
dimensions and color schemes.
"""

import holoviews as hv
from holoviews.plotting.util import process_cmap

Expand All @@ -8,9 +14,9 @@
PLOT_COLOURS = ["#15E3AC", "#0FA57E", "#0D5160"]

# VCard settings
SIDEBAR_BACKGROUND = "#15E3AC"
SIDEBAR_BACKGROUND = "#5CB85D"
VCARD_STYLE = {
"background": "#15E3AC",
"background": "WhiteSmoke",
}

# Global color map
Expand Down
Loading

0 comments on commit aeb7693

Please sign in to comment.