Spaces:
Running
Running
make multiselect box scrollable and discard view selected proteins container to only keep download button
Browse files- ProtHGT_app.py +28 -37
ProtHGT_app.py
CHANGED
|
@@ -127,13 +127,24 @@ with st.sidebar:
|
|
| 127 |
)
|
| 128 |
filtered_proteins = [match[0] for match in matches] # Show top 50 matches
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
else: # Upload file option
|
| 139 |
uploaded_file = st.file_uploader(
|
|
@@ -189,36 +200,16 @@ with st.sidebar:
|
|
| 189 |
""")
|
| 190 |
|
| 191 |
if selected_proteins:
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
border-radius: 4px;
|
| 203 |
-
padding: 8px;
|
| 204 |
-
background-color: white;">
|
| 205 |
-
{'<br>'.join(selected_proteins)}
|
| 206 |
-
</div>
|
| 207 |
-
""",
|
| 208 |
-
unsafe_allow_html=True
|
| 209 |
-
)
|
| 210 |
-
|
| 211 |
-
st.markdown("<div style='padding-top: 10px;'></div>", unsafe_allow_html=True)
|
| 212 |
-
|
| 213 |
-
# Add download button
|
| 214 |
-
proteins_text = '\n'.join(selected_proteins)
|
| 215 |
-
st.download_button(
|
| 216 |
-
label="Download List",
|
| 217 |
-
data=proteins_text,
|
| 218 |
-
file_name="selected_proteins.txt",
|
| 219 |
-
mime="text/plain",
|
| 220 |
-
key="download_button"
|
| 221 |
-
)
|
| 222 |
|
| 223 |
# Add GO category selection
|
| 224 |
go_category_options = {
|
|
|
|
| 127 |
)
|
| 128 |
filtered_proteins = [match[0] for match in matches] # Show top 50 matches
|
| 129 |
|
| 130 |
+
with st.container():
|
| 131 |
+
selected_proteins = st.multiselect(
|
| 132 |
+
"2\\. Select proteins from search results",
|
| 133 |
+
options=filtered_proteins,
|
| 134 |
+
placeholder="Start typing a protein ID above (1) to see search results...",
|
| 135 |
+
max_selections=100,
|
| 136 |
+
disabled=disabled,
|
| 137 |
+
key="protein_selector"
|
| 138 |
+
)
|
| 139 |
+
# Apply custom CSS to make container scrollable
|
| 140 |
+
st.markdown("""
|
| 141 |
+
<style>
|
| 142 |
+
div[data-testid="stMultiSelect"] div:nth-child(2) {
|
| 143 |
+
max-height: 250px;
|
| 144 |
+
overflow-y: auto;
|
| 145 |
+
}
|
| 146 |
+
</style>
|
| 147 |
+
""", unsafe_allow_html=True)
|
| 148 |
|
| 149 |
else: # Upload file option
|
| 150 |
uploaded_file = st.file_uploader(
|
|
|
|
| 200 |
""")
|
| 201 |
|
| 202 |
if selected_proteins:
|
| 203 |
+
st.write(f"Total proteins selected: {len(selected_proteins)}")
|
| 204 |
+
# Add download button
|
| 205 |
+
proteins_text = '\n'.join(selected_proteins)
|
| 206 |
+
st.download_button(
|
| 207 |
+
label="Download Selected Proteins List",
|
| 208 |
+
data=proteins_text,
|
| 209 |
+
file_name="selected_proteins.txt",
|
| 210 |
+
mime="text/plain",
|
| 211 |
+
key="download_selected_proteins"
|
| 212 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# Add GO category selection
|
| 215 |
go_category_options = {
|