Changeset 1721:921b3780c6cc in orange-bioinformatics for server_update/updateNCBI_geneinfo.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/updateNCBI_geneinfo.py

    r1719 r1721  
    11##interval:7 
     2from common import * 
    23from Orange.bio import obiGene, obiTaxonomy 
    3 import Orange.utils.serverfiles as orngServerFiles 
    4 import Orange.utils.environ as orngEnviron 
    5 import sys, os 
    64from gzip import GzipFile 
    7 from getopt import getopt 
    85 
    9 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    10  
    11 tmpdir = os.path.join(orngEnviron.buffer_dir, "tmp_NCBIGene_info") 
     6tmpdir = os.path.join(environ.buffer_dir, "tmp_NCBIGene_info") 
    127try: 
    138    os.mkdir(tmpdir) 
    149except Exception, ex: 
    1510    pass 
    16  
    17 username = opt.get("-u", opt.get("--user", "username")) 
    18 password = opt.get("-p", opt.get("--password", "password")) 
    1911 
    2012gene_info_filename = os.path.join(tmpdir, "gene_info") 
     
    4032        history[hi.split("\t", 1)[0]].append(hi.strip()) 
    4133 
    42          
    43 sf = orngServerFiles.ServerFiles(username, password) 
    44  
    4534for taxid, genes in genes.items(): 
    4635    filename = os.path.join(tmpdir, "gene_info.%s.db" % taxid) 
     
    5039    f.close() 
    5140    print "Uploading", filename 
    52     sf.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename, 
     41    sf_server.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename, 
    5342              title = "NCBI gene info for %s" % obiTaxonomy.name(taxid), 
    5443              tags = ["NCBI", "gene info", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else [])) 
    55     sf.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid) 
     44    sf_server.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid) 
    5645     
    5746    filename = os.path.join(tmpdir, "gene_history.%s.db" % taxid) 
     
    6150    f.close() 
    6251    print "Uploading", filename 
    63     sf.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename, 
     52    sf_server.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename, 
    6453              title = "NCBI gene history for %s" % obiTaxonomy.name(taxid), 
    6554              tags = ["NCBI", "gene info", "history", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else [])) 
    66     sf.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid) 
     55    sf_server.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid) 
Note: See TracChangeset for help on using the changeset viewer.