Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
| 16 |
|
| 17 |
st.set_page_config(layout='wide')
|
| 18 |
st.sidebar.title('🔮 GenPro2')
|
| 19 |
-
st.sidebar.write('GenPro2 is an end-to-end protein sequence generator, structure predictor, and analysis that uses ESMFold and the ESM-2 language model | beta v2.12')
|
| 20 |
|
| 21 |
def generate_sequence_from_words(words, length):
|
| 22 |
seed = ' '.join(words).encode('utf-8')
|
|
@@ -25,14 +25,33 @@ def generate_sequence_from_words(words, length):
|
|
| 25 |
return ''.join(random.choice(amino_acids) for _ in range(length))
|
| 26 |
|
| 27 |
def render_mol(pdb):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
def perform_blast_analysis(sequence):
|
| 38 |
st.subheader('Protein Analysis')
|
|
@@ -40,7 +59,7 @@ def perform_blast_analysis(sequence):
|
|
| 40 |
progress_bar = st.progress(0)
|
| 41 |
for i in range(100):
|
| 42 |
progress_bar.progress(i + 1)
|
| 43 |
-
time.sleep(0.
|
| 44 |
|
| 45 |
try:
|
| 46 |
record = SeqRecord(Seq(sequence), id='random_protein')
|
|
@@ -61,7 +80,7 @@ def perform_blast_analysis(sequence):
|
|
| 61 |
identity_percentage = (hsp.identities / hsp.align_length) * 100
|
| 62 |
|
| 63 |
st.write(f"**Top Match:** {protein_name}")
|
| 64 |
-
st.write(f"**
|
| 65 |
st.write(f"**Sequence Identity Match:** {identity_percentage:.2f}%")
|
| 66 |
|
| 67 |
# Fetch protein function (if available)
|
|
@@ -209,7 +228,7 @@ if st.session_state.structure_info:
|
|
| 209 |
|
| 210 |
1. Click the 'analyze protein' button to search the [BLAST](https://blast.ncbi.nlm.nih.gov/Blast.cgi?PROGRAM=blastp&PAGE_TYPE=BlastSearch&LINK_LOC=blasthome) protein database and see if your protein matches any known sequences. The sequence identity will show how close your sequence matches. *Note this can take several minutes
|
| 211 |
2. Download your protein data and visit the [Protein Data Bank (PDB)](https://www.rcsb.org/) to match your protein structure against known protein structures.
|
| 212 |
-
3. If you think you've discovered a
|
| 213 |
|
| 214 |
|
| 215 |
**Remember, this folding is based on randomly generated sequences. Interpret the results with caution.
|
|
|
|
| 16 |
|
| 17 |
st.set_page_config(layout='wide')
|
| 18 |
st.sidebar.title('🔮 GenPro2')
|
| 19 |
+
st.sidebar.write('GenPro2 is an end-to-end protein sequence generator, structure predictor, and analysis that uses [ESMFold](https://esmatlas.com/explore?at=1%2C1%2C21.999999344348925) and the ESM-2 language model | beta v2.12')
|
| 20 |
|
| 21 |
def generate_sequence_from_words(words, length):
|
| 22 |
seed = ' '.join(words).encode('utf-8')
|
|
|
|
| 25 |
return ''.join(random.choice(amino_acids) for _ in range(length))
|
| 26 |
|
| 27 |
def render_mol(pdb):
|
| 28 |
+
viewer = py3Dmol.view(width='100%', height='400px')
|
| 29 |
+
viewer.addModel(pdb, 'pdb')
|
| 30 |
+
viewer.setStyle({'cartoon': {'color': 'spectrum'}})
|
| 31 |
+
viewer.setBackgroundColor('white')
|
| 32 |
+
viewer.zoomTo()
|
| 33 |
+
viewer.zoom(0.8) # Slightly zoomed out view
|
| 34 |
+
viewer.spin(True)
|
| 35 |
+
viewer.render()
|
| 36 |
+
|
| 37 |
+
# Responsive design for mobile
|
| 38 |
+
st.markdown("""
|
| 39 |
+
<style>
|
| 40 |
+
.stmol-container {
|
| 41 |
+
width: 100% !important;
|
| 42 |
+
height: 400px !important;
|
| 43 |
+
max-width: 800px;
|
| 44 |
+
margin: 0 auto;
|
| 45 |
+
}
|
| 46 |
+
@media (max-width: 600px) {
|
| 47 |
+
.stmol-container {
|
| 48 |
+
height: 300px !important;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
</style>
|
| 52 |
+
""", unsafe_allow_html=True)
|
| 53 |
+
|
| 54 |
+
showmol(viewer, height=400, width=None)
|
| 55 |
|
| 56 |
def perform_blast_analysis(sequence):
|
| 57 |
st.subheader('Protein Analysis')
|
|
|
|
| 59 |
progress_bar = st.progress(0)
|
| 60 |
for i in range(100):
|
| 61 |
progress_bar.progress(i + 1)
|
| 62 |
+
time.sleep(0.9) # Analysis time
|
| 63 |
|
| 64 |
try:
|
| 65 |
record = SeqRecord(Seq(sequence), id='random_protein')
|
|
|
|
| 80 |
identity_percentage = (hsp.identities / hsp.align_length) * 100
|
| 81 |
|
| 82 |
st.write(f"**Top Match:** {protein_name}")
|
| 83 |
+
st.write(f"**UniProt ID:** {organism}")
|
| 84 |
st.write(f"**Sequence Identity Match:** {identity_percentage:.2f}%")
|
| 85 |
|
| 86 |
# Fetch protein function (if available)
|
|
|
|
| 228 |
|
| 229 |
1. Click the 'analyze protein' button to search the [BLAST](https://blast.ncbi.nlm.nih.gov/Blast.cgi?PROGRAM=blastp&PAGE_TYPE=BlastSearch&LINK_LOC=blasthome) protein database and see if your protein matches any known sequences. The sequence identity will show how close your sequence matches. *Note this can take several minutes
|
| 230 |
2. Download your protein data and visit the [Protein Data Bank (PDB)](https://www.rcsb.org/) to match your protein structure against known protein structures.
|
| 231 |
+
3. If you think you've discovered a unique and useful protein share it with the world on social media!
|
| 232 |
|
| 233 |
|
| 234 |
**Remember, this folding is based on randomly generated sequences. Interpret the results with caution.
|