Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,8 @@ import urllib.parse
|
|
15 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
16 |
|
17 |
st.set_page_config(layout='wide')
|
18 |
-
st.sidebar.title('🔮 GenPro2 Protein Generator, Structure Predictor, and Analysis Tool')
|
19 |
-
st.sidebar.write('
|
20 |
|
21 |
def generate_sequence_from_words(words, length):
|
22 |
seed = ' '.join(words).encode('utf-8')
|
@@ -36,54 +36,43 @@ def render_mol(pdb):
|
|
36 |
|
37 |
def perform_blast_analysis(sequence):
|
38 |
st.subheader('Protein Analysis')
|
39 |
-
with st.spinner("Analyzing generated protein... This may take several minutes. Stay tuned!"):
|
40 |
progress_bar = st.progress(0)
|
41 |
-
|
42 |
-
# Slow down the progress bar
|
43 |
for i in range(100):
|
44 |
progress_bar.progress(i + 1)
|
45 |
-
time.sleep(0.
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
-
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
hsp = alignment.hsps[0] # Get the first (best) HSP
|
59 |
-
|
60 |
-
# Extract protein name and organism
|
61 |
-
title_parts = alignment.title.split('|')
|
62 |
-
protein_name = title_parts[-1].strip()
|
63 |
-
organism = title_parts[-2].split('OS=')[-1].split('OX=')[0].strip()
|
64 |
-
|
65 |
-
# Calculate identity percentage
|
66 |
-
identity_percentage = (hsp.identities / alignment.length) * 100
|
67 |
-
|
68 |
-
st.write(f"**Top Match:** {protein_name}")
|
69 |
-
st.write(f"**Organism:** {organism}")
|
70 |
-
st.write(f"**Sequence Identity:** {identity_percentage:.2f}%")
|
71 |
-
|
72 |
-
# Fetch protein function (if available)
|
73 |
-
if hasattr(alignment, 'description') and alignment.description:
|
74 |
-
st.write(f"**Potential Function:** {alignment.description}")
|
75 |
-
else:
|
76 |
-
st.write("No significant matches found. This might be a unique protein sequence!")
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
st.
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
|
88 |
def update(sequence, word1, word2, word3, sequence_length):
|
89 |
headers = {
|
@@ -132,7 +121,7 @@ if 'show_analyze_button' not in st.session_state:
|
|
132 |
if 'structure_info' not in st.session_state:
|
133 |
st.session_state.structure_info = None
|
134 |
|
135 |
-
st.title("
|
136 |
|
137 |
st.sidebar.subheader("Generate Sequence from Words")
|
138 |
word1 = st.sidebar.text_input("Word 1")
|
@@ -140,6 +129,13 @@ word2 = st.sidebar.text_input("Word 2")
|
|
140 |
word3 = st.sidebar.text_input("Word 3")
|
141 |
sequence_length = st.sidebar.number_input("Sequence Length", min_value=50, max_value=400, value=100, step=10)
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
# Information for users
|
144 |
st.info("""
|
145 |
Protein Length Guide:
|
@@ -149,6 +145,16 @@ Protein Length Guide:
|
|
149 |
|
150 |
""")
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
if st.sidebar.button('Generate and Predict'):
|
153 |
if word1 and word2 and word3:
|
154 |
sequence = generate_sequence_from_words([word1, word2, word3], sequence_length)
|
|
|
15 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
16 |
|
17 |
st.set_page_config(layout='wide')
|
18 |
+
st.sidebar.title('🔮 GenPro2 Protein AI Generator, Structure Predictor, and Analysis Tool')
|
19 |
+
st.sidebar.write('beta v2.12 | ')
|
20 |
|
21 |
def generate_sequence_from_words(words, length):
|
22 |
seed = ' '.join(words).encode('utf-8')
|
|
|
36 |
|
37 |
def perform_blast_analysis(sequence):
|
38 |
st.subheader('Protein Analysis')
|
39 |
+
with st.spinner("Analyzing generated protein... This may take a several minutes. Stay tuned!"):
|
40 |
progress_bar = st.progress(0)
|
|
|
|
|
41 |
for i in range(100):
|
42 |
progress_bar.progress(i + 1)
|
43 |
+
time.sleep(0.1) # Simulate analysis time
|
44 |
|
45 |
+
try:
|
46 |
+
record = SeqRecord(Seq(sequence), id='random_protein')
|
47 |
+
result_handle = NCBIWWW.qblast("blastp", "swissprot", record.seq)
|
48 |
+
|
49 |
+
blast_record = NCBIXML.read(result_handle)
|
50 |
+
|
51 |
+
if blast_record.alignments:
|
52 |
+
alignment = blast_record.alignments[0] # Get the top hit
|
53 |
+
hsp = alignment.hsps[0] # Get the first (best) HSP
|
54 |
|
55 |
+
# Extract protein name and organism
|
56 |
+
title_parts = alignment.title.split('|')
|
57 |
+
protein_name = title_parts[-1].strip()
|
58 |
+
organism = title_parts[-2].split('OS=')[-1].split('OX=')[0].strip()
|
59 |
|
60 |
+
# Calculate identity percentage
|
61 |
+
identity_percentage = (hsp.identities / alignment.length) * 100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
st.write(f"**Top Match:** {protein_name}")
|
64 |
+
st.write(f"**Organism Code:** {organism}")
|
65 |
+
st.write(f"**Sequence Identity Match:** {identity_percentage:.2f}%")
|
66 |
+
|
67 |
+
|
68 |
+
# Fetch protein function (if available)
|
69 |
+
if hasattr(alignment, 'description') and alignment.description:
|
70 |
+
st.write(f"**Potential Function:** {alignment.description}")
|
71 |
+
|
72 |
+
if hasattr(alignment, 'description') and alignment.description:
|
73 |
+
st.write(f"**Potential Function:** {alignment.description}")
|
74 |
+
else:
|
75 |
+
st.write("No significant matches found in the database. This might be a unique protein sequence!")
|
76 |
|
77 |
def update(sequence, word1, word2, word3, sequence_length):
|
78 |
headers = {
|
|
|
121 |
if 'structure_info' not in st.session_state:
|
122 |
st.session_state.structure_info = None
|
123 |
|
124 |
+
st.title("🔮 GenPro2 Protein Discovery & Anlaysis")
|
125 |
|
126 |
st.sidebar.subheader("Generate Sequence from Words")
|
127 |
word1 = st.sidebar.text_input("Word 1")
|
|
|
129 |
word3 = st.sidebar.text_input("Word 3")
|
130 |
sequence_length = st.sidebar.number_input("Sequence Length", min_value=50, max_value=400, value=100, step=10)
|
131 |
|
132 |
+
st.markdown("""
|
133 |
+
## About:
|
134 |
+
GenPro2 is an end-to-end protein sequence generator, structure predictor, and analysis that uses [*ESMFold*](https://esmatlas.com/about) and the ESM-2 language model.
|
135 |
+
|
136 |
+
|
137 |
+
## How to get started:
|
138 |
+
""")
|
139 |
# Information for users
|
140 |
st.info("""
|
141 |
Protein Length Guide:
|
|
|
145 |
|
146 |
""")
|
147 |
|
148 |
+
st.markdown("""
|
149 |
+
1. Start by entering any three seed words of your choice and select a sequence length in the sidebar.
|
150 |
+
2. Click 'Generate and Predict' to generate a unique protein sequence based on your inputs.
|
151 |
+
3. GenPro2 then predicts the 3D structure of your protein and provides a confidence score.
|
152 |
+
|
153 |
+
GenPro2 offers a unique, hands-on way to generate, visualize, and analyze novel protein sequences. By generating and analyzing novel protein structures, you're stepping into the world of computational drug discovery. Your unique protein could be the key to unlocking new therapeutic possibilities or understanding disease mechanisms. Whether you're a student, PhD researcher, or enthusiast, GenPro2 offers a user-friendly platform to explore the vast potential of protein structures. Who knows? Your next generated sequence might just lead to a breakthrough.
|
154 |
+
|
155 |
+
|
156 |
+
""")
|
157 |
+
|
158 |
if st.sidebar.button('Generate and Predict'):
|
159 |
if word1 and word2 and word3:
|
160 |
sequence = generate_sequence_from_words([word1, word2, word3], sequence_length)
|