Question: I am running blast over internet using biopython but its giving connection error but when I am doing same thing on shell its working fine.
0
gravatar for nadia_ashraf2000
5.0 years ago by
Pakistan
nadia_ashraf20000 wrote:

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. 

blast biopython • 2.5k views
ADD COMMENTlink modified 5.0 years ago by Peter5.8k • written 5.0 years ago by nadia_ashraf20000
0
gravatar for Peter
5.0 years ago by
Peter5.8k
Scotland, UK
Peter5.8k wrote:

Using any online resource there will be network errors from time to time, or problems at the remote server. This is best dealt with using a try/except to catch the error, pause, and retry (up to some reasonable limit like 3 times).

However, for any large BLAST job, I would recommend installing BLAST and the NT database locally - it even works on Windows but the database is quite big. Your institute might have a local Linux cluster you could use instead?

ADD COMMENTlink written 5.0 years ago by Peter5.8k

Thanks for the suggestion I runned it on linux cluster and its working just fine :)

ADD REPLYlink written 5.0 years ago by nadia_ashraf20000

If this answer solved your question, please "accept" the answer. That's part of how BioStars and similar sites like Stack Exchange work.

ADD REPLYlink written 4.8 years ago by Peter5.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 671 users visited in the last hour