jfataphd commited on
Commit
62faff0
1 Parent(s): c6e3011

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -16
app.py CHANGED
@@ -6,26 +6,35 @@ import pandas as pd
6
  import matplotlib.pyplot as plt
7
  import squarify
8
  import numpy as np
 
 
9
 
10
  st.set_page_config(
11
  page_title="FATA4 Science",
12
  page_icon=":microscope:",
13
  layout="wide",
14
- initial_sidebar_state="expanded",
15
  menu_items={
16
  'About': "FATA4 Science is a Natural Language Processing (NLP) that ...."
17
  }
18
  )
19
 
20
  # Define the HTML and CSS styles
 
 
 
 
 
 
 
21
  st.markdown("""
22
  <style>
23
  body {
24
- background-color: #EBF5FB;
25
  # color: #ffffff;
26
  }
27
  .stApp {
28
- background-color: #EBF5FB;
29
  # color: #ffffff;
30
  }
31
  </style>
@@ -46,14 +55,19 @@ st.markdown("---")
46
  st.subheader("Uncovering knowledge through Natural Language Processing (NLP)")
47
 
48
  st.header(f"{database_name} Pubmed corpus.")
49
- text_input_value = st.text_input(f"Enter one term to search within the {database_name} corpus", max_chars=50)
50
  query = text_input_value
51
  query = query.lower()
 
 
 
 
52
  # query = input ("Enter your keyword(s):")
53
  if query:
54
  bar = st.progress(0)
55
  time.sleep(.2)
56
  st.caption(f":LightSkyBlue[searching {num_abstracts} {database_name} PubMed abstracts] covering 1990-2022")
 
57
  for i in range(10):
58
  bar.progress((i + 1) * 10)
59
  time.sleep(.1)
@@ -98,7 +112,7 @@ if query:
98
  # # plot the treemap using matplotlib
99
  plt.axis('off')
100
  fig = plt.gcf()
101
- fig.patch.set_facecolor('#EBF5FB')
102
  # # display the treemap in Streamlit
103
  st.pyplot(fig)
104
  plt.clf()
@@ -138,7 +152,7 @@ if query:
138
 
139
  plt.axis('off')
140
  fig2 = plt.gcf()
141
- fig2.patch.set_facecolor('#EBF5FB')
142
  # plt.show()
143
  #
144
  # # display the treemap in Streamlit
@@ -148,18 +162,18 @@ if query:
148
  st.download_button(label="download top 100 genes (csv)", data=csv, file_name=f'{database_name}_genes.csv',
149
  mime='text/csv')
150
 
151
- DEFAULT_WIDTH = 80
152
- VIDEO_DATA = f"https://www.youtube.com/@NCIgov/search?query=cancer"
153
-
154
- width = st.sidebar.slider(
155
- label="Width", min_value=0, max_value=100, value=DEFAULT_WIDTH, format="%d%%"
156
- )
157
 
158
- width = max(width, 0.01)
159
- side = max((100 - width) / 2, 0.01)
 
160
 
161
- _, container, _ = st.columns([side, width, side])
162
- container.video(data=VIDEO_DATA)
163
 
164
 
165
 
 
6
  import matplotlib.pyplot as plt
7
  import squarify
8
  import numpy as np
9
+ import re
10
+ import urllib.request
11
 
12
  st.set_page_config(
13
  page_title="FATA4 Science",
14
  page_icon=":microscope:",
15
  layout="wide",
16
+ initial_sidebar_state="auto",
17
  menu_items={
18
  'About': "FATA4 Science is a Natural Language Processing (NLP) that ...."
19
  }
20
  )
21
 
22
  # Define the HTML and CSS styles
23
+ st.markdown("""
24
+ <style>
25
+ [data-testid=stSidebar] {
26
+ background-color: #99CCFF;
27
+ }
28
+ </style>
29
+ """, unsafe_allow_html=True)
30
  st.markdown("""
31
  <style>
32
  body {
33
+ background-color: #CCFFFF;
34
  # color: #ffffff;
35
  }
36
  .stApp {
37
+ background-color: #CCFFFF;
38
  # color: #ffffff;
39
  }
40
  </style>
 
55
  st.subheader("Uncovering knowledge through Natural Language Processing (NLP)")
56
 
57
  st.header(f"{database_name} Pubmed corpus.")
58
+ text_input_value = st.text_input(f"Enter one term to search within the {database_name} corpus")
59
  query = text_input_value
60
  query = query.lower()
61
+ query = re.sub("[,.?!&*;:]", "", query)
62
+ matches = [" "]
63
+ if any([x in query for x in matches]):
64
+ st.write("Please only enter one term or a term without spaces")
65
  # query = input ("Enter your keyword(s):")
66
  if query:
67
  bar = st.progress(0)
68
  time.sleep(.2)
69
  st.caption(f":LightSkyBlue[searching {num_abstracts} {database_name} PubMed abstracts] covering 1990-2022")
70
+
71
  for i in range(10):
72
  bar.progress((i + 1) * 10)
73
  time.sleep(.1)
 
112
  # # plot the treemap using matplotlib
113
  plt.axis('off')
114
  fig = plt.gcf()
115
+ fig.patch.set_facecolor('#CCFFFF')
116
  # # display the treemap in Streamlit
117
  st.pyplot(fig)
118
  plt.clf()
 
152
 
153
  plt.axis('off')
154
  fig2 = plt.gcf()
155
+ fig2.patch.set_facecolor('#CCFFFF')
156
  # plt.show()
157
  #
158
  # # display the treemap in Streamlit
 
162
  st.download_button(label="download top 100 genes (csv)", data=csv, file_name=f'{database_name}_genes.csv',
163
  mime='text/csv')
164
 
165
+ if query:
166
+ search_keyword = {query}
167
+ html = urllib.request.urlopen(f"https://www.youtube.com/results?search_query={database_name}")
168
+ video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
169
+ # st.video("https://www.youtube.com/watch?v=" + video_ids[0])
 
170
 
171
+ VIDEO_DATA = "https://www.youtube.com/watch?v=" + video_ids[0]
172
+ width = 80
173
+ side = 10
174
 
175
+ _, container, _ = st.columns([side, width, side])
176
+ container.video(data=VIDEO_DATA)
177
 
178
 
179