Entering edit mode
10.0 years ago
nadia_ashraf2000
•
0
import Bio
import csv
from Bio.Blast import NCBIXML
from Bio.Blast import NCBIWWW
q_id = []
with open('C:\Users\Nadia\Desktop\imran-sequenceIDs.csv','rb') as f:
reader=csv.reader(f)
for row in reader:
q_id.append(row[0])
print 'sequence tags read'
with open('C:\\Users\\Nadia\\Desktop\\01-01A-Unigene.txt','r') as seq_file:
seq_file=seq_file.readlines()
print 'sequence file read'
for i in range(0,len(q_id)):
seq=[]
if i>=1:
for j,k in enumerate(seq_file):
if str(q_id[i])in k:
print 'tag matched',i
start=j
print start
counter=1
seq.append(k)
while counter==1:
for l in range(start+1,len(seq_file)-(start+1)):
if not seq_file[l][0]=='>':
seq.append(seq_file[l])
else:
counter=2
break
if seq:
seq=''.join(seq)
result_handle=NCBIWWW.qblast("blastn","nt",seq)
blast_record=NCBIXML.read(result_handle)
if not blast_record.alignments:
print q_id[i], 'is novel'
else:
print q_id[i],'is not novel!'
This is my script and its generating following error
Traceback (most recent call last):
File "C:\Python27\blast.py", line 37, in <module>
result_handle=NCBIWWW.qblast("blastn","nt",seq)
File "C:\Python27\lib\site-packages\Bio\Blast\NCBIWWW.py", line 163, in qblast
handle = _urlopen(request)
File "C:\Python27\lib\urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 404, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 422, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27\lib\urllib2.py", line 1184, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
Any suggestion would be really helpful.
Thanks for the suggestion I runned it on linux cluster and its working just fine :)
If this answer solved your question, please "accept" the answer. That's part of how BioStars and similar sites like Stack Exchange work.