Mercurial > repos > vandelj > giant_gsea_format
annotate src/General_functions.py @ 0:3022feec50fe draft
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
author | vandelj |
---|---|
date | Fri, 26 Jun 2020 09:36:46 -0400 |
parents | |
children | d72f1bc5ce9e |
rev | line source |
---|---|
0
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
1 import re |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
2 import numpy as np |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
3 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
5 options=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
6 inputfile = open(file_path) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
7 firstLine = next(inputfile).strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
8 cpt=0 |
3022feec50fe
"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 ): |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
11 if cpt==0: |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
13 cpt+=1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
14 if cpt==each: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
15 cpt=0 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
16 inputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
17 return options |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
18 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
20 options=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
21 inputfile = open(file_path) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
22 firstLine = next(inputfile).strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
23 cpt=0 |
3022feec50fe
"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 ): |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
26 if cpt==0: |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
28 cpt+=1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
29 if cpt==each: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
30 cpt=0 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
31 inputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
32 return options |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
33 |
3022feec50fe
"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=[]): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
35 options=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
36 inputfile = open(file_path) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
37 if int(numberToMerge)>0: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
38 iHeader=0 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
39 for iCurrentLine in inputfile: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
40 iHeader=iHeader+1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
41 if iHeader>int(numberToMerge): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
42 break |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
43 currentLine=iCurrentLine.strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
44 iOption=-1 |
3022feec50fe
"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 ): |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
47 iOption=iOption+1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
48 if iHeader==1: |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
50 else: |
3022feec50fe
"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) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
52 else: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
53 currentLine = next(inputfile).strip().split("\t") |
3022feec50fe
"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 ): |
3022feec50fe
"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 |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
57 inputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
58 return options |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
59 |
3022feec50fe
"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 ): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
61 inputfile = open(file_path) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
62 firstLine = next(inputfile).strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
63 iColumn=-1 |
3022feec50fe
"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 ): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
65 if field_component==factorName:#to test |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
66 iColumn=i |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
67 options=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
68 if iColumn!=-1: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
69 for nextLine in inputfile: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
70 nextLine=nextLine.strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
71 if len(nextLine)>1: |
3022feec50fe
"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: |
3022feec50fe
"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) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
74 inputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
75 return options |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
76 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
78 options=[] |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
80 inputfile = open(file_list.file_name) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
81 firstLine = next(inputfile).strip().split("\t") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
82 cpt=0 |
3022feec50fe
"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 ): |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
85 if cpt==0: |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
87 cpt+=1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
88 if cpt==each: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
89 cpt=0 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
90 inputfile.close() |
3022feec50fe
"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 |
3022feec50fe
"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 |
3022feec50fe
"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 ): |
3022feec50fe
"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 ) ) |
3022feec50fe
"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 |
3022feec50fe
"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 ): |
3022feec50fe
"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 ) ) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
98 return options |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
99 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
101 forbidenCharacters={"*",":",",","|"} |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
102 outputfile = open(outputFileName, 'w') |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
103 outputLog = open(logFile, 'w') |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
104 sampleList=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
105 if not isinstance(file_list,list): |
3022feec50fe
"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) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
107 else : |
3022feec50fe
"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 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
110 sampleList.append(str(sample_component[1])) |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
112 globalDict=dict() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
113 factorNameList=[] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
114 firstLine="Conditions" |
3022feec50fe
"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 |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
117 return 1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
118 else: |
3022feec50fe
"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 ): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
120 currentSampleList=list(sampleList) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
121 currentFactor=str(factor_component['factorName']) |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
123 for specialCharacter in forbidenCharacters: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
124 if currentFactor.find(specialCharacter)!=-1: |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
126 return 4 |
3022feec50fe
"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 |
3022feec50fe
"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: |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
130 return 3 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
131 globalDict[currentFactor]=dict() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
132 firstLine=firstLine+"\t"+currentFactor |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
133 factorNameList.append(currentFactor) |
3022feec50fe
"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 |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
136 return 1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
137 else: |
3022feec50fe
"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'] ): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
139 currentValue=str(value_component['valueName']) |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
141 for specialCharacter in forbidenCharacters: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
142 if currentValue.find(specialCharacter)!=-1: |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
144 return 4 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
145 currentSample=str(value_component['valueConditions']).split(",") |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
147 if not sample_component in currentSampleList: |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
149 return 2 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
150 currentSampleList.remove(sample_component) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
151 globalDict[currentFactor][sample_component]=currentValue |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
152 if(len(currentSampleList)>0): |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
154 return 2 |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
156 #start writing the factor file |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
157 outputfile.write(firstLine+"\n") |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
159 newLine=sample_component |
3022feec50fe
"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): |
3022feec50fe
"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] |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
162 outputfile.write(newLine+"\n") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
163 outputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
164 outputLog.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
165 return 0 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
166 |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
168 outputLog = open(logFile, 'w') |
3022feec50fe
"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") |
3022feec50fe
"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) |
3022feec50fe
"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 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
172 availableColumns=[] |
3022feec50fe
"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): |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
174 availableColumns.append(str(tuple_content[0])) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
175 if len(availableColumns)==0: |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
177 return 1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
178 selectedColumns=list(columnsToAdd) |
3022feec50fe
"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): |
3022feec50fe
"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'])) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
181 if volcano_content['fdrColumn'] in availableColumns: |
3022feec50fe
"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'])) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
183 else: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
184 selectedColumns.append(0) |
3022feec50fe
"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'])) |
3022feec50fe
"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)): |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
188 return 1 |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
190 #start writting formatted file |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
191 inputfile = open(file_path) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
192 outputfile = open(outputFileName, 'w') |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
193 iLineCpt=-1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
194 for iCurrentLine in inputfile: |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
195 iLineCpt=iLineCpt+1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
196 if iLineCpt>=int(headerLine_number): |
3022feec50fe
"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")) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
198 newLine="\t".join(currentLineFields[selectedColumns]) |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
199 outputfile.write(newLine+"\n") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
200 if iLineCpt<int(headerLine_number): |
3022feec50fe
"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") |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
202 return 1 |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
203 inputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
204 outputfile.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
205 outputLog.close() |
3022feec50fe
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
206 return 0 |