Mercurial > repos > vandelj > giant_factor_generator
annotate src/General_functions.py @ 0:4764dc6a1019 draft
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
author | vandelj |
---|---|
date | Fri, 26 Jun 2020 09:51:15 -0400 |
parents | |
children | 7a520f7169e1 |
rev | line source |
---|---|
0
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
1 import re |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
2 import numpy as np |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
3 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
4 def get_column_names( file_path, toNotConsider=-1, each=1): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
5 options=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
6 inputfile = open(file_path) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
7 firstLine = next(inputfile).strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
8 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
9 for i, field_component in enumerate( firstLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
10 if i!=toNotConsider:#to squeeze the first column |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
11 if cpt==0: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
12 options.append( ( field_component, field_component, False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
13 cpt+=1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
14 if cpt==each: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
15 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
16 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
17 return options |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
18 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
19 def get_column_names_filteredList( file_path, toNotConsider=[], each=1): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
20 options=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
21 inputfile = open(file_path) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
22 firstLine = next(inputfile).strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
23 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
24 for i, field_component in enumerate( firstLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
25 if i not in toNotConsider:#to squeeze the first columns |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
26 if cpt==0: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
27 options.append( ( field_component, field_component, False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
28 cpt+=1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
29 if cpt==each: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
30 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
31 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
32 return options |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
33 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
34 def get_column_names_mergeNumber(file_path, numberToMerge=1, toNotConsider=[]): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
35 options=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
36 inputfile = open(file_path) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
37 if int(numberToMerge)>0: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
38 iHeader=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
39 for iCurrentLine in inputfile: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
40 iHeader=iHeader+1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
41 if iHeader>int(numberToMerge): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
42 break |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
43 currentLine=iCurrentLine.strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
44 iOption=-1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
45 for i, field_component in enumerate( currentLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
46 if i not in toNotConsider:#to squeeze specified columns |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
47 iOption=iOption+1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
48 if iHeader==1: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
49 options.append( ( str(field_component), str(field_component), False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
50 else: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
51 options[iOption]=(options[iOption][0]+"_"+str(field_component),options[iOption][1]+"_"+str(field_component),False) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
52 else: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
53 currentLine = next(inputfile).strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
54 for i, field_component in enumerate( currentLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
55 if i not in toNotConsider:#to squeeze specified columns |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
56 options.append( ( "Column_"+str(i), "Column_"+str(i), False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
57 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
58 return options |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
59 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
60 def get_row_names( file_path, factorName ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
61 inputfile = open(file_path) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
62 firstLine = next(inputfile).strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
63 iColumn=-1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
64 for i, field_component in enumerate( firstLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
65 if field_component==factorName:#to test |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
66 iColumn=i |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
67 options=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
68 if iColumn!=-1: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
69 for nextLine in inputfile: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
70 nextLine=nextLine.strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
71 if len(nextLine)>1: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
72 if (nextLine[iColumn], nextLine[iColumn], False) not in options: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
73 options.append( (nextLine[iColumn], nextLine[iColumn], False) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
74 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
75 return options |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
76 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
77 def get_condition_file_names( file_list, toNotConsider=-1, each=1): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
78 options=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
79 if not isinstance(file_list,list):#if input file is a tabular file, act as get_column_names |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
80 inputfile = open(file_list.file_name) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
81 firstLine = next(inputfile).strip().split("\t") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
82 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
83 for i, field_component in enumerate( firstLine ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
84 if i!=toNotConsider:#to squeeze the first column |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
85 if cpt==0: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
86 options.append( ( field_component, field_component, False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
87 cpt+=1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
88 if cpt==each: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
89 cpt=0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
90 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
91 else:#if input file is a .cel file list or a collection |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
92 if not hasattr(file_list[0],'collection'):#if it is not a collection, get name easily |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
93 for i, field_component in enumerate( file_list ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
94 options.append( ( field_component.name, field_component.name, False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
95 else:#if the file is a collection, have to get deeper in the corresponding HistoryDatasetCollectionAssociation object |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
96 for i, field_component in enumerate( file_list[0].collection.elements ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
97 options.append( ( field_component.element_identifier, field_component.element_identifier, False ) ) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
98 return options |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
99 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
100 def generateFactorFile( file_list, factor_list, outputFileName, logFile): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
101 forbidenCharacters={"*",":",",","|"} |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
102 outputfile = open(outputFileName, 'w') |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
103 outputLog = open(logFile, 'w') |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
104 sampleList=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
105 if not isinstance(file_list,list): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
106 conditionNames=get_condition_file_names(file_list,0) #unique expression file, remove the first column (index=0) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
107 else : |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
108 conditionNames=get_condition_file_names(file_list) #.CEL files |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
109 for iSample, sample_component in enumerate (conditionNames): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
110 sampleList.append(str(sample_component[1])) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
111 outputLog.write("[INFO] "+str(len(sampleList))+" sample are detected as input\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
112 globalDict=dict() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
113 factorNameList=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
114 firstLine="Conditions" |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
115 if len(factor_list)==0:#check if there is at least one factor available |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
116 outputLog.write("[ERROR] no factor was defined !\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
117 return 1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
118 else: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
119 for iFactor, factor_component in enumerate( factor_list ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
120 currentSampleList=list(sampleList) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
121 currentFactor=str(factor_component['factorName']) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
122 #check if factor name contains forbidden characters |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
123 for specialCharacter in forbidenCharacters: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
124 if currentFactor.find(specialCharacter)!=-1: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
125 outputLog.write("[ERROR] '"+specialCharacter+"' character is forbidden in factor name : '"+currentFactor+"'\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
126 return 4 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
127 #check if factor allready named like that |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
128 if not globalDict.get(currentFactor) is None: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
129 outputLog.write("[ERROR] '"+currentFactor+"' is used several times as factor name\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
130 return 3 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
131 globalDict[currentFactor]=dict() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
132 firstLine=firstLine+"\t"+currentFactor |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
133 factorNameList.append(currentFactor) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
134 if len(factor_component['valueList'])<=1:#check if there is at least two value available |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
135 outputLog.write("[ERROR] at least two different values are necessary for '"+currentFactor+"' factor\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
136 return 1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
137 else: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
138 for iValue, value_component in enumerate( factor_component['valueList'] ): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
139 currentValue=str(value_component['valueName']) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
140 #check if factor name contains forbidden characters |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
141 for specialCharacter in forbidenCharacters: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
142 if currentValue.find(specialCharacter)!=-1: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
143 outputLog.write("[ERROR] '"+specialCharacter+"' character is forbidden in value name : '"+currentValue+"'\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
144 return 4 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
145 currentSample=str(value_component['valueConditions']).split(",") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
146 for iSample, sample_component in enumerate (currentSample): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
147 if not sample_component in currentSampleList: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
148 outputLog.write("[ERROR] sample "+sample_component+" was assigned several times for factor '"+currentFactor+"'\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
149 return 2 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
150 currentSampleList.remove(sample_component) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
151 globalDict[currentFactor][sample_component]=currentValue |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
152 if(len(currentSampleList)>0): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
153 outputLog.write("[ERROR] for factor '"+currentFactor+"'' sample "+str(currentSampleList)+" are not assigned to any value\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
154 return 2 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
155 outputLog.write("[INFO] "+str(len(globalDict))+" factors are detected\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
156 #start writing the factor file |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
157 outputfile.write(firstLine+"\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
158 for iSample, sample_component in enumerate(sampleList): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
159 newLine=sample_component |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
160 for iFactor, factor_component in enumerate(factorNameList): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
161 newLine=newLine+"\t"+globalDict[factor_component][sample_component] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
162 outputfile.write(newLine+"\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
163 outputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
164 outputLog.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
165 return 0 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
166 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
167 def selectSubSetTable(file_path,headerLine_number,columnsToAdd,columnNamesToKeep,outputFileName,logFile): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
168 outputLog = open(logFile, 'w') |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
169 outputLog.write("[INFO] header line number : "+ headerLine_number+" lines\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
170 availableColumnsTuple=get_column_names_mergeNumber(file_path, headerLine_number) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
171 #convert tuple list as a simple array |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
172 availableColumns=[] |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
173 for iTuple, tuple_content in enumerate (availableColumnsTuple): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
174 availableColumns.append(str(tuple_content[0])) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
175 if len(availableColumns)==0: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
176 outputLog.write("[ERROR] No detected columns in input file\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
177 return 1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
178 selectedColumns=list(columnsToAdd) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
179 for iVolcano, volcano_content in enumerate(columnNamesToKeep): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
180 selectedColumns.append(availableColumns.index(volcano_content['pvalColumn'])) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
181 if volcano_content['fdrColumn'] in availableColumns: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
182 selectedColumns.append(availableColumns.index(volcano_content['fdrColumn'])) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
183 else: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
184 selectedColumns.append(0) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
185 selectedColumns.append(availableColumns.index(volcano_content['fcColumn'])) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
186 if len(selectedColumns)!=(3*len(columnNamesToKeep)+len(columnsToAdd)): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
187 outputLog.write("[ERROR] matching between input file colnames and requested column names failed\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
188 return 1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
189 outputLog.write("[INFO] columns kept : "+str(selectedColumns)+"\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
190 #start writting formatted file |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
191 inputfile = open(file_path) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
192 outputfile = open(outputFileName, 'w') |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
193 iLineCpt=-1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
194 for iCurrentLine in inputfile: |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
195 iLineCpt=iLineCpt+1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
196 if iLineCpt>=int(headerLine_number): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
197 currentLineFields=np.array(iCurrentLine.strip().split("\t")) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
198 newLine="\t".join(currentLineFields[selectedColumns]) |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
199 outputfile.write(newLine+"\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
200 if iLineCpt<int(headerLine_number): |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
201 outputLog.write("[ERROR] not enough lines in input files ("+(iLineCpt+1)+" lines)\n") |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
202 return 1 |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
203 inputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
204 outputfile.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
205 outputLog.close() |
4764dc6a1019
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
206 return 0 |