Spaces:
Sleeping
Sleeping
Erva Ulusoy
commited on
Commit
·
a81447f
1
Parent(s):
4c00b99
file uploader encoding error fix and label update
Browse files- Domain2GO.py +16 -2
Domain2GO.py
CHANGED
|
@@ -35,9 +35,23 @@ with st.sidebar:
|
|
| 35 |
st.session_state['sequence'] = st.text_area('Enter a protein sequence in FASTA format*')
|
| 36 |
st.session_state['name'] = st.session_state['sequence'].split('\n')[0].strip('>')
|
| 37 |
else:
|
| 38 |
-
protein_input = st.file_uploader('Choose file')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
if protein_input:
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
fasta_sequences = SeqIO.parse(protein_input_stringio, 'fasta')
|
| 42 |
for fasta in fasta_sequences:
|
| 43 |
st.session_state['name'], st.session_state['sequence'] = fasta.id, str(fasta.seq)
|
|
|
|
| 35 |
st.session_state['sequence'] = st.text_area('Enter a protein sequence in FASTA format*')
|
| 36 |
st.session_state['name'] = st.session_state['sequence'].split('\n')[0].strip('>')
|
| 37 |
else:
|
| 38 |
+
protein_input = st.file_uploader('Choose a file', type=['.fasta', '.fas', '.fa', '.fna', '.ffn', '.faa', '.mpfa', '.frn', '.txt'])
|
| 39 |
+
css='''
|
| 40 |
+
<style>
|
| 41 |
+
[data-testid="stFileUploadDropzone"] div div::after {color:gray; font-size: .8em; content:"FASTA file should contain only one sequence."}
|
| 42 |
+
[data-testid="stFileUploadDropzone"] div div small{display:none;}
|
| 43 |
+
</style>
|
| 44 |
+
'''
|
| 45 |
+
|
| 46 |
+
st.markdown(css, unsafe_allow_html=True)
|
| 47 |
+
|
| 48 |
if protein_input:
|
| 49 |
+
bytes_data = protein_input.read()
|
| 50 |
+
try:
|
| 51 |
+
protein_input_stringio = StringIO(bytes_data.decode("utf-8"))
|
| 52 |
+
except UnicodeDecodeError:
|
| 53 |
+
protein_input_stringio = StringIO(bytes_data.decode("utf-16"))
|
| 54 |
+
|
| 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)
|