Spaces:
Running
Running
Erva Ulusoy
commited on
Commit
·
b83c412
1
Parent(s):
c18585d
Update app.py
Browse files
app.py
CHANGED
@@ -41,12 +41,12 @@ with st.sidebar:
|
|
41 |
input_type = st.radio('Select input type', ['Enter sequence', 'Upload FASTA file'])
|
42 |
if input_type == 'Enter sequence':
|
43 |
if st.session_state.example_seq_button:
|
44 |
-
sequence = st.text_area('Enter protein sequence in FASTA format.',
|
45 |
value='>sp|O18783|PLMN_NOTEU\n'
|
46 |
'MEYGKVIFLFLLFLKSGQGESLENYIKTEGASLSNSQKKQFVASSTEECEALCEKETEFVCRSFEHYNKEQKCVIMSENSKTSSVERKRDVVLFEKRIYLSDCKSGNGRNYRGTLSKTKSGITCQKWSDLSPHVPNYAPSKYPDAGLEKNYCRNPDDDVKGPWCYTTNPDIRYEYCDVPECEDECMHCSGENYRGTISKTESGIECQPWDSQEPHSHEYIPSKFPSKDLKENYCRNPDGEPRPWCFTSNPEKRWEFCNIPRCSSPPPPPGPMLQCLKGRGENYRGKIAVTKSGHTCQRWNKQTPHKHNRTPENFPCRGLDENYCRNPDGELEPWCYTTNPDVRQEYCAIPSCGTSSPHTDRVEQSPVIQECYEGKGENYRGTTSTTISGKKCQAWSSMTPHQHKKTPDNFPNADLIRNYCRNPDGDKSPWCYTMDPTVRWEFCNLEKCSGTGSTVLNAQTTRVPSVDTTSHPESDCMYGSGKDYRGKRSTTVTGTLCQAWTAQEPHRHTIFTPDTYPRAGLEENYCRNPDGDPNGPWCYTTNPKKLFDYCDIPQCVSPSSFDCGKPRVEPQKCPGRIVGGCYAQPHSWPWQISLRTRFGEHFCGGTLIAPQWVLTAAHCLERSQWPGAYKVILGLHREVNPESYSQEIGVSRLFKGPLAADIALLKLNRPAAINDKVIPACLPSQDFMVPDRTLCHVTGWGDTQGTSPRGLLKQASLPVIDNRVCNRHEYLNGRVKSTELCAGHLVGRGDSCQGDSGGPLICFEDDKYVLQGVTSWGLGCARPNKPGVYVRVSRYISWIEDVMKNN')
|
47 |
else:
|
48 |
-
sequence = st.text_input('Enter protein sequence in FASTA format.')
|
49 |
-
name = sequence.split('\n')[0].strip('>')
|
50 |
st.button('Use example sequence', on_click=click_button)
|
51 |
else:
|
52 |
protein_input = st.file_uploader('Choose file')
|
@@ -54,14 +54,14 @@ with st.sidebar:
|
|
54 |
protein_input_stringio = StringIO(protein_input.getvalue().decode("utf-8"))
|
55 |
fasta_sequences = SeqIO.parse(protein_input_stringio, 'fasta')
|
56 |
for fasta in fasta_sequences:
|
57 |
-
name, sequence = fasta.id, str(fasta.seq)
|
58 |
|
59 |
-
email = st.text_input('Enter your email for InterProScan query: ')
|
60 |
|
61 |
# prevent user from clicking 'Find domains' button if email or sequence is empty
|
62 |
domains_submitted = False
|
63 |
if st.button('Find domains'):
|
64 |
-
if email and sequence:
|
65 |
domains_submitted = True
|
66 |
st.session_state.disabled = True
|
67 |
else:
|
@@ -69,12 +69,13 @@ with st.sidebar:
|
|
69 |
else:
|
70 |
with domain_tab:
|
71 |
st.warning('Please enter your query and click "Find domains" to see domains in sequence.')
|
|
|
72 |
with domain_tab:
|
73 |
no_domains = False
|
74 |
error_in_interproscan = False
|
75 |
if domains_submitted:
|
76 |
with st.spinner('Finding domains in sequence using InterProScan. This may take a while...'):
|
77 |
-
result = find_domains(email, sequence, name)
|
78 |
result_text = result[0]
|
79 |
if result_text == 'Domains found.':
|
80 |
st.success(result_text + ' You can now see function predictions for the sequence in the "Function predictions" tab.')
|
@@ -96,7 +97,7 @@ with domain_tab:
|
|
96 |
st.download_button(
|
97 |
label="Download domains in sequence as CSV",
|
98 |
data=domains_csv,
|
99 |
-
file_name=f"{name}_domains.csv",
|
100 |
mime="text/csv",
|
101 |
)
|
102 |
|
@@ -129,7 +130,7 @@ with pred_tab:
|
|
129 |
st.download_button(
|
130 |
label="Download function predictions as CSV",
|
131 |
data=pred_csv,
|
132 |
-
file_name=f"{name}_function_predictions.csv",
|
133 |
mime="text/csv",
|
134 |
)
|
135 |
|
|
|
41 |
input_type = st.radio('Select input type', ['Enter sequence', 'Upload FASTA file'])
|
42 |
if input_type == 'Enter sequence':
|
43 |
if st.session_state.example_seq_button:
|
44 |
+
st.session_state['sequence'] = st.text_area('Enter protein sequence in FASTA format.',
|
45 |
value='>sp|O18783|PLMN_NOTEU\n'
|
46 |
'MEYGKVIFLFLLFLKSGQGESLENYIKTEGASLSNSQKKQFVASSTEECEALCEKETEFVCRSFEHYNKEQKCVIMSENSKTSSVERKRDVVLFEKRIYLSDCKSGNGRNYRGTLSKTKSGITCQKWSDLSPHVPNYAPSKYPDAGLEKNYCRNPDDDVKGPWCYTTNPDIRYEYCDVPECEDECMHCSGENYRGTISKTESGIECQPWDSQEPHSHEYIPSKFPSKDLKENYCRNPDGEPRPWCFTSNPEKRWEFCNIPRCSSPPPPPGPMLQCLKGRGENYRGKIAVTKSGHTCQRWNKQTPHKHNRTPENFPCRGLDENYCRNPDGELEPWCYTTNPDVRQEYCAIPSCGTSSPHTDRVEQSPVIQECYEGKGENYRGTTSTTISGKKCQAWSSMTPHQHKKTPDNFPNADLIRNYCRNPDGDKSPWCYTMDPTVRWEFCNLEKCSGTGSTVLNAQTTRVPSVDTTSHPESDCMYGSGKDYRGKRSTTVTGTLCQAWTAQEPHRHTIFTPDTYPRAGLEENYCRNPDGDPNGPWCYTTNPKKLFDYCDIPQCVSPSSFDCGKPRVEPQKCPGRIVGGCYAQPHSWPWQISLRTRFGEHFCGGTLIAPQWVLTAAHCLERSQWPGAYKVILGLHREVNPESYSQEIGVSRLFKGPLAADIALLKLNRPAAINDKVIPACLPSQDFMVPDRTLCHVTGWGDTQGTSPRGLLKQASLPVIDNRVCNRHEYLNGRVKSTELCAGHLVGRGDSCQGDSGGPLICFEDDKYVLQGVTSWGLGCARPNKPGVYVRVSRYISWIEDVMKNN')
|
47 |
else:
|
48 |
+
st.session_state['sequence'] = st.text_input('Enter protein sequence in FASTA format.')
|
49 |
+
st.session_state['name'] = st.session_state['sequence'].split('\n')[0].strip('>')
|
50 |
st.button('Use example sequence', on_click=click_button)
|
51 |
else:
|
52 |
protein_input = st.file_uploader('Choose file')
|
|
|
54 |
protein_input_stringio = StringIO(protein_input.getvalue().decode("utf-8"))
|
55 |
fasta_sequences = SeqIO.parse(protein_input_stringio, 'fasta')
|
56 |
for fasta in fasta_sequences:
|
57 |
+
st.session_state['name'], st.session_state['sequence'] = fasta.id, str(fasta.seq)
|
58 |
|
59 |
+
st.session_state['email'] = st.text_input('Enter your email for InterProScan query: ')
|
60 |
|
61 |
# prevent user from clicking 'Find domains' button if email or sequence is empty
|
62 |
domains_submitted = False
|
63 |
if st.button('Find domains'):
|
64 |
+
if email in st.session_state and sequence in st.session_state:
|
65 |
domains_submitted = True
|
66 |
st.session_state.disabled = True
|
67 |
else:
|
|
|
69 |
else:
|
70 |
with domain_tab:
|
71 |
st.warning('Please enter your query and click "Find domains" to see domains in sequence.')
|
72 |
+
|
73 |
with domain_tab:
|
74 |
no_domains = False
|
75 |
error_in_interproscan = False
|
76 |
if domains_submitted:
|
77 |
with st.spinner('Finding domains in sequence using InterProScan. This may take a while...'):
|
78 |
+
result = find_domains(st.session_state.email, st.session_state.sequence, st.session_state.name)
|
79 |
result_text = result[0]
|
80 |
if result_text == 'Domains found.':
|
81 |
st.success(result_text + ' You can now see function predictions for the sequence in the "Function predictions" tab.')
|
|
|
97 |
st.download_button(
|
98 |
label="Download domains in sequence as CSV",
|
99 |
data=domains_csv,
|
100 |
+
file_name=f"{st.session_state.name}_domains.csv",
|
101 |
mime="text/csv",
|
102 |
)
|
103 |
|
|
|
130 |
st.download_button(
|
131 |
label="Download function predictions as CSV",
|
132 |
data=pred_csv,
|
133 |
+
file_name=f"{st.session_state.name}_function_predictions.csv",
|
134 |
mime="text/csv",
|
135 |
)
|
136 |
|