Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken pages when sequence data not available #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <port>
```

Expand Down
8 changes: 6 additions & 2 deletions WebSTR/WebSTR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions WebSTR/locus_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.empty:
return None
agg_df = df.pivot_table(index='sequence', columns='population', values='frequency', aggfunc='first').reset_index()
agg_df = agg_df.fillna(0)

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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