annotate tools/rgenetics/rgQQ_code.py @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 # before running the qc, need to rename various output files
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 # <data format="html" name="html_file" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 # <data format="txt" name="log_file" parent="html_file" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 # <data format="tabular" name="marker_file" parent="html_file" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 # <data format="tabular" name="subject_file" parent="html_file" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 from galaxy import datatypes,model
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 import sys,string
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 def get_columns( input ):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 columns = []
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 elems = []
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 if input and input.metadata.columns:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 ncols = input.metadata.columns
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 colnames = ['Col%d' % x for x in range(1,ncols+1)]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 for i, line in enumerate( file ( input.file_name ) ):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 valid = True
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 if line and not line.startswith( '#' ):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 line = line.rstrip('\r\n')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 elems = line.split( '\t' )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 Since this tool requires users to select only those columns
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 that contain numerical values, we'll restrict the column select
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 list appropriately.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 if len(elems) > 0:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 for col in range(len(elems)): # zero offset
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 if i == 0: # header row
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 colnames[col] = elems[col]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 else:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 val = elems[col]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 try:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 val = float(val)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 valid = True
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 except:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 valid = False
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 if valid:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 option = colnames[col]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 columns.append((option,str(col),False))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 if len(columns) > 0:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 We have our select list built, so we can break out of the outer most for loop
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 break
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 if i == 30:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 break # Hopefully we never get here...
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 else:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 columns = [('?','?',False),]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 return columns