Entering edit mode
12.2 years ago
Peiska
▴
20
I am doing a BioPython Script that reads IDs from a .txt and retrieves corresponding sequence records from ExPASy service. I just start to program in BioPython a few weeks ago, and I really dont know why this is not working. Can someone help me please?
This is my code:
from Bio import ExPASy
from Bio import SeqIO
openfile = open("idlist.txt", "r")
ids=openfile.readlines()
i=0
while i< len (ids):
handle = ExPASy.get_sprot_raw(ids[i])
seq_record = SeqIO.read(handle, "swiss") #Program crashes here
print seq_record.id
print seq_record.name
print seq_record.description
print repr(seq_record.seq)
print "Length %i" % len(seq_record)
print seq_record.annotations["keywords"]
i+=1
handle.close()
The text file with the IDS has this format and this ids separated by lines:
Q06187 E2RMF7 P35991 Q3ZC95 Q5S255 Q8JH64
Solved: handle = ExPASy.get_sprot_raw(ids[i].strip())
thanks for sharing a problem and the solution!