Biopython无法找到文件

时间:2012-09-17 10:22:46

标签: biopython blast

我正在尝试从Python提示符运行qblast,并在导入我需要的所有库之后,Python无法找到我的文件:

>>> record = SeqIO.read(open("sinchimeras_1.fasta"), format="fasta")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'sinchimeras_1.fasta'

我试图写下该文件的所有路径(“/ Users / imac ...”)并将文件移动到Python和Biopython文件夹,然后收到相同的消息。

我在哪里保存文件?我做错了什么?

1 个答案:

答案 0 :(得分:0)

您需要将该文件移动到工作目录或使用绝对路径。

这个问题与Biopython无关; IOError来自open("sinchimeras_1.fasta")

解释

当您为Python提供相对路径“sinchimeras_1.fasta”时,它会在当前目录中查找此类文件。因此,不要将您的Fasta文件移动到Python / Biopython文件夹,而是确保它位于您的工作目录中(os.getcwd()可能会有所帮助)。

或者,您可以提供文件的绝对路径来代替“sinchimeras_1.fasta”(例如open("/Users/imac.../sinchimeras_1.fasta"))。