Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# Install required packages
|
| 5 |
+
import os
|
| 6 |
+
os.system("pip install requests streamlit")
|
| 7 |
+
|
| 8 |
+
def get_genome_from_uniprot(uniprot_id):
|
| 9 |
+
url = f"https://www.uniprot.org/uniprot/{uniprot_id}.fasta"
|
| 10 |
+
response = requests.get(url)
|
| 11 |
+
|
| 12 |
+
if response.status_code == 200:
|
| 13 |
+
return response.text
|
| 14 |
+
else:
|
| 15 |
+
st.error("Failed to retrieve genome. Please check the UniProt ID.")
|
| 16 |
+
return None
|
| 17 |
+
|
| 18 |
+
def main():
|
| 19 |
+
st.title("Download Genome from UniProtKB")
|
| 20 |
+
st.write("Enter the unique UniProt ID to download the corresponding genome.")
|
| 21 |
+
|
| 22 |
+
uniprot_id = st.text_input("UniProt ID")
|
| 23 |
+
|
| 24 |
+
if st.button("Get Genome"):
|
| 25 |
+
if uniprot_id:
|
| 26 |
+
genome_data = get_genome_from_uniprot(uniprot_id)
|
| 27 |
+
if genome_data:
|
| 28 |
+
st.text_area("Genome Data", genome_data, height=300)
|
| 29 |
+
st.download_button("Download Genome", genome_data, file_name=f"{uniprot_id}.fasta", mime="text/plain")
|
| 30 |
+
else:
|
| 31 |
+
st.warning("Please enter a UniProt ID.")
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
main()
|