Update app.py
Browse files
app.py
CHANGED
|
@@ -67,6 +67,10 @@ def perform_blast_analysis(sequence):
|
|
| 67 |
except Exception as e:
|
| 68 |
st.error("An error occurred during protein analysis. Please try again later.")
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def update(sequence, word1, word2, word3, sequence_length):
|
| 71 |
headers = {
|
| 72 |
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -113,13 +117,18 @@ def update(sequence, word1, word2, word3, sequence_length):
|
|
| 113 |
Enjoy exploring the world of protein sequences! Share your high-confidence protein images with us on X [*@WandsAI*](https://x.com/wandsai)!
|
| 114 |
""")
|
| 115 |
|
| 116 |
-
|
| 117 |
-
perform_blast_analysis(sequence)
|
| 118 |
|
| 119 |
except requests.exceptions.RequestException as e:
|
| 120 |
st.error(f"An error occurred while calling the API: {str(e)}")
|
| 121 |
st.write("Please try again later or contact support if the issue persists.")
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
st.title("Word-Seeded Protein Sequence Generator and Structure Predictor")
|
| 124 |
|
| 125 |
st.sidebar.subheader("Generate Sequence from Words")
|
|
@@ -131,10 +140,16 @@ sequence_length = st.sidebar.number_input("Sequence Length", min_value=50, max_v
|
|
| 131 |
if st.sidebar.button('Generate and Predict'):
|
| 132 |
if word1 and word2 and word3:
|
| 133 |
sequence = generate_sequence_from_words([word1, word2, word3], sequence_length)
|
|
|
|
| 134 |
st.sidebar.text_area("Generated Sequence", sequence, height=100)
|
| 135 |
st.sidebar.info("Note: The same words and sequence length will always produce the same sequence.")
|
| 136 |
|
| 137 |
with st.spinner("Predicting protein structure... This may take a few minutes."):
|
| 138 |
update(sequence, word1, word2, word3, sequence_length)
|
| 139 |
else:
|
| 140 |
-
st.sidebar.warning("Please enter all three words to generate a sequence.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
except Exception as e:
|
| 68 |
st.error("An error occurred during protein analysis. Please try again later.")
|
| 69 |
|
| 70 |
+
import streamlit as st
|
| 71 |
+
|
| 72 |
+
# ... (keep all previous imports and functions)
|
| 73 |
+
|
| 74 |
def update(sequence, word1, word2, word3, sequence_length):
|
| 75 |
headers = {
|
| 76 |
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
| 117 |
Enjoy exploring the world of protein sequences! Share your high-confidence protein images with us on X [*@WandsAI*](https://x.com/wandsai)!
|
| 118 |
""")
|
| 119 |
|
| 120 |
+
st.session_state.show_analyze_button = True
|
|
|
|
| 121 |
|
| 122 |
except requests.exceptions.RequestException as e:
|
| 123 |
st.error(f"An error occurred while calling the API: {str(e)}")
|
| 124 |
st.write("Please try again later or contact support if the issue persists.")
|
| 125 |
|
| 126 |
+
# Initialize session state variables
|
| 127 |
+
if 'sequence' not in st.session_state:
|
| 128 |
+
st.session_state.sequence = None
|
| 129 |
+
if 'show_analyze_button' not in st.session_state:
|
| 130 |
+
st.session_state.show_analyze_button = False
|
| 131 |
+
|
| 132 |
st.title("Word-Seeded Protein Sequence Generator and Structure Predictor")
|
| 133 |
|
| 134 |
st.sidebar.subheader("Generate Sequence from Words")
|
|
|
|
| 140 |
if st.sidebar.button('Generate and Predict'):
|
| 141 |
if word1 and word2 and word3:
|
| 142 |
sequence = generate_sequence_from_words([word1, word2, word3], sequence_length)
|
| 143 |
+
st.session_state.sequence = sequence
|
| 144 |
st.sidebar.text_area("Generated Sequence", sequence, height=100)
|
| 145 |
st.sidebar.info("Note: The same words and sequence length will always produce the same sequence.")
|
| 146 |
|
| 147 |
with st.spinner("Predicting protein structure... This may take a few minutes."):
|
| 148 |
update(sequence, word1, word2, word3, sequence_length)
|
| 149 |
else:
|
| 150 |
+
st.sidebar.warning("Please enter all three words to generate a sequence.")
|
| 151 |
+
|
| 152 |
+
# Show the Analyze Protein button if a sequence has been generated
|
| 153 |
+
if st.session_state.show_analyze_button:
|
| 154 |
+
if st.button('Analyze Protein'):
|
| 155 |
+
perform_blast_analysis(st.session_state.sequence)
|