1) I'm working in python to do some Bio-informatics analysis.I have to retrieve DNA sequence from uniprot web site. For that i have written a code like this:
# 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!!!"
For each ID it's taking nearly 1 mins to retrieve the sequence. The problem is this code is running but at some ID the program is getting stuck and it's not moving forward for hours. It's not showing any errors as well. The sequence exist in DataBase also. But there is continuous internet connection (but a bit slow some times). I have to retrieve 1000+ of such sequence and analyse further. How can i solve this issue.
2) Also please tell me how I can exit out of the loop at the end of 5 mins whether or not the task is complete.