-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKEGG.py
58 lines (47 loc) · 1.37 KB
/
KEGG.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
from bioservices.uniprot import UniProt
import requests, json
from xml.etree import ElementTree
url = "http://rest.kegg.jp/find/pathway/sphingolipid"
response = requests.get(url)
t=(response.content).split()
lines=[]
for line in t:
if "path:" in line:
mapid=line.strip("path:")
url = "http://rest.kegg.jp/link/cpd/%s" %mapid
response = requests.get(url)
t=(response.content).split()
if t is not None:
for line in t:
if "cpd:" in line:
url = "http://rest.kegg.jp/get/%s" %line
response = requests.get(url)
t=(response.content).split()
for line in t:
lines.append(line)
for i in range(len(lines)-1):
if "PubChem:" in lines[i]:
url = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/%s/property/IsomericSMILES/CSV" %lines[i+1]
response = requests.get(url)
t=(response.content).split()
print t
"""
res= t.split("\t")
for line in res:
print line
ar=[]
t=h.split('\t')
for line in t:
ar.append(line)
i=0
for line in ar:
i=i+1
print i,line
array=[]
for line in t:
array.append(line)
for i in range(len(array)):
a=array[i].find("sphingolipid")
if a >0:
print array[i+1]
"""