I am trying to retrieve the specific binary interactions of a data set of proteins. I am getting the following error: Can you suggest me that how to resolve the problem?
import urllib2
import sys
# ------------------ MITAB FUNCTIONS ------------------
def getXrefByDatabase(line, database):
fields = line.split('|')
for field in fields:
parts = field.split(':')
db = parts[0]
value = parts[1].split('(')[0]
if database == db:
return value
# -----------------------------------------------------
f1=open ('pro_name.txt', 'r')
f2=open ('interactions.txt', 'w')
for line in f1:
a = line.rstrip('\n')
s2 = "%20AND%20taxidA:9606%20AND%20taxidB:9606?"
queryUrl = s1 + a + s2;
#print queryUrl
try:
fileHandle = urllib2.urlopen(queryUrl)
content = fileHandle.read()
fileHandle.close()
except IOError:
print 'Cannot open URL' % urlStr
content = ''
lines = content.splitlines()
f2.write('\n')
f2.write(a)
f2.write('\n')
for line in lines:
cols = line.split('\t')
f2.write( getXrefByDatabase(cols[0], 'uniprotkb') + ' interacts with ' + getXrefByDatabase(cols[1], 'uniprotkb'))
f2.write('\n')