Mercurial > repos > vandelj > giant_volcano_plot
annotate src/LIMMA_options.py @ 0:c9a38c1eadf1 draft
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
author | vandelj |
---|---|
date | Fri, 26 Jun 2020 09:45:41 -0400 |
parents | |
children |
rev | line source |
---|---|
0
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
1 import re |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
2 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
3 def get_column_names( file_path, toNotConsider=None, toNotConsiderBis=None): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
4 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
5 inputfile = open(file_path) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
6 firstLine = next(inputfile).strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
7 for i, field_component in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
8 if i!=0 and field_component!=toNotConsider and field_component!=toNotConsiderBis:#to squeeze the first column |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
9 options.append( ( field_component, field_component, False ) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
10 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
11 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
12 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
13 def get_row_names( file_path, factorName ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
14 inputfile = open(file_path) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
15 firstLine = next(inputfile).strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
16 iColumn=-1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
17 for i, field_component in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
18 if field_component==factorName:#to test |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
19 iColumn=i |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
20 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
21 if iColumn!=-1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
22 for nextLine in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
23 nextLine=nextLine.strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
24 if len(nextLine)>1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
25 if (nextLine[iColumn], nextLine[iColumn], False) not in options: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
26 options.append( (nextLine[iColumn], nextLine[iColumn], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
27 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
28 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
29 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
30 def get_row_names_interaction( file_path, factorNameA, factorNameB ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
31 inputfile = open(file_path) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
32 firstLine = next(inputfile).strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
33 iColumnA=-1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
34 iColumnB=-1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
35 for i, field_component in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
36 if field_component==factorNameA:#to test |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
37 iColumnA=i |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
38 if field_component==factorNameB:#to test |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
39 iColumnB=i |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
40 possibleValuesA=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
41 possibleValuesB=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
42 if iColumnA!=-1 and iColumnB!=-1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
43 for nextLine in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
44 nextLine=nextLine.strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
45 if len(nextLine)>1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
46 if nextLine[iColumnA] not in possibleValuesA: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
47 possibleValuesA.append(nextLine[iColumnA]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
48 if nextLine[iColumnB] not in possibleValuesB: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
49 possibleValuesB.append(nextLine[iColumnB]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
50 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
51 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
52 if len(possibleValuesA)>=1 and len(possibleValuesB)>=1 and possibleValuesA[0]!="None" and possibleValuesB[0]!="None": |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
53 for counterA in range(len(possibleValuesA)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
54 for counterB in range(len(possibleValuesB)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
55 options.append( (possibleValuesA[counterA]+"*"+possibleValuesB[counterB], possibleValuesA[counterA]+"*"+possibleValuesB[counterB], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
56 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
57 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
58 def get_comparisonsA( factorA, valuesA ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
59 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
60 formatValuesA=re.sub("(^\[u')|('\]$)","", str(valuesA)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
61 possibleValues=formatValuesA.split("', u'") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
62 if len(possibleValues)>=2: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
63 for counter in range(len(possibleValues)-1): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
64 for innerCounter in range(counter+1,len(possibleValues)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
65 options.append( (possibleValues[counter]+" - "+possibleValues[innerCounter], possibleValues[counter]+" - "+possibleValues[innerCounter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
66 options.append( (possibleValues[innerCounter]+" - "+possibleValues[counter], possibleValues[innerCounter]+" - "+possibleValues[counter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
67 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
68 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
69 def get_comparisonsAB(factorA, valuesA, factorB, valuesB, interaction): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
70 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
71 formatValuesA=re.sub("(^\[u')|('\]$)","", str(valuesA)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
72 possibleValuesA=formatValuesA.split("', u'") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
73 formatValuesB=re.sub("(^\[u')|('\]$)","", str(valuesB)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
74 possibleValuesB=formatValuesB.split("', u'") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
75 if str(interaction)=="False": |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
76 if len(possibleValuesA)>=2: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
77 for counter in range(len(possibleValuesA)-1): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
78 for innerCounter in range(counter+1,len(possibleValuesA)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
79 options.append( (possibleValuesA[counter]+" - "+possibleValuesA[innerCounter], possibleValuesA[counter]+" - "+possibleValuesA[innerCounter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
80 options.append( (possibleValuesA[innerCounter]+" - "+possibleValuesA[counter], possibleValuesA[innerCounter]+" - "+possibleValuesA[counter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
81 if len(possibleValuesB)>=2: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
82 for counter in range(len(possibleValuesB)-1): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
83 for innerCounter in range(counter+1,len(possibleValuesB)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
84 options.append( (possibleValuesB[counter]+" - "+possibleValuesB[innerCounter], possibleValuesB[counter]+" - "+possibleValuesB[innerCounter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
85 options.append( (possibleValuesB[innerCounter]+" - "+possibleValuesB[counter], possibleValuesB[innerCounter]+" - "+possibleValuesB[counter], False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
86 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
87 if len(possibleValuesA)>=1 and len(possibleValuesB)>=1 and possibleValuesA[0]!="None" and possibleValuesB[0]!="None": |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
88 for counterA in range(len(possibleValuesA)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
89 for innerCounterA in range(len(possibleValuesA)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
90 for counterB in range(len(possibleValuesB)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
91 for innerCounterB in range(len(possibleValuesB)): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
92 if not(counterA==innerCounterA and counterB==innerCounterB): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
93 options.append( ("("+possibleValuesA[counterA]+" * "+possibleValuesB[counterB]+") - ("+possibleValuesA[innerCounterA]+" * "+possibleValuesB[innerCounterB]+")","("+possibleValuesA[counterA]+" * "+possibleValuesB[counterB]+") - ("+possibleValuesA[innerCounterA]+" * "+possibleValuesB[innerCounterB]+")", False) ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
94 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
95 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
96 def get_row_names_allInteractions( file_path, factorSelected): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
97 formatFactors=re.sub("(^\[u')|('\]$)","", str(factorSelected)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
98 factorsList=formatFactors.split("', u'") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
99 iColumn=[None] * len(factorsList) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
100 valuesList=[None] * len(factorsList) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
101 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
102 inputfile = open(file_path) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
103 firstLine = next(inputfile).strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
104 for iField, fieldComponent in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
105 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
106 if fieldComponent==factorComponent: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
107 iColumn[iFactor]=iField |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
108 valuesList[iFactor]=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
109 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
110 for nextLine in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
111 nextLine=nextLine.strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
112 if len(nextLine)>1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
113 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
114 if nextLine[iColumn[iFactor]] not in valuesList[iFactor]: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
115 valuesList[iFactor].append(nextLine[iColumn[iFactor]]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
116 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
117 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
118 allCombinations=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
119 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
120 if iFactor==0: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
121 allCombinations=valuesList[iFactor] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
122 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
123 currentCombinations=allCombinations |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
124 allCombinations=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
125 for iValue, valueComponent in enumerate(valuesList[iFactor]): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
126 for iCombination, combination in enumerate(currentCombinations): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
127 allCombinations.append(combination+"*"+valueComponent) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
128 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
129 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
130 for iCombination, combination in enumerate(allCombinations): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
131 options.append((combination,combination,False)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
132 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
133 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
134 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
135 def get_allrow_names( file_path, factorSelected ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
136 formatFactors=re.sub("(^\[u')|('\]$)","", str(factorSelected)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
137 factorsList=formatFactors.split("', u'") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
138 iColumn=[None] * len(factorsList) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
139 valuesList=[None] * len(factorsList) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
140 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
141 inputfile = open(file_path) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
142 firstLine = next(inputfile).strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
143 for iField, fieldComponent in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
144 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
145 if fieldComponent==factorComponent: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
146 iColumn[iFactor]=iField |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
147 valuesList[iFactor]=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
148 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
149 for nextLine in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
150 nextLine=nextLine.strip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
151 if len(nextLine)>1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
152 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
153 if nextLine[iColumn[iFactor]] not in valuesList[iFactor]: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
154 valuesList[iFactor].append(nextLine[iColumn[iFactor]]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
155 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
156 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
157 allValues=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
158 for iFactor, factorComponent in enumerate(factorsList): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
159 for iValue, valueComponent in enumerate(valuesList[iFactor]): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
160 allValues.append(factorComponent+":"+valueComponent) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
161 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
162 options=[] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
163 for iValue, valueComponent in enumerate(allValues): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
164 options.append((valueComponent,valueComponent,False)) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
165 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
166 return options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
167 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
168 def replaceNamesInFiles(expressionFile_name,conditionFile_name,outputExpressionFile,outputConditionFile,ouputDictionnary): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
169 dico={} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
170 forbidenCharacters={"*",":",",","|"} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
171 ##start with expression file, read only the first line |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
172 inputfile = open(expressionFile_name) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
173 outputfile = open(outputExpressionFile, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
174 firstLine = next(inputfile).rstrip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
175 iCondition=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
176 newFirstLine="" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
177 for i, field_component in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
178 if (i>0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
179 #conditions names should not be redundant with other conditions |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
180 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
181 dico[field_component]="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
182 newFirstLine+="\t"+"Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
183 iCondition+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
184 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
185 raise NameError('condition name allready exists!') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
186 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
187 newFirstLine+=field_component |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
188 outputfile.write(newFirstLine+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
189 for line in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
190 outputfile.write(line) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
191 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
192 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
193 #then parse condition file, read all lines in this case |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
194 inputfile = open(conditionFile_name) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
195 outputfile = open(outputConditionFile, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
196 firstLine=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
197 iFactor=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
198 iValue=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
199 for line in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
200 currentLine = line.rstrip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
201 newCurrentLine="" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
202 for i, field_component in enumerate( currentLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
203 #special treatment for the first line |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
204 if (firstLine==1): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
205 if (i==0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
206 newCurrentLine=field_component |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
207 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
208 #factor names should not be redundant with other factors or conditions |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
209 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
210 dico[field_component]="Factor"+str(iFactor) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
211 newCurrentLine+="\t"+"Factor"+str(iFactor) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
212 iFactor+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
213 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
214 raise NameError('factor name allready exists!') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
215 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
216 if (i==0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
217 #check if condition name allready exist and used it if it is, or create a new one if not |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
218 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
219 dico[field_component]="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
220 newCurrentLine="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
221 iCondition+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
222 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
223 newCurrentLine=dico[field_component] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
224 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
225 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
226 dico[field_component]="Value"+str(iValue) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
227 newCurrentLine+="\tValue"+str(iValue) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
228 iValue+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
229 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
230 newCurrentLine+="\t"+dico[field_component] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
231 outputfile.write(newCurrentLine+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
232 firstLine=0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
233 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
234 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
235 ##check if any entries in dictionnary contains forbiden character |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
236 for key, value in dico.items(): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
237 for specialCharacter in forbidenCharacters: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
238 if value.startswith("Condition")==False and key.find(specialCharacter)!=-1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
239 return 1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
240 ##then write dictionnary in a additional file |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
241 outputfile = open(ouputDictionnary, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
242 for key, value in dico.items(): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
243 outputfile.write(key+"\t"+value+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
244 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
245 return 0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
246 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
247 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
248 def replaceNamesBlockInFiles(expressionFile_name,conditionFile_name,blockingFile_name,outputExpressionFile,outputConditionFile,outputBlockingFile,ouputDictionnary): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
249 dico={} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
250 forbidenCharacters={"*",":",",","|"} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
251 ##start with expression file, read only the first line |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
252 inputfile = open(expressionFile_name) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
253 outputfile = open(outputExpressionFile, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
254 firstLine = next(inputfile).rstrip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
255 iCondition=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
256 newFirstLine="" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
257 for i, field_component in enumerate( firstLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
258 if (i>0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
259 #conditions names should not be redundant with other conditions |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
260 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
261 dico[field_component]="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
262 newFirstLine+="\t"+"Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
263 iCondition+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
264 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
265 raise NameError('condition name allready exists!') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
266 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
267 newFirstLine+=field_component |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
268 outputfile.write(newFirstLine+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
269 for line in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
270 outputfile.write(line) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
271 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
272 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
273 #then parse condition file, read all lines in this case |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
274 iFactor=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
275 iValue=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
276 for fileNum in range(2): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
277 if fileNum==0: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
278 inputfile = open(conditionFile_name) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
279 outputfile = open(outputConditionFile, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
280 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
281 inputfile = open(blockingFile_name) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
282 outputfile = open(outputBlockingFile, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
283 firstLine=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
284 for line in inputfile: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
285 currentLine = line.rstrip().split("\t") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
286 newCurrentLine="" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
287 for i, field_component in enumerate( currentLine ): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
288 #special treatment for the first line |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
289 if (firstLine==1): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
290 if (i==0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
291 newCurrentLine=field_component |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
292 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
293 #factor names should not be redundant with other factors or conditions |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
294 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
295 dico[field_component]="Factor"+str(iFactor) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
296 newCurrentLine+="\t"+"Factor"+str(iFactor) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
297 iFactor+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
298 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
299 raise NameError('factor name allready exists!') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
300 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
301 if (i==0): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
302 #check if condition name allready exist and used it if it is, or create a new one if not |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
303 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
304 dico[field_component]="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
305 newCurrentLine="Condition"+str(iCondition) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
306 iCondition+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
307 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
308 newCurrentLine=dico[field_component] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
309 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
310 if(field_component not in dico): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
311 dico[field_component]="Value"+str(iValue) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
312 newCurrentLine+="\tValue"+str(iValue) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
313 iValue+=1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
314 else: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
315 newCurrentLine+="\t"+dico[field_component] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
316 outputfile.write(newCurrentLine+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
317 firstLine=0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
318 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
319 inputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
320 ##check if any entries in dictionnary contains forbiden character |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
321 for key, value in dico.items(): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
322 for specialCharacter in forbidenCharacters: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
323 if value.startswith("Condition")==False and key.find(specialCharacter)!=-1: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
324 return 1 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
325 ##then write dictionnary in a additional file |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
326 outputfile = open(ouputDictionnary, 'w') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
327 for key, value in dico.items(): |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
328 outputfile.write(key+"\t"+value+"\n") |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
329 outputfile.close() |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
330 return 0 |