python - 我不明白如何为我想在 python 中打开的文件指定路径

标签 python biopython

我是 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/

相关文章:

javascript - Regex - 匹配 html 源代码中的 javascript 变量

python - 提取向上指向的车道线

python - 如何以固定宽度打印字符串?

python - 如何在 python 中合并重叠的字符串?

python - fasta.gz 上的 SeqIO.parse

python - 仅对齐并保存结构段

python - 沿特定轴的 Numpy 点积

Python日志记录导致延迟?

biopython - 如何使用biopython库将多个pdb写入单个pdb文件

python - 尝试使用多线程并行化 python 算法并避免 GIL 限制