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

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

import galaxy-central

行番号 
1from galaxy import datatypes,model
2import sys,time,string,shutil,os
3
4def timenow():
5    """return current time as a string
6    """
7    return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
8
9def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
10    """Sets the name of the html output file
11       if we created a set of ldreduced files, we need to move them into the input files_path
12       so it doesn't need to be done again
13    """
14    indat = inp_data['i']
15    indatname = indat.name
16    base_name = indat.metadata.base_name
17    todir = indat.extra_files_path # where the ldreduced stuff should be
18    job_name = param_dict.get( 'title', 'Eigenstrat run' )
19    job_name = job_name.encode()
20    killme = string.punctuation + string.whitespace
21    trantab = string.maketrans(killme,'_'*len(killme))
22    job_name = job_name.translate(trantab)
23    info = '%s rgEigPCA2 on %s at %s' % (job_name,indatname,timenow())
24    exts = ['html','txt']
25    for i,ofname in enumerate(['out_file1','pca']):
26        data = out_data[ofname]
27        ext = exts[i]
28        newname = '%s.%s' % (job_name,ext)
29        data.name = newname
30        data.info = info
31        out_data[ofname] = data
32        if i == 0:
33            fromdir = data.extra_files_path
34    ldfname = '%s_INDEP_THIN' % base_name # we store ld reduced and thinned data
35    ldout = os.path.join(todir,ldfname)
36    ldin = os.path.join(fromdir,ldfname)
37    if os.path.exists('%s.bed' % ldin) and not os.path.exists('%s.bed' % ldout): # copy ldreduced to input for next time
38        for ext in ['bim','bed','fam']:
39            src = '%s.%s' % (ldin,ext)
40            dest = '%s.%s' % (ldout,ext)
41            shutil.copy(src,dest)
42    app.model.context.flush()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。