1)我在python中工作进行生物信息学分析。我必须从uniprot网站检索DNA序列。为此我写了这样的代码:
# b is the list of ID read from text file.
for j in range (0,len(b)):
add=str("http://www.ebi.ac.uk/ena/data/view/")+str(b[j+13:j+23])+str("&display=fasta")
# Here str(b[j+13:j+23]) is the specific ID which changes at every iteration of for...
g =urllib.urlopen(add)
c=g.readlines()
#few more codes......
print b[j+13:j+23]," Sequence is retrieved successfully!!!"
对于每个ID,它需要将近1分钟来检索序列。问题是这个代码正在运行但是在一些ID下,程序卡住了,并且它没有向前移动数小时。它也没有显示任何错误。该序列也存在于DataBase中。但是有连续的互联网连接(但有时有点慢)。我必须检索1000多个这样的序列并进一步分析。我该如何解决这个问题。
2)另外请告诉我如何在5分钟结束时退出循环,无论任务是否完成。