import streamlit as st import streamlit.components.v1 as components import requests from io import StringIO from Bio import SeqIO import os import time import pandas as pd from run_domain2go_app import * def convert_df(df): return df.to_csv(index=False).encode('utf-8') # prevent user from clicking submit button if email or sequence is empty submitted = False with st.sidebar: st.title("Domain2GO: Mutual Annotation-Based Prediction of Protein Domain Functions") st.write("[![publication](https://img.shields.io/badge/DOI-10.1002/pro.4988-b31b1b.svg)](https://doi.org/10.1002/pro.4988) [![github-repository](https://img.shields.io/badge/GitHub-black?logo=github)](https://github.com/HUBioDataLab/Domain2GO)") if 'example_seq_button' not in st.session_state: st.session_state.example_seq_button = False def click_button(): st.session_state.example_seq_button = not st.session_state.example_seq_button input_type = st.radio('Select input type', ['Enter a sequence', 'Upload a FASTA file']) if input_type == 'Enter a sequence': st.button('Use example sequence', on_click=click_button) if st.session_state.example_seq_button: sequence_text_input = st.text_area('Enter a protein sequence in FASTA format*', value='>sp|O18783|PLMN_NOTEU\n' 'MEYGKVIFLFLLFLKSGQGESLENYIKTEGASLSNSQKKQFVASSTEECEALCEKETEFVCRSFEHYNKEQKCVIMSENSKTSSVERKRDVVLFEKRIYLSDCKSGNGRNYRGTLSKTKSGITCQKWSDLSPHVPNYAPSKYPDAGLEKNYCRNPDDDVKGPWCYTTNPDIRYEYCDVPECEDECMHCSGENYRGTISKTESGIECQPWDSQEPHSHEYIPSKFPSKDLKENYCRNPDGEPRPWCFTSNPEKRWEFCNIPRCSSPPPPPGPMLQCLKGRGENYRGKIAVTKSGHTCQRWNKQTPHKHNRTPENFPCRGLDENYCRNPDGELEPWCYTTNPDVRQEYCAIPSCGTSSPHTDRVEQSPVIQECYEGKGENYRGTTSTTISGKKCQAWSSMTPHQHKKTPDNFPNADLIRNYCRNPDGDKSPWCYTMDPTVRWEFCNLEKCSGTGSTVLNAQTTRVPSVDTTSHPESDCMYGSGKDYRGKRSTTVTGTLCQAWTAQEPHRHTIFTPDTYPRAGLEENYCRNPDGDPNGPWCYTTNPKKLFDYCDIPQCVSPSSFDCGKPRVEPQKCPGRIVGGCYAQPHSWPWQISLRTRFGEHFCGGTLIAPQWVLTAAHCLERSQWPGAYKVILGLHREVNPESYSQEIGVSRLFKGPLAADIALLKLNRPAAINDKVIPACLPSQDFMVPDRTLCHVTGWGDTQGTSPRGLLKQASLPVIDNRVCNRHEYLNGRVKSTELCAGHLVGRGDSCQGDSGGPLICFEDDKYVLQGVTSWGLGCARPNKPGVYVRVSRYISWIEDVMKNN') else: sequence_text_input = st.text_area('Enter a protein sequence in FASTA format*') fasta_sequences = list(SeqIO.parse(StringIO(sequence_text_input), 'fasta')) if len(fasta_sequences) > 1: st.error('Please enter only one sequence.') fasta_sequences = None elif sequence_text_input and len(fasta_sequences) == 0: st.error('Please enter a sequence.') fasta_sequences = None elif len(fasta_sequences) == 1: st.session_state['sequence'] = str(fasta_sequences[0].seq) st.session_state['name'] = fasta_sequences[0].id else: protein_input = st.file_uploader('Choose a file', type=['.fasta', '.fas', '.fa', '.fna', '.ffn', '.faa', '.mpfa', '.frn', '.txt']) css=''' ''' st.markdown(css, unsafe_allow_html=True) if protein_input: bytes_data = protein_input.read() try: protein_input_stringio = StringIO(bytes_data.decode("utf-8")) except UnicodeDecodeError: protein_input_stringio = StringIO(bytes_data.decode("utf-16")) fasta_sequences = list(SeqIO.parse(protein_input_stringio, 'fasta')) if len(fasta_sequences) == 0: st.error('Please upload a file containing a sequence.') fasta_sequences = None elif len(fasta_sequences) > 1: st.error('Please upload a file containing only one sequence.') fasta_sequences = None elif len(fasta_sequences) == 1: st.session_state['name'], st.session_state['sequence'] = fasta_sequences[0].id, str(fasta_sequences[0].seq) st.session_state['email'] = st.text_input('Enter your email for InterProScan query**') with st.sidebar: if st.button('Predict functions'): if 'email' in st.session_state and 'sequence' in st.session_state and '@' in st.session_state.email and fasta_sequences: submitted = True st.session_state.disabled = True else: with st.sidebar: st.warning('Please enter your email and protein sequence first. If you have already entered your email and protein sequence, please check that your email is valid, your sequence is in FASTA format, and that you have entered only one sequence.') with st.sidebar: c = st.container() c.markdown("---") c.markdown( """
*Disclaimer: This program is designed to generate predictions for a single protein due to the extended runtime of InterProScan. If you need predictions for multiple UniProtKB/Swiss-Prot proteins, we recommend utilizing our comprehensive protein function prediction dataset available in our Github repository.
**InterProScan requests your email to notify you when your job is done. Your email will not be used for any other purpose.
Submit your protein sequence to start.