-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpubchem.py
72 lines (62 loc) · 1.56 KB
/
pubchem.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from bioservices import UniProt
import requests
u= UniProt()
CID=[]
a=[]
b=[]
name=[]
human=[]
p=open("respubchem.txt","w")
f=open("humanpubchem.txt","r")
lines=f.readlines()
for line in lines:
c=line.split('\t')
if len(c)>2:
if "CID" not in c[3]:
CID.append(c[3])
"""
for line in lines:
c=line.split('\t')
if len(c)>2:
if "Target" not in c[9]:
name.append(c[9])
for line in lines:
c=line.split('\t')
if len(c)>2:
if "Target" not in c[9]:
if c[9] not in a: #for the reputation, we need to save them as singular one in another array
a.append(c[9])
res=u.search(c[9],frmt="tab", columns="entry name")
for line in res.split():
if "HUMAN" in line:
if len(c[9])>0:
if c[9][len(c[9])-1] is 1 or 2:
print c[9]
break
"""
hop=[]
res=[]
smil=[]
for i in range(len(CID)):
url= "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/%s/property/IsomericSMILES/CSV" %CID[i]
response = requests.get(url)
t=(response.content)
print>>p, t
hop.append(t)
print len(hop)
"""
res.append(t)
l=t.split( )[1]
can=l.split(",")
if len(can) is 2:
of=(can[1].strip('"'))
smil.append(of)
print CID[i], of
if len(sml)>0:
smil.append(sml)
smil.append(sml)
cid= l.split(",")[0]
ind=CID.index(cid)
# print name[ind], cid, sml
print len(smil)
"""