source: orange-bioinformatics/server_update/updateSTRING.py @ 1756:ec01f8aa98a9

Revision 1756:ec01f8aa98a9, 1.6 KB checked in by markotoplak, 12 months ago (diff)

STRING database build: do not unzip files.

RevLine 
[1717]1##!interval=7
2##!contact=ales.erjavec@fri.uni-lj.si
3
[1720]4from Orange.bio import obiPPI
[1721]5import urllib2, gzip
[1717]6
[1721]7from common import *
[1753]8import re
[1717]9
10
[1753]11def get_version():
12    from urllib2 import build_opener
13    html = build_opener().open('http://www.string-db.org/newstring_cgi/show_download_page.pl').read().decode()
14    ver = re.findall("protein\.links\.(v.*?)\.txt\.gz", html, re.DOTALL)[0]
15    return ver
[1717]16
[1753]17version = get_version()
18version_id = "#dbversion:%s" % version
[1717]19
[1753]20force = False # force update
[1717]21
[1753]22for cl,desc,sfn in [ (obiPPI.STRING, 
23                    "STRING Protein interactions (Creative Commons Attribution 3.0 License)", 
24                    obiPPI.STRING.FILENAME),
25                    (obiPPI.STRINGDetailed, 
26                    "STRING Protein interactions (Creative Commons Attribution-Noncommercial-Share Alike 3.0 License)", 
27                    obiPPI.STRINGDetailed.FILENAME_DETAILED) ]:
28
29    print cl
30    print "current info", sf_server.info("PPI", sfn)
31
32    if force or version_id not in sf_server.info("PPI", sfn)["tags"]:
33
34        filename = sf_local.localpath("PPI",  sfn)
35
[1756]36        if os.path.exists(filename): #remvoe prebuilt sqlite database
[1753]37            os.remove(filename)
38
39        cl.download_data(version)
40
[1756]41        gzfile = gzip.GzipFile(filename + ".gz", "wb") #gzip the database
[1753]42        shutil.copyfileobj(open(filename, "rb"), gzfile)
43
44        sf_server.upload("PPI", sfn, filename + ".gz", 
45                       desc,
[1720]46                       tags=["protein interaction", "STRING", 
[1753]47                             "#compression:gz", "#version:%s" % cl.VERSION, version_id]
[1720]48                       )
[1753]49        sf_server.unprotect("PPI", sfn)
Note: See TracBrowser for help on using the repository browser.