diff get_data/kegg_glycan/linkKEGG.py @ 1:0a5e0df17054 draft default tip

Uploaded
author chrisb
date Fri, 06 May 2016 08:05:48 -0400
parents 89592faa2875
children
line wrap: on
line diff
--- a/get_data/kegg_glycan/linkKEGG.py	Wed Mar 23 14:35:56 2016 -0400
+++ b/get_data/kegg_glycan/linkKEGG.py	Fri May 06 08:05:48 2016 -0400
@@ -1,6 +1,6 @@
 __author__ = 'cbarnett'
 __license__ = "MIT"
-__version = "0.3"
+__version = "0.3.1"
 # http://www.kegg.jp/kegg/rest/keggapi.html
 
 
@@ -13,6 +13,15 @@
     import urllib2
 
     uri = 'http://rest.kegg.jp/link/'
+
+    import re
+    p = re.compile(' *\+ *') # ensure no unneccessary space in an AND query
+    sdbfix = p.subn('+', sourcedb)
+    sourcedb=sdbfix[0]
+
+    if ' ' in sourcedb:
+        sourcedb = sourcedb.replace(' ', '%20')  # previous behaviour was ignoring text after a space, rather convert to '%20' and pass on to KEGG REST service
+
     fulluri = uri + targetdb + "/" + sourcedb
     try:
         response = urllib2.urlopen(fulluri).read()