Spaces:
Sleeping
Sleeping
import streamlit as st | |
import requests | |
# Install required packages | |
import os | |
os.system("pip install requests streamlit") | |
def get_genome_from_uniprot(uniprot_id): | |
url = f"https://www.uniprot.org/uniprot/{uniprot_id}.fasta" | |
response = requests.get(url) | |
if response.status_code == 200: | |
return response.text | |
else: | |
st.error("Failed to retrieve genome. Please check the UniProt ID.") | |
return None | |
def main(): | |
st.title("Download Genome from UniProtKB") | |
st.write("Enter the unique UniProt ID to download the corresponding genome.") | |
uniprot_id = st.text_input("UniProt ID") | |
if st.button("Get Genome"): | |
if uniprot_id: | |
genome_data = get_genome_from_uniprot(uniprot_id) | |
if genome_data: | |
st.text_area("Genome Data", genome_data, height=300) | |
st.download_button("Download Genome", genome_data, file_name=f"{uniprot_id}.fasta", mime="text/plain") | |
else: | |
st.warning("Please enter a UniProt ID.") | |
if __name__ == "__main__": | |
main() | |