Spaces:
Sleeping
Sleeping
wzkariampuzha
commited on
Commit
•
8ed723b
1
Parent(s):
b564537
Update app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,20 @@ import nltk
|
|
2 |
nltk.data.path.append("/home/user/app/nltk_data")
|
3 |
#nltk.download('stopwords')
|
4 |
#nltk.download('punkt')
|
5 |
-
import
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
import pandas as pd
|
8 |
#pd.set_option('display.max_colwidth', None)
|
9 |
import streamlit as st
|
10 |
st.set_page_config(layout="wide")
|
11 |
-
import spacy
|
12 |
-
import tensorflow as tf
|
13 |
-
import pickle
|
14 |
-
import re
|
15 |
import plotly.graph_objects as go
|
16 |
|
17 |
#### LOGO ####
|
@@ -58,23 +62,20 @@ filtering = st.sidebar.radio("What type of filtering would you like?",('Strict',
|
|
58 |
extract_diseases = st.sidebar.checkbox("Extract Rare Diseases", value=False)
|
59 |
|
60 |
#### MODEL LOADING ####
|
61 |
-
|
62 |
@st.experimental_singleton(show_spinner=False)
|
63 |
def load_models_experimental():
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
return
|
68 |
|
69 |
#### DOWNLOAD FUNCTION ####
|
70 |
-
|
71 |
@st.cache
|
72 |
def convert_df(df):
|
73 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
74 |
return df.to_csv().encode('utf-8')
|
75 |
|
76 |
#### SANKEY FUNCTION ####
|
77 |
-
|
78 |
#@st.cache(allow_output_mutation=True)
|
79 |
@st.experimental_singleton()
|
80 |
def epi_sankey(sankey_data, disease_or_gard_id):
|
@@ -103,9 +104,8 @@ def epi_sankey(sankey_data, disease_or_gard_id):
|
|
103 |
return fig
|
104 |
|
105 |
#### BEGIN APP ####
|
106 |
-
|
107 |
with st.spinner('Loading Epidemiology Models and Dependencies...'):
|
108 |
-
|
109 |
loaded = st.success('All Models and Dependencies Loaded!')
|
110 |
|
111 |
disease_or_gard_id = st.text_input("Input a rare disease term or NIH GARD ID.")
|
@@ -115,10 +115,8 @@ loaded.empty()
|
|
115 |
st.markdown("Examples of rare diseases include [**Fellman syndrome**](https://rarediseases.info.nih.gov/diseases/1/gracile-syndrome), [**Classic Homocystinuria**](https://rarediseases.info.nih.gov/diseases/6667/classic-homocystinuria), [**7383**](https://rarediseases.info.nih.gov/diseases/7383/phenylketonuria), and [**GARD:0009941**](https://rarediseases.info.nih.gov/diseases/9941/fshmd1a). A full list of rare diseases tracked by the NIH Genetic and Rare Diseases Information Center (GARD) can be found [here](https://rarediseases.info.nih.gov/diseases/browse-by-first-letter).")
|
116 |
|
117 |
if disease_or_gard_id:
|
118 |
-
df, sankey_data, name_gardID =
|
119 |
-
|
120 |
-
extract_diseases, GARD_dict, max_length,
|
121 |
-
classify_model_vars)
|
122 |
#IF it returns something, then continue.
|
123 |
if sankey_data:
|
124 |
df.replace(to_replace='None', value="None")
|
|
|
2 |
nltk.data.path.append("/home/user/app/nltk_data")
|
3 |
#nltk.download('stopwords')
|
4 |
#nltk.download('punkt')
|
5 |
+
from epi_pipeline import (
|
6 |
+
streamlit_extraction,
|
7 |
+
NER_Pipeline,
|
8 |
+
GARD_Search,
|
9 |
+
Classify_Pipeline
|
10 |
+
)
|
11 |
import pandas as pd
|
12 |
#pd.set_option('display.max_colwidth', None)
|
13 |
import streamlit as st
|
14 |
st.set_page_config(layout="wide")
|
15 |
+
#import spacy
|
16 |
+
#import tensorflow as tf
|
17 |
+
#import pickle
|
18 |
+
#import re
|
19 |
import plotly.graph_objects as go
|
20 |
|
21 |
#### LOGO ####
|
|
|
62 |
extract_diseases = st.sidebar.checkbox("Extract Rare Diseases", value=False)
|
63 |
|
64 |
#### MODEL LOADING ####
|
|
|
65 |
@st.experimental_singleton(show_spinner=False)
|
66 |
def load_models_experimental():
|
67 |
+
epi_classify = Classify_Pipeline()
|
68 |
+
epi_extract = NER_Pipeline()
|
69 |
+
rd_identify = GARD_Search()
|
70 |
+
return epi_classify, epi_extract, rd_identify
|
71 |
|
72 |
#### DOWNLOAD FUNCTION ####
|
|
|
73 |
@st.cache
|
74 |
def convert_df(df):
|
75 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
76 |
return df.to_csv().encode('utf-8')
|
77 |
|
78 |
#### SANKEY FUNCTION ####
|
|
|
79 |
#@st.cache(allow_output_mutation=True)
|
80 |
@st.experimental_singleton()
|
81 |
def epi_sankey(sankey_data, disease_or_gard_id):
|
|
|
104 |
return fig
|
105 |
|
106 |
#### BEGIN APP ####
|
|
|
107 |
with st.spinner('Loading Epidemiology Models and Dependencies...'):
|
108 |
+
epi_classify, epi_extract, rd_identify = load_models_experimental()
|
109 |
loaded = st.success('All Models and Dependencies Loaded!')
|
110 |
|
111 |
disease_or_gard_id = st.text_input("Input a rare disease term or NIH GARD ID.")
|
|
|
115 |
st.markdown("Examples of rare diseases include [**Fellman syndrome**](https://rarediseases.info.nih.gov/diseases/1/gracile-syndrome), [**Classic Homocystinuria**](https://rarediseases.info.nih.gov/diseases/6667/classic-homocystinuria), [**7383**](https://rarediseases.info.nih.gov/diseases/7383/phenylketonuria), and [**GARD:0009941**](https://rarediseases.info.nih.gov/diseases/9941/fshmd1a). A full list of rare diseases tracked by the NIH Genetic and Rare Diseases Information Center (GARD) can be found [here](https://rarediseases.info.nih.gov/diseases/browse-by-first-letter).")
|
116 |
|
117 |
if disease_or_gard_id:
|
118 |
+
df, sankey_data, name_gardID = streamlit_extraction(disease_or_gard_id, max_results, filtering,
|
119 |
+
epi_ner, GARD_Search, extract_diseases, epi_classify)
|
|
|
|
|
120 |
#IF it returns something, then continue.
|
121 |
if sankey_data:
|
122 |
df.replace(to_replace='None', value="None")
|