我是 Python 的新用户,我尝试导入 genbank 和 fasta 格式文件。 在他们的文档中,他们提供了一个示例来说明如何将数据集导入 Python。 具体来说,他们在 Biopython 教程和食谱第 16 页中提供了以下示例:
from Bio import SeqIO
for seq_record in SeqIO.parse("ls_orchid.gbk", "genbank"):
print seq_record.id
print repr(seq_record.seq)
print len(seq_record)
现在,他们在第 14 页提到 Biopython 源代码包含此文件,这是真的。但是,python如何通过Bio import SeqIO知道文件到底在哪里呢? 请注意,我在安装biopython及其组件后尝试了上面的代码,但它从未工作?
另外,我可以指定 genbank 文件的路径并以某种方式打开它吗!
谢谢
最佳答案
根据http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc10
您需要将文件复制到本地目录
When this tutorial was originally written, this search gave us only 94 hits, which we saved as a FASTA formatted text file and as a GenBank formatted text file (files ls_orchid.fasta and ls_orchid.gbk, also included with the Biopython source code under docs/tutorial/examples/).
If you run the search today, you’ll get hundreds of results! When following the tutorial, if you want to see the same list of genes, just download the two files above or copy them from docs/examples/ in the Biopython source code. In Section 2.5 we will look at how to do a search like this from within Python.
关于python - 我不明白如何为我想在 python 中打开的文件指定路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9251683/