root/galaxy-central/tools/rgenetics/rgQQ_code.py @ 2

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

import galaxy-central

行番号 
1# before running the qc, need to rename various output files
2#       <data format="html" name="html_file" />
3#       <data format="txt" name="log_file" parent="html_file" />
4#       <data format="tabular" name="marker_file" parent="html_file" />
5#       <data format="tabular" name="subject_file" parent="html_file" />
6
7from galaxy import datatypes,model
8import sys,string
9
10def get_columns( input ):
11    columns = []
12    elems = []
13    if input and input.metadata.columns:
14        ncols = input.metadata.columns
15        colnames = ['Col%d' % x for x in range(1,ncols+1)]
16        for i, line in enumerate( file ( input.file_name ) ):
17            valid = True
18            if line and not line.startswith( '#' ):
19                line = line.rstrip('\r\n')
20                elems = line.split( '\t' )
21
22                """
23                Since this tool requires users to select only those columns
24                that contain numerical values, we'll restrict the column select
25                list appropriately.
26                """
27                if len(elems) > 0:
28                    for col in range(len(elems)): # zero offset
29                       if i == 0: # header row
30                          colnames[col] = elems[col]
31                       else:
32                          val = elems[col]
33                          try:
34                              val = float(val)
35                              valid = True
36                          except:
37                              valid = False
38                       if valid:
39                            option = colnames[col]
40                            columns.append((option,str(col),False))
41                if len(columns) > 0:
42                    """
43                    We have our select list built, so we can break out of the outer most for loop
44                    """
45                    break
46            if i == 30:
47                break # Hopefully we never get here...
48    else:
49        columns = [('?','?',False),]
50    return columns
51
52
53def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
54    """Sets the name of the data
55       <outputs>
56       <data format="pdf" name="allqq" />
57       <data format="pdf" name="lowqq" parent="allqq"/>
58    </outputs>
59    """
60    job_name = param_dict.get( 'name', 'My rgQQplot' )
61    killme = string.punctuation + string.whitespace
62    trantab = string.maketrans(killme,'_'*len(killme))
63    newname = '%s.pdf' % job_name.translate(trantab)
64    lookup={}
65    lookup['allqq'] = newname
66    for aname in lookup.keys():
67       data = out_data[aname]
68       newname = lookup[aname]
69       data.name = newname
70       out_data[aname] = data
71    app.model.context.flush()
72
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。