1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> |
---|
2 | <%@ page import="java.util.*"%> |
---|
3 | <%@ page import="java.util.zip.*"%> |
---|
4 | <%@ page import="net.sf.basedb.core.*"%> |
---|
5 | <%@ page import="net.sf.basedb.clients.web.*"%> |
---|
6 | <%@ page import="net.sf.basedb.util.*"%> |
---|
7 | <%@ page import="uk.ac.ebi.nugo.plugins.*"%> |
---|
8 | |
---|
9 | <jsp:useBean id="inputDataBean" class="uk.ac.ebi.nugo.plugins.DataBean" scope="session" /> |
---|
10 | <!-- submits the form data back to the bean assuming that each form element is matched to a variable in the bean by the same name --> |
---|
11 | <jsp:setProperty name="inputDataBean" property="*" /> |
---|
12 | |
---|
13 | <% |
---|
14 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
15 | final String ID = sc.getId(); |
---|
16 | final String requestId = request.getParameter("requestId"); |
---|
17 | |
---|
18 | %> |
---|
19 | |
---|
20 | <html> |
---|
21 | |
---|
22 | <head> |
---|
23 | |
---|
24 | <link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" /> |
---|
25 | <link rel="stylesheet" type="text/css" href="/base/include/styles/main.css"> |
---|
26 | <link rel="stylesheet" type="text/css" href="/base/include/styles/size_m.css"> |
---|
27 | |
---|
28 | <script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script> |
---|
29 | <script language="JavaScript" type="text/javascript"> |
---|
30 | |
---|
31 | //submits form |
---|
32 | function submit() |
---|
33 | { |
---|
34 | gatherValues(); |
---|
35 | document.mappings.submit(); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | function getRoot() |
---|
40 | { |
---|
41 | return '/base/'; |
---|
42 | } |
---|
43 | |
---|
44 | function getScale() |
---|
45 | { |
---|
46 | return 1.0; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | //collects all the values from the file selector boxes and strings them together so they can be |
---|
51 | //passed on as a single parameter for plugin configuration |
---|
52 | function gatherValues() |
---|
53 | { |
---|
54 | var fileList = ''; |
---|
55 | var subjectList = ''; |
---|
56 | var tissueList = ''; |
---|
57 | var frm = document.forms['mappings']; |
---|
58 | var numElements = frm.elements.length; |
---|
59 | for(var i = 0; i < numElements; i++) |
---|
60 | { |
---|
61 | var value = frm.elements[i].value; |
---|
62 | var id = frm.elements[i].id; |
---|
63 | if(id.match("fileInput")) |
---|
64 | { |
---|
65 | fileList += frm.elements[i].value + '\t'; |
---|
66 | } |
---|
67 | if(id.match("subjectInput")) |
---|
68 | { |
---|
69 | subjectList += frm.elements[i].value + '\t'; |
---|
70 | } |
---|
71 | if(id.match("tissueInput")) |
---|
72 | { |
---|
73 | tissueList += frm.elements[i].value + '\t'; |
---|
74 | } |
---|
75 | if(id.match("combinationInput")) |
---|
76 | { |
---|
77 | combinationList += frm.elements[i].value + '\t'; |
---|
78 | } |
---|
79 | } |
---|
80 | frm.fileList.value = fileList; |
---|
81 | frm.subjectList.value = subjectList; |
---|
82 | frm.tissueList.value = tissueList; |
---|
83 | frm.combinationList.value = combinationList; |
---|
84 | } |
---|
85 | |
---|
86 | </script> |
---|
87 | |
---|
88 | </head> |
---|
89 | |
---|
90 | <body> |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | <form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post"> |
---|
95 | |
---|
96 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
97 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
98 | <input type="hidden" name="requestId" value="<%=requestId%>"> |
---|
99 | |
---|
100 | <input type="hidden" id="fileList" name="fileList" value""/> |
---|
101 | <input type="hidden" id="subjectList" name="subjectList" value""/> |
---|
102 | <input type="hidden" id="tissueList" name="tissueList" value""/> |
---|
103 | <input type="hidden" id="combinationList" name="combinationList" value""/> |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | <% |
---|
108 | //first extract the factor names and the possible values |
---|
109 | String expFactors = inputDataBean.getExpFactors().trim(); |
---|
110 | String[] rawFactors = expFactors.split("\n"); |
---|
111 | |
---|
112 | String[][] factorValues = new String[rawFactors.length][]; |
---|
113 | String[] factorNames = new String[rawFactors.length]; |
---|
114 | |
---|
115 | for (int i = 0; i < rawFactors.length; i++) |
---|
116 | { |
---|
117 | //extract the factor name |
---|
118 | String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("(")); |
---|
119 | factorNames[i] = factorName; |
---|
120 | //extract the possible values from between the parentheses |
---|
121 | String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1, |
---|
122 | rawFactors[i].indexOf(")")); |
---|
123 | String[] values = allValues.split(","); |
---|
124 | factorValues[i] = values; |
---|
125 | } |
---|
126 | |
---|
127 | //here we get hold of the cartesian product of all the factor values |
---|
128 | String[][] products = CartesianProduct.getCartesianProduct(factorValues); |
---|
129 | |
---|
130 | //now inspect the content of the zip file and list all the individual files therein |
---|
131 | |
---|
132 | //first parse the filepath from the input page |
---|
133 | String zipFilePath = inputDataBean.getPath(); |
---|
134 | System.out.println("zipFilePath = " + zipFilePath); |
---|
135 | String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/")); |
---|
136 | String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/") + 1); |
---|
137 | |
---|
138 | //get hold of the appropriate BASE objects for this |
---|
139 | DbControl dc = sc.newDbControl(); |
---|
140 | Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY)); |
---|
141 | File zipFile = File.getFile(dc, zipFileDir, zipFileName, false); |
---|
142 | |
---|
143 | //now inspect the file content and store the names in the List |
---|
144 | Vector<String> fileNames = new Vector<String>(); |
---|
145 | ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0)); |
---|
146 | ZipEntry entry = zipStream.getNextEntry(); |
---|
147 | while (entry != null) |
---|
148 | { |
---|
149 | fileNames.add(entry.getName()); |
---|
150 | entry = zipStream.getNextEntry(); |
---|
151 | } |
---|
152 | |
---|
153 | String[] fileNamesArr = new String[fileNames.size()]; |
---|
154 | fileNames.toArray(fileNamesArr); |
---|
155 | Arrays.sort(fileNamesArr); |
---|
156 | |
---|
157 | dc.close(); |
---|
158 | |
---|
159 | //next get the subjectNames and make up select boxes with these |
---|
160 | //they too have to be mapped to filenames |
---|
161 | String[] subjectNames = inputDataBean.getSubjectNames().split("\n"); |
---|
162 | |
---|
163 | //we also need to parse out the tissues string to produce another column of select boxes |
---|
164 | String[] tissueNames = inputDataBean.getTissues().split("\n"); |
---|
165 | |
---|
166 | //work out the number of hybridizations |
---|
167 | int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates()); |
---|
168 | int numTreatmentGroups = Integer.parseInt(inputDataBean.getNumTreatmentGroups()); |
---|
169 | int numTissues = inputDataBean.getTissues().split("\n").length; |
---|
170 | int numHybs = Tab2MageWriter.calcNumHybs(numReplicates, numTreatmentGroups, numTissues); |
---|
171 | System.out.println("numHybs = " + numHybs); |
---|
172 | System.out.println("products.length = " + products.length); |
---|
173 | %> |
---|
174 | |
---|
175 | <h1>Tab2MAGE Import Wizard -- File Mappings</h1> |
---|
176 | <p> |
---|
177 | |
---|
178 | The table below holds a list of all possible factor value combinations used in your experiment. |
---|
179 | Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p> |
---|
180 | |
---|
181 | <!-- this table holds the combinations of factor values --> |
---|
182 | |
---|
183 | <table align="center" cellpadding="15"> |
---|
184 | |
---|
185 | <!-- column header row factor names --> |
---|
186 | |
---|
187 | <tr> |
---|
188 | |
---|
189 | <!-- file selector header --> |
---|
190 | <td class="header"><h3>File</h3></td> |
---|
191 | <td class="header"><h3>Subject</h3></td> |
---|
192 | <td class="header"><h3>Tissue</h3></td> |
---|
193 | <td class="header"><h3>Factor Value Combination</h3></td> |
---|
194 | |
---|
195 | </tr> |
---|
196 | |
---|
197 | <!-- now add as many rows as we have discrete combinations of factor values --> |
---|
198 | |
---|
199 | <% |
---|
200 | for (int i = 0; i < numHybs; i++) |
---|
201 | { |
---|
202 | %> |
---|
203 | |
---|
204 | <tr> |
---|
205 | |
---|
206 | <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values--> |
---|
207 | |
---|
208 | <td class="input" ><select id="fileInput<%=i %>"> |
---|
209 | <% |
---|
210 | for (int k = 0; k < fileNamesArr.length; k++) |
---|
211 | { |
---|
212 | %> |
---|
213 | |
---|
214 | <option><%=fileNamesArr[k]%></option> |
---|
215 | |
---|
216 | <% |
---|
217 | } |
---|
218 | %> |
---|
219 | </select></td> |
---|
220 | |
---|
221 | <!-- next we need a cell with a drop down menu where we can select a subject name to match the combination of factor values--> |
---|
222 | |
---|
223 | <td class="input" ><select id="subjectInput<%=i %>"> |
---|
224 | <% |
---|
225 | for (int k = 0; k < subjectNames.length; k++) |
---|
226 | { |
---|
227 | %> |
---|
228 | |
---|
229 | <option><%=subjectNames[k]%></option> |
---|
230 | |
---|
231 | <% |
---|
232 | } |
---|
233 | %> |
---|
234 | </select></td> |
---|
235 | |
---|
236 | <!-- next we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values--> |
---|
237 | |
---|
238 | <td class="input" ><select id="tissueInput<%=i %>"> |
---|
239 | <% |
---|
240 | for (int k = 0; k < tissueNames.length; k++) |
---|
241 | { |
---|
242 | %> |
---|
243 | |
---|
244 | <option><%=tissueNames[k]%></option> |
---|
245 | |
---|
246 | <% |
---|
247 | } |
---|
248 | %> |
---|
249 | </select></td> |
---|
250 | |
---|
251 | <!-- need a single cell with a select box that lets the user select from a list of unique factor value combinations --> |
---|
252 | |
---|
253 | <td> |
---|
254 | <select id="combinationInput<%=i %>"> |
---|
255 | <% |
---|
256 | for (int k = 0; k < products.length; k++) |
---|
257 | { |
---|
258 | //make a String with all the factor values in this combination |
---|
259 | //separate values in each combi with a space |
---|
260 | String combi = ""; |
---|
261 | for (int j = 0; j < products[k].length; j++) |
---|
262 | { |
---|
263 | combi += products[k][j] + " "; |
---|
264 | } |
---|
265 | %> |
---|
266 | |
---|
267 | <option><%=combi%></option> |
---|
268 | |
---|
269 | <% |
---|
270 | } |
---|
271 | %> |
---|
272 | </select> |
---|
273 | </td> |
---|
274 | |
---|
275 | </tr> |
---|
276 | |
---|
277 | <% |
---|
278 | } |
---|
279 | %> |
---|
280 | |
---|
281 | </table> |
---|
282 | |
---|
283 | <p> |
---|
284 | |
---|
285 | <table align="center" class="noBorder" cellspacing="5" cellpadding="5"> |
---|
286 | <tr class="noBorder"> |
---|
287 | <td id="next" width="50%" style="border-style: none;"><div class="buttons" onmouseover="this.className='buttons_hover';" onmouseout="this.className='buttons';" onclick="submit()"><div class="buttons_inner"><table class="noBorder" cellspacing="0" cellpadding="0"><tr class="noBorder"><td style="border-style: none;"><img src="/base/images/gonext.gif" border="0"></td><td style="border-style: none;">Start Import</td></tr></table></div></div></td> |
---|
288 | <td id="close" width="50%" style="border-style: none;"><div class="buttons" onmouseover="this.className='buttons_hover';" onmouseout="this.className='buttons';" onclick="window.close()"><div class="buttons_inner"><table class="noBorder" cellspacing="0" cellpadding="0"><tr class="noBorder"><td style="border-style: none;"><img src="/base/images/cancel.gif" border="0"></td><td style="border-style: none;">Cancel</td></tr></table></div></div></td> </tr> |
---|
289 | </table> |
---|
290 | |
---|
291 | |
---|
292 | </form> |
---|
293 | |
---|
294 | |
---|
295 | |
---|
296 | </body> |
---|
297 | </html> |
---|