-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq26.py
More file actions
31 lines (28 loc) · 1.09 KB
/
q26.py
File metadata and controls
31 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import urllib2
import re
def calc(resopnse):
string1 = response.read().splitlines() #formatting the for the input
string2 = ''
for i in range(0,len(string1)):
string2 +=string1[i]
#print string2
val = (re.findall('(GO\; GO\:\d{7}\; P\:.+?;)',string2)) #identifying all the biological processes in which the protein is involved.
return val
def format(val): #To format the obtained strings from calc(response).
string2 = ''
for i in range(0, len(val)):
string2 += val[i]
value = re.findall('(P\:.+?;)',string2)
result1 = [w.replace('P:','') for w in value]
result = [w.replace(';', '') for w in result1]
return result
f = open ("rosalind_dbpr.txt",'r')
input = f.readlines()
num_lines = sum(1 for line in open("rosalind_dbpr.txt"))
for i in range(0,num_lines):
response = urllib2.urlopen('http://www.uniprot.org/uniprot/'+input[i].rstrip()+'.txt') # acccessing the input.
val = calc(response)
#print val
value = format(val) #printing the ouput.
for i in value:
print i