Spaces:
Sleeping
Sleeping
File size: 4,488 Bytes
dbcbce0 904196a dbcbce0 39b95cf ee93764 dbcbce0 39b95cf ee93764 39b95cf ee93764 dbcbce0 39b95cf bdb0a66 ee93764 39b95cf ee93764 39b95cf dbcbce0 e3c30c7 ee93764 39b95cf ee93764 39b95cf dbcbce0 ee93764 dbcbce0 ee93764 dbcbce0 904196a 81bd00b 904196a dbcbce0 904196a dbcbce0 904196a dbcbce0 81bd00b dbcbce0 39b95cf b35ba5a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | import streamlit as st
import pandas as pd
import prediction as pred_module # Import the prediction module
import os
def extract_windows(sequence, window_size=55):
"""
Extract windows of a given size centered around each 'K' residue in the sequence.
Parameters:
sequence (str): The amino acid sequence.
window_size (int): The size of the window to extract (must be an odd number).
Returns:
list: A list of subsequences of the specified window size centered on 'K'.
"""
half_window = window_size // 2
windows = []
for i in range(len(sequence)):
if sequence[i] == 'K':
start = i - half_window
end = i + half_window + 1
if start >= 0 and end <= len(sequence):
window_sequence = sequence[start:end]
windows.append((i, window_sequence))
return windows
def main():
st.title("Ubiquitinated Protein Sequence Predictor")
st.write("""
This app predicts whether a given protein sequence contains ubiquitination sites.
Enter a protein sequence and the app will analyze windows size 'n-1/2' residues centered around each 'K' residue.
If any window is predicted positive, the sequence is considered to contain ubiquitination sites.
""")
sequence_input = st.text_area("Enter protein sequence:")
if st.button("Predict"):
if len(sequence_input) < 55:
st.error("Sequence length must be at least 55 residues.")
else:
windows = extract_windows(sequence_input)
final_prediction = 0 # Initialize final prediction as negative
for i, window_sequence in windows:
pred_result = pred_module.predict_sequence_label(window_sequence)
if pred_result == 1:
final_prediction = 1 # If any window is positive, set final prediction to positive
break
if final_prediction == 1:
st.success("The sequence contains ubiquitination sites.")
else:
st.success("The sequence does not contain ubiquitination sites.")
# Collect user feedback
st.write("Provide your feedback on the prediction:")
feedback = st.radio(
"Was the prediction correct?",
("Yes", "No"),
key="feedback"
)
if st.button("Submit Feedback"):
feedback_data = {
"sequence": [sequence_input],
"predicted_label": [final_prediction],
"feedback": [feedback]
}
feedback_df = pd.DataFrame(feedback_data)
# Check if feedback.csv exists
if not os.path.isfile("feedback.csv"):
feedback_df.to_csv("feedback.csv", index=False)
else:
try:
existing_feedback = pd.read_csv("feedback.csv")
feedback_df = pd.concat([existing_feedback, feedback_df], ignore_index=True)
feedback_df.to_csv("feedback.csv", index=False)
except pd.errors.EmptyDataError:
feedback_df.to_csv("feedback.csv", index=False)
st.success("Feedback submitted successfully!")
# Display feedback table
st.write("User Feedback Table (Last 10 Entries):")
try:
feedback_df = pd.read_csv("feedback.csv")
last_10_feedback = feedback_df.tail(10)
st.dataframe(last_10_feedback)
except FileNotFoundError:
st.write("No feedback available yet.")
except pd.errors.EmptyDataError:
st.write("Feedback file is empty. No feedback available yet.")
if __name__ == "__main__":
main()
# Add a footer
st.markdown(
"""
<style>
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #f1f1f1;
color: black;
text-align: center;
padding: 10px;
}
.footer p {
font-size: 1.2em;
font-weight: bold;
}
</style>
<div class="footer">
<p>© Shubham Kale and Prof.N.Arul.Murugan, IIIT Delhi</p>
</div>
""", unsafe_allow_html=True
) |