Marko Toplak avatar Marko Toplak committed 354d91b

Fixed update scripts for STRING and Taxonomy.

Comments (0)

Files changed (4)

_bioinformatics/obiPPI.py

         # Strip .gz extension
         links_filename = os.path.join(dir, os.path.splitext(links_filename)[0])
         if not os.path.exists(links_filename):
-            shutil.copyfileobj(gz, open(links_filename))
+            shutil.copyfileobj(gz, open(links_filename, "wb"))
         
         cls.init_db(version, taxids)
             

_bioinformatics/obiTaxonomy.py

     @staticmethod
     def ParseTaxdumpFile(file=None, outputdir=None, callback=None):
         from cStringIO import StringIO
+        import Orange.utils
         if file == None:
-            file = tarfile.open(None, "r:gz", StringIO(urllib2.urlopen("ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz").read()))
-        if type(file) == str:
+            so = StringIO()
+            Orange.utils.wget("ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz", dst_obj=so)
+            file = tarfile.open(None, "r:gz", StringIO(so.getvalue()))
+            so.close()
+        elif type(file) == str:
             file = tarfile.open(file)
         names = file.extractfile("names.dmp").readlines()
         nodes = file.extractfile("nodes.dmp").readlines()
             outputdir = default_database_path
         text = TextDB().create(os.path.join(outputdir, "ncbi_taxonomy.db"))
         info = TextDB().create(os.path.join(outputdir, "ncbi_taxonomy_inf.db"))
-        milestones = set(range(0, len(namesDict), max(len(namesDict)/100, 1)))
+        milestones = set(range(0, len(namesDict), max(int(len(namesDict)/100), 1)))
         for i, (id, names) in enumerate(namesDict.items()):
             parent, rank = nodesDict[id]
             ## id, parent and rank go first

server_update/updateSTRING.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
-import obiPPI, orngServerFiles
+from Orange.bio import obiPPI
+import Orange.utils.serverfiles as orngServerFiles
 import os, sys, shutil, urllib2, gzip
 from getopt import getopt
 
 
 serverFiles = orngServerFiles.ServerFiles(username, password)
 
-import obiPPI
-
 filename = orngServerFiles.localpath("PPI", obiPPI.STRING.FILENAME)
 
-if os.path.exists(filename):
-    os.remove(filename)
+if False:
+    if os.path.exists(filename):
+        os.remove(filename)
 
-obiPPI.STRING.download_data("v9.0")
+    obiPPI.STRING.download_data("v9.0")
 
-gzfile = gzip.GzipFile(filename + ".gz", "wb")
-shutil.copyfileobj(open(filename, "rb"), gzfile)
+    gzfile = gzip.GzipFile(filename + ".gz", "wb")
+    shutil.copyfileobj(open(filename, "rb"), gzfile)
 
-serverFiles.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz", 
-                   "STRING Protein interactions (Creative Commons Attribution 3.0 License)",
-                   tags=["protein interaction", "STRING", 
-                         "#compression:gz", "#version:%s" % obiPPI.STRING.VERSION]
-                   )
-serverFiles.unprotect("PPI", obiPPI.STRING.FILENAME)
+    serverFiles.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz", 
+                       "STRING Protein interactions (Creative Commons Attribution 3.0 License)",
+                       tags=["protein interaction", "STRING", 
+                             "#compression:gz", "#version:%s" % obiPPI.STRING.VERSION]
+                       )
+    serverFiles.unprotect("PPI", obiPPI.STRING.FILENAME)
 
 # The second part
 filename = orngServerFiles.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
                          "#compression:gz", "#version:%s" % obiPPI.STRINGDetailed.VERSION]
                    )
 serverFiles.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
-    
+    

server_update/updateTaxonomy.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
-import obiTaxonomy
-import orngServerFiles
+from Orange.bio import obiTaxonomy
+import Orange.utils.serverfiles as orngServerFiles
+import Orange.utils.environ
 
-import orngEnviron
 import os, sys, tarfile
 import socket
 
 username = opt.get("-u", opt.get("--user", "username"))
 password = opt.get("-p", opt.get("--password", "password"))
 
-path = os.path.join(orngEnviron.bufferDir, "tmp_Taxonomy")
+path = os.path.join(Orange.utils.environ.buffer_dir, "tmp_Taxonomy")
 serverFiles = orngServerFiles.ServerFiles(username, password)
 u = obiTaxonomy.Update(local_database_path=path)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.