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 | <html> |
---|
20 | |
---|
21 | <head> |
---|
22 | |
---|
23 | <link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" /> |
---|
24 | <link rel="stylesheet" type="text/css" href="/base/include/styles/main.css"> |
---|
25 | <link rel="stylesheet" type="text/css" href="/base/include/styles/size_m.css"> |
---|
26 | |
---|
27 | <script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script> |
---|
28 | <script language="JavaScript" type="text/javascript"> |
---|
29 | |
---|
30 | //submits form |
---|
31 | function submit() |
---|
32 | { |
---|
33 | gatherValues(); |
---|
34 | document.mappings.submit(); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | function getRoot() |
---|
39 | { |
---|
40 | return '/base/'; |
---|
41 | } |
---|
42 | |
---|
43 | function getScale() |
---|
44 | { |
---|
45 | return 1.0; |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | //collects all the values from the file selector boxes and strings them together so they can be |
---|
50 | //passed on as a single parameter for plugin configuration |
---|
51 | function gatherValues() |
---|
52 | { |
---|
53 | var fileList = ''; |
---|
54 | var subjectList = ''; |
---|
55 | var tissueList = ''; |
---|
56 | var dyeList = ''; |
---|
57 | var combinationList = ''; |
---|
58 | var frm = document.forms['mappings']; |
---|
59 | var numElements = frm.elements.length; |
---|
60 | for(var i = 0; i < numElements; i++) |
---|
61 | { |
---|
62 | var value = frm.elements[i].value; |
---|
63 | var id = frm.elements[i].id; |
---|
64 | if(id.match("fileInput")) |
---|
65 | { |
---|
66 | fileList += frm.elements[i].value + '\t'; |
---|
67 | } |
---|
68 | if(id.match("subjectInput")) |
---|
69 | { |
---|
70 | subjectList += frm.elements[i].value + '\t'; |
---|
71 | } |
---|
72 | if(id.match("tissueInput")) |
---|
73 | { |
---|
74 | tissueList += frm.elements[i].value + '\t'; |
---|
75 | } |
---|
76 | if(id.match("dyeInput")) |
---|
77 | { |
---|
78 | dyeList += frm.elements[i].value + '\t'; |
---|
79 | } |
---|
80 | if(id.match("combinationInput")) |
---|
81 | { |
---|
82 | combinationList += frm.elements[i].value + '\t'; |
---|
83 | } |
---|
84 | } |
---|
85 | frm.fileList.value = fileList; |
---|
86 | frm.subjectList.value = subjectList; |
---|
87 | frm.tissueList.value = tissueList; |
---|
88 | frm.dyeList.value = dyeList; |
---|
89 | frm.combinationList.value = combinationList; |
---|
90 | } |
---|
91 | |
---|
92 | </script> |
---|
93 | |
---|
94 | </head> |
---|
95 | |
---|
96 | <body> |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | <form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post"> |
---|
101 | |
---|
102 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
103 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
104 | <input type="hidden" name="requestId" value="<%=requestId%>"> |
---|
105 | |
---|
106 | <input type="hidden" id="fileList" name="fileList" value""/> |
---|
107 | <input type="hidden" id="subjectList" name="subjectList" value""/> |
---|
108 | <input type="hidden" id="tissueList" name="tissueList" value""/> |
---|
109 | <input type="hidden" id="dyeList" name="dyeList" value""/> |
---|
110 | <input type="hidden" id="combinationList" name="combinationList" value""/> |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | <% |
---|
115 | //first extract the factor names and the possible values |
---|
116 | String expFactors = inputDataBean.getExpFactors().trim(); |
---|
117 | String[] rawFactors = expFactors.split("\n"); |
---|
118 | |
---|
119 | String[][] factorValues = new String[rawFactors.length][]; |
---|
120 | String[] factorNames = new String[rawFactors.length]; |
---|
121 | |
---|
122 | for (int i = 0; i < rawFactors.length; i++) |
---|
123 | { |
---|
124 | //extract the factor name |
---|
125 | String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("(")); |
---|
126 | factorNames[i] = factorName; |
---|
127 | //extract the possible values from between the parentheses |
---|
128 | String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1, |
---|
129 | rawFactors[i].indexOf(")")); |
---|
130 | String[] values = allValues.split(","); |
---|
131 | factorValues[i] = values; |
---|
132 | } |
---|
133 | |
---|
134 | //here we get hold of the cartesian product of all the factor values |
---|
135 | String[][] products = CartesianProduct.getCartesianProduct(factorValues); |
---|
136 | |
---|
137 | //now inspect the content of the zip file and list all the individual files therein |
---|
138 | |
---|
139 | //first parse the filepath from the input page |
---|
140 | String zipFilePath = inputDataBean.getPath(); |
---|
141 | System.out.println("zipFilePath = " + zipFilePath); |
---|
142 | String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/")); |
---|
143 | String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/") + 1); |
---|
144 | |
---|
145 | //get hold of the appropriate BASE objects for this |
---|
146 | DbControl dc = sc.newDbControl(); |
---|
147 | Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY)); |
---|
148 | File zipFile = File.getFile(dc, zipFileDir, zipFileName, false); |
---|
149 | |
---|
150 | //now inspect the file content and store the names in the List |
---|
151 | Vector<String> fileNames = new Vector<String>(); |
---|
152 | ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0)); |
---|
153 | ZipEntry entry = zipStream.getNextEntry(); |
---|
154 | while (entry != null) |
---|
155 | { |
---|
156 | fileNames.add(entry.getName()); |
---|
157 | entry = zipStream.getNextEntry(); |
---|
158 | } |
---|
159 | |
---|
160 | String[] fileNamesArr = new String[fileNames.size()]; |
---|
161 | fileNames.toArray(fileNamesArr); |
---|
162 | Arrays.sort(fileNamesArr); |
---|
163 | |
---|
164 | dc.close(); |
---|
165 | |
---|
166 | //next get the subjectNames and make up select boxes with these |
---|
167 | //they too have to be mapped to filenames |
---|
168 | String[] subjectNames = inputDataBean.getSubjectNames().split("\n"); |
---|
169 | |
---|
170 | //we also need to parse out the tissues string to produce another column of select boxes |
---|
171 | String[] tissueNames = inputDataBean.getTissues().split("\n"); |
---|
172 | |
---|
173 | //work out the number of hybridizations |
---|
174 | String platform = inputDataBean.getPlatform(); |
---|
175 | //work out whether this is a single or dual channel experiment |
---|
176 | boolean singleChannel = false; |
---|
177 | if (platform.equalsIgnoreCase("affymetrix")) |
---|
178 | { |
---|
179 | singleChannel = true; |
---|
180 | } |
---|
181 | int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates()); |
---|
182 | int numTreatmentGroups = Integer.parseInt(inputDataBean.getNumTreatmentGroups()); |
---|
183 | int numTissues = inputDataBean.getTissues().split("\n").length; |
---|
184 | boolean dyeSwapBool = false; |
---|
185 | boolean poolingBool = false; |
---|
186 | if(inputDataBean.getDyeSwap().equals("yes")) |
---|
187 | { |
---|
188 | dyeSwapBool = true; |
---|
189 | } |
---|
190 | if(inputDataBean.getPooling().equals("yes")) |
---|
191 | { |
---|
192 | poolingBool = true; |
---|
193 | } |
---|
194 | |
---|
195 | int numHybs = Tab2MageUtils.calcNumHybs(dyeSwapBool,poolingBool,Integer.parseInt(inputDataBean.getNumDesigns()), numReplicates, numTreatmentGroups,numTissues); |
---|
196 | |
---|
197 | System.out.println("numHybs = " + numHybs); |
---|
198 | System.out.println("products.length = " + products.length); |
---|
199 | %> |
---|
200 | |
---|
201 | <h2>Tab2MAGE Import Wizard -- File Mappings</h2> |
---|
202 | <p> |
---|
203 | |
---|
204 | The table below allows you to configure your hybridizations as combinations of a subject/sample, tissue and factor values, and to then map them |
---|
205 | against a file name that corresponds to the hybridization.. |
---|
206 | Please select, for each hybridization, the appropriate file, subject, tissue, factor value combination and -- where appropriate -- dye |
---|
207 | from the drop down menus.</p><p> |
---|
208 | |
---|
209 | <!-- this table holds the combination values--> |
---|
210 | |
---|
211 | <table align="center" cellpadding="15"> |
---|
212 | |
---|
213 | <!-- column header row factor names --> |
---|
214 | |
---|
215 | <tr> |
---|
216 | |
---|
217 | <!-- file selector header --> |
---|
218 | <td class="header"><h3>File</h3></td> |
---|
219 | <td class="header"><h3>Subject</h3></td> |
---|
220 | <td class="header"><h3>Tissue</h3></td> |
---|
221 | <% |
---|
222 | //don't need a dye selector for single channel expts -- only one dye used |
---|
223 | if(!singleChannel) |
---|
224 | { |
---|
225 | %> |
---|
226 | <td class="header"><h3>Dye</h3></td> |
---|
227 | <% |
---|
228 | } |
---|
229 | %> |
---|
230 | |
---|
231 | <td class="header"><h3>Factor Value Combination</h3></td> |
---|
232 | |
---|
233 | </tr> |
---|
234 | |
---|
235 | <!-- now add as many rows as we have discrete combinations of factor values --> |
---|
236 | |
---|
237 | <% |
---|
238 | for (int i = 0; i < numHybs; i++) |
---|
239 | { |
---|
240 | %> |
---|
241 | |
---|
242 | <tr> |
---|
243 | |
---|
244 | <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values--> |
---|
245 | |
---|
246 | <td class="input" ><select id="fileInput<%=i %>"> |
---|
247 | <% |
---|
248 | for (int k = 0; k < fileNamesArr.length; k++) |
---|
249 | { |
---|
250 | %> |
---|
251 | |
---|
252 | <option><%=fileNamesArr[k]%></option> |
---|
253 | |
---|
254 | <% |
---|
255 | } |
---|
256 | %> |
---|
257 | </select></td> |
---|
258 | |
---|
259 | <!-- next we need a cell with a drop down menu where we can select a subject name to match the combination of factor values--> |
---|
260 | |
---|
261 | <td class="input" ><select id="subjectInput<%=i %>"> |
---|
262 | <% |
---|
263 | for (int k = 0; k < subjectNames.length; k++) |
---|
264 | { |
---|
265 | %> |
---|
266 | |
---|
267 | <option><%=subjectNames[k]%></option> |
---|
268 | |
---|
269 | <% |
---|
270 | } |
---|
271 | %> |
---|
272 | </select></td> |
---|
273 | |
---|
274 | <!-- next we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values--> |
---|
275 | |
---|
276 | <td class="input" ><select id="tissueInput<%=i %>"> |
---|
277 | <% |
---|
278 | for (int k = 0; k < tissueNames.length; k++) |
---|
279 | { |
---|
280 | %> |
---|
281 | |
---|
282 | <option><%=tissueNames[k]%></option> |
---|
283 | |
---|
284 | <% |
---|
285 | } |
---|
286 | %> |
---|
287 | </select></td> |
---|
288 | |
---|
289 | <% |
---|
290 | //don't need a dye selector for single channel expts -- only one dye used |
---|
291 | if(!singleChannel) |
---|
292 | { |
---|
293 | %> |
---|
294 | <!-- select your dye here--> |
---|
295 | |
---|
296 | <td class="input"><select id="dyeInput<%=i %>"> |
---|
297 | <% |
---|
298 | if (!singleChannel) |
---|
299 | { |
---|
300 | %> |
---|
301 | <option>Cy3</option> |
---|
302 | <option>Cy5</option> |
---|
303 | <% |
---|
304 | } |
---|
305 | else |
---|
306 | { |
---|
307 | %> |
---|
308 | <option>biotin</option> |
---|
309 | <% |
---|
310 | } |
---|
311 | %> |
---|
312 | |
---|
313 | </select></td> |
---|
314 | <% |
---|
315 | } %> |
---|
316 | |
---|
317 | <!-- need a single cell with a select box that lets the user select from a list of unique factor value combinations --> |
---|
318 | |
---|
319 | <td> |
---|
320 | <select id="combinationInput<%=i %>"> |
---|
321 | <% |
---|
322 | for (int k = 0; k < products.length; k++) |
---|
323 | { |
---|
324 | //make a String with all the factor values in this combination |
---|
325 | //separate values in each combi with a space |
---|
326 | String combi = ""; |
---|
327 | for (int j = 0; j < products[k].length; j++) |
---|
328 | { |
---|
329 | combi += products[k][j] + " "; |
---|
330 | } |
---|
331 | %> |
---|
332 | |
---|
333 | <option><%=combi%></option> |
---|
334 | |
---|
335 | <% |
---|
336 | } |
---|
337 | %> |
---|
338 | </select> |
---|
339 | </td> |
---|
340 | |
---|
341 | </tr> |
---|
342 | |
---|
343 | <% |
---|
344 | } |
---|
345 | %> |
---|
346 | |
---|
347 | </table> |
---|
348 | |
---|
349 | <p> |
---|
350 | |
---|
351 | <table align="center" class="noBorder" cellspacing="5" cellpadding="5"> |
---|
352 | <tr class="noBorder"> |
---|
353 | <td id="back" style="border-style: none;"><div class="buttons" onmouseover="this.className='buttons_hover';" onmouseout="this.className='buttons';" onclick="back()"><div class="buttons_inner"><table class="noBorder" cellspacing="0" cellpadding="0"><tr class="noBorder"><td style="border-style: none;"><img src="/base/images/goback.gif" border="0"></td><td style="border-style: none;">Back</td></tr></table></div></div></td> |
---|
354 | <td id="next" 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;">Next</td></tr></table></div></div></td> |
---|
355 | <td id="close" 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> |
---|
356 | </tr> |
---|
357 | </table> |
---|
358 | |
---|
359 | |
---|
360 | </form> |
---|
361 | |
---|
362 | |
---|
363 | |
---|
364 | </body> |
---|
365 | </html> |
---|