Changeset 1753:d8bea5b19e25 in orange-bioinformatics for server_update/updateSTRING.py


Ignore:
Timestamp:
04/18/13 22:43:46 (12 months ago)
Author:
markotoplak
Branch:
default
Message:

Update script for STRING: reads current version from the webpage and updates only if the database version on SF server differs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server_update/updateSTRING.py

    r1721 r1753  
    66 
    77from common import * 
     8import re 
    89 
    9 filename = sf_local.localpath("PPI", obiPPI.STRING.FILENAME) 
    1010 
    11 if False: 
    12     if os.path.exists(filename): 
    13         os.remove(filename) 
     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 
    1416 
    15     obiPPI.STRING.download_data("v9.0") 
     17version = get_version() 
     18version_id = "#dbversion:%s" % version 
    1619 
    17     gzfile = gzip.GzipFile(filename + ".gz", "wb") 
    18     shutil.copyfileobj(open(filename, "rb"), gzfile) 
     20force = False # force update 
    1921 
    20     sf_server.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz",  
    21                        "STRING Protein interactions (Creative Commons Attribution 3.0 License)", 
     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 
     36        if os.path.exists(filename): 
     37            os.remove(filename) 
     38 
     39        cl.download_data(version) 
     40 
     41        gzfile = gzip.GzipFile(filename + ".gz", "wb") 
     42        shutil.copyfileobj(open(filename, "rb"), gzfile) 
     43 
     44        sf_server.upload("PPI", sfn, filename + ".gz",  
     45                       desc, 
    2246                       tags=["protein interaction", "STRING",  
    23                              "#compression:gz", "#version:%s" % obiPPI.STRING.VERSION] 
     47                             "#compression:gz", "#version:%s" % cl.VERSION, version_id] 
    2448                       ) 
    25     sf_server.unprotect("PPI", obiPPI.STRING.FILENAME) 
    26  
    27 # The second part 
    28 filename = sf_local.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
    29  
    30 if os.path.exists(filename): 
    31     os.remove(filename) 
    32  
    33 obiPPI.STRINGDetailed.download_data("v9.0") 
    34  
    35 gzfile = gzip.GzipFile(filename + ".gz", "wb") 
    36 shutil.copyfileobj(open(filename, "rb"), gzfile) 
    37  
    38 sf_server.upload("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED, filename + ".gz",  
    39                    "STRING Protein interactions (Creative Commons Attribution-Noncommercial-Share Alike 3.0 License)" , 
    40                    tags=["protein interaction", "STRING", 
    41                          "#compression:gz", "#version:%s" % obiPPI.STRINGDetailed.VERSION] 
    42                    ) 
    43 sf_server.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
    44      
     49        sf_server.unprotect("PPI", sfn) 
Note: See TracChangeset for help on using the changeset viewer.