source: branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/mappings.jsp @ 550

Last change on this file since 550 was 550, checked in by mbayer, 13 years ago

have restructured the code completely that writes the hybs section

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