Py学习  »  Python

#WatsonStudio和Biopython和Fasta文件保存在S3 ObjectStorage上

Dani • 4 年前 • 635 次点击  

我需要阅读一个使用Biopython上传到云对象存储的fasta文件。 我在华生工作室的python 2.7中有一本电子书。 有人试过这个吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38148
 
635 次点击  
文章 [ 1 ]  |  最新文章 4 年前
charles gomes
Reply   •   1 楼
charles gomes    5 年前

从Biopython下载样本数据集: http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc49

将文件拖放到云对象存储。

单击该文件旁边的向下箭头,然后单击InsertStreamingBody对象

enter image description here

这将插入一个streaming body对象(例如streaming_body_1),请运行该单元。

下一步在bytes对象中读取它

fastareadbytes = streaming_body_1.read()

现在,我们需要将字节解码为字符串,然后将其转换为stringio,以便在seqio.parse()中使用它来读取它。

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))

您将看到这样的响应: enter image description here