root/galaxy-central/tools/rgenetics/rgGLM_code.py

リビジョン 2, 2.0 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1# before running the qc, need to rename various output files
2import os,string,time
3from galaxy import datatypes
4
5def timenow():
6    """return current time as a string
7    """
8    return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
9
10def get_out_formats():
11    """return options for formats"""
12    dat = [['ucsc track','wig'],['ucsc genome graphs','gg'],['tab delimited','xls']]
13    dat = [(x[0],x[1],False) for x in dat]
14    dat.reverse()
15    return dat
16
17def get_phecols(phef='',selectOne=0):
18   """return column names """
19   phepath = phef.extra_files_path
20   phename = phef.metadata.base_name
21   phe = os.path.join(phepath,'%s.pphe' % phename)
22   head = open(phe,'r').next()
23   c = head.strip().split()[2:] # first are fid,iid
24   res = [(cname,cname,False) for cname in c]
25   if len(res) >= 1:
26       if selectOne:
27          x,y,z = res[0] # 0,1 = fid,iid
28          res[0] = (x,y,True) # set second selected
29       else:
30          res.insert(0,('None','None',True))
31   else:
32      res = [('None','no phenotype columns found',False),]
33   return res
34
35
36def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
37    """Sets the name of the data"""
38    killme=string.punctuation+string.whitespace
39    trantab = string.maketrans(killme,'_'*len(killme))
40    job_name = param_dict.get( 'title1', 'GLM' )
41    job_name = job_name.encode().translate(trantab)
42    outxls = ['tabular','%s_GLM.xls' % job_name]
43    logtxt = ['txt','%s_GLM_log.txt' % job_name]
44    ggout = ['gg','%s_GLM_topTable.gff' % job_name]
45    lookup={}
46    lookup['out_file1'] = outxls
47    lookup['logf'] = logtxt
48    lookup['gffout'] = ggout
49    info = '%s GLM output by rgGLM created at %s' % (job_name,timenow())
50    for name in lookup.keys():
51        data = out_data[name]
52        data_type,newname = lookup.get(name,(None,None))
53        if data_type <> None:
54            data.name = newname
55            data.info = info
56            out_data[name] = data
57        else:
58            print >> stdout,'no output matching %s in exec after hook for rgGLM' % name
59    app.model.context.flush()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。