Changeset 1721:921b3780c6cc in orange-bioinformatics for server_update/updateGO.py


Ignore:
Timestamp:
09/14/12 12:20:53 (19 months ago)
Author:
markotoplak
Branch:
default
Message:

Moved common functionality of the server files update scripts to a separate file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server_update/updateGO.py

    r1719 r1721  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
     4from common import * 
     5 
    46from Orange.bio import obiGO, obiTaxonomy, obiGene, obiGenomicsUpdate 
    57 
    6 import Orange.utils.environ as orngEnviron 
    7 import Orange.utils.serverfiles as orngServerFiles 
    8 import os, sys, shutil, urllib2, tarfile 
    9 from getopt import getopt 
    10  
    11 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    12  
    13 username = opt.get("-u", opt.get("--user", "username")) 
    14 password = opt.get("-p", opt.get("--password", "password")) 
     8import urllib2, tarfile 
    159 
    1610from collections import defaultdict 
    1711 
    18 tmpDir = os.path.join(orngEnviron.buffer_dir, "tmp_GO") 
     12tmpDir = os.path.join(environ.buffer_dir, "tmp_GO") 
    1913try: 
    2014    os.mkdir(tmpDir) 
    2115except Exception: 
    2216    pass 
    23  
    24 serverFiles = orngServerFiles.ServerFiles(username, password) 
    2517 
    2618u = obiGO.Update(local_database_path = tmpDir) 
     
    3830    ##upload the ontology 
    3931    print "Uploading gene_ontology_edit.obo.tar.gz" 
    40     serverFiles.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)", 
     32    sf_server.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)", 
    4133                       tags=["gene", "ontology", "GO", "essential", "#uncompressed:%i" % uncompressedSize(filename), "#version:%i" % obiGO.Ontology.version]) 
    42     serverFiles.unprotect("GO", "gene_ontology_edit.obo.tar.gz") 
     34    sf_server.unprotect("GO", "gene_ontology_edit.obo.tar.gz") 
    4335 
    4436#from obiGeneMatch import _dbOrgMap 
     
    8678#            print "unknown organism name translation for:", org 
    8779        print "Uploading", "gene_association." + org + ".tar.gz" 
    88         serverFiles.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName, 
     80        sf_server.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName, 
    8981                           tags=["gene", "annotation", "ontology", "GO", orgName, "#uncompressed:%i" % uncompressedSize(filename), 
    9082                                 "#organism:"+orgName, "#version:%i" % obiGO.Annotations.version] + (["essential"] if org in essentialOrgs else [])) 
    91         serverFiles.unprotect("GO", "gene_association." + org + ".tar.gz") 
     83        sf_server.unprotect("GO", "gene_association." + org + ".tar.gz") 
    9284         
    9385try: 
    9486    import cPickle 
    9587#    tax = cPickle.load(open(os.path.join(tmpDir, "taxonomy.pickle"), "rb")) 
    96     tax = cPickle.load(open(orngServerFiles.localpath_download("GO", "taxonomy.pickle"), "rb")) 
     88    tax = cPickle.load(open(sf_local.localpath_download("GO", "taxonomy.pickle"), "rb")) 
    9789except Exception: 
    9890    tax = {} 
     
    10395    cPickle.dump(tax, open(os.path.join(tmpDir, "taxonomy.pickle"), "wb")) 
    10496    print "Uploading", "taxonomy.pickle" 
    105     serverFiles.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs", 
     97    sf_server.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs", 
    10698                       tags = ["GO", "taxon", "organism", "essential", "#version:%i" % obiGO.Taxonomy.version]) 
    107     serverFiles.unprotect("GO", "taxonomy.pickle") 
     99    sf_server.unprotect("GO", "taxonomy.pickle") 
Note: See TracChangeset for help on using the changeset viewer.