我已经涉足 biopython 大约一年了,最近我升级到了 Biopython 1.59 版。我一直在通过一些教程来更新我的技能,但是当我运行 for 循环和 biopython 库中的任何模块时,我总是得到以下错误:
IndentationError: expected an indented block
当我从命令行终端调用以 Komodo Edit 版本 7.0.2 编写的 .py 文件时,我只会收到此错误:
Priyas-iMac:~ Priya$ python /Users/priya/Documents/Python/Tutorials/BioParse.py
Traceback (most recent call last):
File "/Users/priya/Documents/Python/Tutorials/BioParse.py", line 4, in <module>
SeqIO.write(rc, "/Users/priya/Documents/Python/Tutorials/ls_orchid_rc.fasta", "fasta")
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/SeqIO/__init__.py", line 400, in write
from Bio import AlignIO
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/AlignIO/__init__.py", line 147, in <module>
import NexusIO
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/AlignIO/NexusIO.py", line 19, in <module>
from Bio.Nexus import Nexus
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/Nexus/Nexus.py", line 15, in <module>
import os,sys, math, random, copy
File "/Users/Priya/Documents/Python/Tutorials/random.py", line 27
randLowHigh(5,10)
^
IndentationError: expected an indented block
当我使用命令行调用我一年前编写的旧 .py 文件时,它们运行良好。当我直接启动 python 并逐行输入教程示例时,它工作正常:
Priyas-iMac:~ Priya$ python
Python 2.7.3 (default, Apr 19 2012, 00:55:09)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Bio import SeqIO
>>> for seq_record in SeqIO.parse("/Users/priya/Documents/Python/Tutorials/ls_orchid.txt","fasta"):
... print seq_record.id
...
gi|2765658|emb|Z78533.1|CIZ78533
gi|2765657|emb|Z78532.1|CCZ78532
如何修复我的 .py 文件以便我可以从终端运行它?
任何对此问题的见解将不胜感激!
普里亚