From f103afeb3176c3dd39321e12ded46b742bf4a81a Mon Sep 17 00:00:00 2001 From: Melissa Gymrek Date: Fri, 4 Oct 2024 16:09:39 -0700 Subject: [PATCH 1/4] add option to skip loading dash --- README.md | 1 + WebSTR/WebSTR.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 272229c..d898e2a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ cd webstr # optionally, checkout a specific branch to test export BASEPATH=*full data directory path* export FLASK_DEBUG=1 # run in debug mode +export NODASH=1 # optional, skip loading dash modules python ./WebSTR/WebSTR.py --host 0.0.0.0 --port ``` diff --git a/WebSTR/WebSTR.py b/WebSTR/WebSTR.py index d3ba3f2..43ece27 100755 --- a/WebSTR/WebSTR.py +++ b/WebSTR/WebSTR.py @@ -16,11 +16,11 @@ from locus_view import * from region_view import * from gene_plots import * -from dash_graphs import add_dash_graphs_to_flask_server # Grab environment variables API_URL = os.environ.get("WEBSTR_API_URL",'http://webstr-api.ucsd.edu') BASEPATH = os.environ.get("BASEPATH", "/storage/resources/dbase/human/") +NODASH = os.environ.get("NODASH", 0) == "1" #################### Data paths ############### RefFaPath_hg19 = os.path.join(BASEPATH, "hg19", "hg19.fa") @@ -29,7 +29,11 @@ #################### Set up flask server ############### server = Flask(__name__) server.secret_key = 'dbSTR' -add_dash_graphs_to_flask_server(server) + +#################### Set up dash ############### +if not NODASH: + from dash_graphs import add_dash_graphs_to_flask_server + add_dash_graphs_to_flask_server(server) #################### Render region page ############### @server.route('/search') From 70dc876ced053527468e1a6f43335e0b0841b1d9 Mon Sep 17 00:00:00 2001 From: Melissa Gymrek Date: Fri, 4 Oct 2024 16:10:03 -0700 Subject: [PATCH 2/4] remove gunicorn from frontend requirements --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fd5c532..9274e30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,5 +19,4 @@ tenacity==8.1.0 urllib3==1.26.13 Werkzeug==2.2.2 zipp==3.11.0 -gunicorn==20.1.0 dash_bio==1.0.2 \ No newline at end of file From 9f7b76867dd9f65fcf3ae17cc5a971dce78e2b84 Mon Sep 17 00:00:00 2001 From: Melissa Gymrek Date: Fri, 4 Oct 2024 16:20:39 -0700 Subject: [PATCH 3/4] safely handle missing seq data --- WebSTR/locus_view.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WebSTR/locus_view.py b/WebSTR/locus_view.py index 602d4e9..28a802f 100644 --- a/WebSTR/locus_view.py +++ b/WebSTR/locus_view.py @@ -319,6 +319,8 @@ def GetSeqDataAPI(repeat_id): sys.stderr.write("WARNING: could not access allseq table from API\n") return None df = pd.DataFrame.from_records(resp.json()) + if df.shape[0] == 0: + return None agg_df = df.pivot_table(index='sequence', columns='population', values='frequency', aggfunc='first').reset_index() agg_df = agg_df.fillna(0) From 7849a603d9dc3ed1a291604b2f750162de21c47b Mon Sep 17 00:00:00 2001 From: Melissa Gymrek Date: Fri, 4 Oct 2024 16:22:37 -0700 Subject: [PATCH 4/4] handle missing sequence data --- WebSTR/locus_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebSTR/locus_view.py b/WebSTR/locus_view.py index 28a802f..c36c5ad 100644 --- a/WebSTR/locus_view.py +++ b/WebSTR/locus_view.py @@ -319,7 +319,7 @@ def GetSeqDataAPI(repeat_id): sys.stderr.write("WARNING: could not access allseq table from API\n") return None df = pd.DataFrame.from_records(resp.json()) - if df.shape[0] == 0: + if df.empty: return None agg_df = df.pivot_table(index='sequence', columns='population', values='frequency', aggfunc='first').reset_index() agg_df = agg_df.fillna(0)