-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamModeError #3057
Comments
Hi @akim-nyoni Can you provide the code with what you do between the file uploader and the line that causes the error? My guess is the file uploads correctly, but the input to biopython is incorrect. Just to be clear, the output from the FileUploader is an instance of BytesIO. You might need to convert it to a string This StackOverflow answer might help. # assume bytes_io is a `BytesIO` object
byte_str = bytes_io.read()
# Convert to a "unicode" object
text_obj = byte_str.decode('UTF-8') # Or use the encoding you expect |
import streamlit as st def main():
if name == 'main': the for transcription and translation of DNA |
Thank you for the code @akim-nyoni . This is definitely a challenge of converting the output of file uploader, that is import io
# assume bytes_io is a `BytesIO` object
byte_str = seq_file.read()
# Convert to a "unicode" string object
text_obj = byte_str.decode('UTF-8') # Or use the encoding you expect
# convert to io.StringIO, which I think SeqIO will understand well.
SeqIO.read(io.StringIO(text_obj)) Since this is not issue with Streamlit, I am going to close this issue. Feel free to let us know if you get any more errors, but I recommend using our forums. It’s monitored by multiple people, many of which may be familiar with biopython and how to make it work with Streamlit. Here’s a discussion conversation on the same conversion from BytesIO to a string. |
Thank you, it worked |
import streamlit as st data pkgsimport matplotlib.pyplot as plt def main():
assume bytes_io is a
|
Hi there @arighosh1 , thanks for sharing your question! Unfortunately we can't always dig deep and troubleshoot challenges like this on GitHub. We typically use GitHub for feature requests and bug reports. For troubleshooting help, you can visit our awesome community forums, where thousands of other Streamlit hackers help each other and talk about the amazing things they are creating! |
Im trying to use streamlit in biopython and its giving me the below error:
what my be the problem?
StreamModeError: Fasta files must be opened in text mode.
Traceback:
File "c:\users\akim nyoni\anaconda3\lib\site-packages\streamlit\script_runner.py", line 333, in run_script
exec(code, module.dict)
File "C:\Users\AKIM NYONI\Desktop\Xul\SCI4101 Bioinformatcs\app\BioInfo-App\App.py", line 38, in
main()
File "C:\Users\AKIM NYONI\Desktop\Xul\SCI4101 Bioinformatcs\app\BioInfo-App\App.py", line 28, in main
dna_record = SeqIO.read( seq_file ,"fasta")
File "c:\users\akim nyoni\anaconda3\lib\site-packages\Bio\SeqIO_init.py", line 654, in read
iterator = parse(handle, format, alphabet)
File "c:\users\akim nyoni\anaconda3\lib\site-packages\Bio\SeqIO_init_.py", line 607, in parse
return iterator_generator(handle)
File "c:\users\akim nyoni\anaconda3\lib\site-packages\Bio\SeqIO\FastaIO.py", line 183, in init
super().init(source, mode="t", fmt="Fasta")
File "c:\users\akim nyoni\anaconda3\lib\site-packages\Bio\SeqIO\Interfaces.py", line 52, in init
raise StreamModeError(
The text was updated successfully, but these errors were encountered: