I need to read a fasta file uploaded on Cloud Object storage using Biopython. I've anotebook in Python 2.7 in Watson Studio. Does anyone have tried this?
Asked
Active
Viewed 59 times
-1
-
Usually you want to explore some options out and see why they are failing before posting question. Hope below answer helps!!! – charles gomes Oct 04 '18 at 00:18
1 Answers
0
Download the sample dataset from biopython :- http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc49
Drag and drop the file to Cloud Object Storage.
Click Down arrow next to that file and click InsertStreamingBody object
This will insert a streamingBody object(ex. streaming_body_1), Please run that cell.
Next read that in a bytes Object
fastareadbytes = streaming_body_1.read()
Now we need to decode the bytes to string and then convert it to StringIO so that we can use it in SeqIO.parse() to read it
from io import StringIO
from Bio import SeqIO
for seq_record in SeqIO.parse(StringIO(fastareadbytes.decode('utf-8')), "fasta"):
print(seq_record.id)
print(repr(seq_record.seq))
print(len(seq_record))
![](../../users/profiles/4725197.webp)
charles gomes
- 2,105
- 8
- 15