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
RevLine 
[528]1<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
[526]2<%@ page import="java.util.*"%>
[528]3<%@ page import="java.util.zip.*"%>
[526]4<%@ page import="net.sf.basedb.core.*"%>
5<%@ page import="net.sf.basedb.clients.web.*"%>
6<%@ page import="net.sf.basedb.util.*"%>
[527]7<%@ page import="uk.ac.ebi.nugo.plugins.*"%>
[526]8
[532]9<jsp:useBean id="inputDataBean" class="uk.ac.ebi.nugo.plugins.DataBean" scope="session" />
[526]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<%
[527]14  final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
15  final String ID = sc.getId();
[530]16  final String requestId = request.getParameter("requestId");
[527]17%>
[526]18
19<html>
20
21<head>
22
[528]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">
[526]26
[528]27<script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script>
[526]28<script language="JavaScript" type="text/javascript">
[529]29
30//submits form
31function submit()
32{
[530]33  gatherValues();
34  document.mappings.submit();
[529]35}
36
37
38function getRoot()
39{
40  return '/base/';
41}
42
43function getScale()
44{
45  return 1.0;
46}
[530]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{
[531]53  var fileList = '';
54  var subjectList = '';
55  var tissueList = '';
[530]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;
[531]62    if(id.match("fileInput"))
[530]63    {
[531]64      fileList += frm.elements[i].value + '\t';
[530]65    }
[531]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    }
[550]74    if(id.match("dyeInput"))
75    {
76      dyeList += frm.elements[i].value + '\t';
77    }
[547]78    if(id.match("combinationInput"))
79    {
80      combinationList += frm.elements[i].value + '\t';
81    }
[530]82  }
[531]83  frm.fileList.value = fileList;
84  frm.subjectList.value = subjectList;
85  frm.tissueList.value = tissueList;
[550]86  frm.dyeList.value = dyeList;
[547]87  frm.combinationList.value = combinationList;
[530]88}
89
[526]90</script>
[527]91
[526]92</head>
93
94<body>
95
[528]96
97
[543]98<form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post">
[528]99
100<input type="hidden" name="ID" value="<%=ID%>"> 
[529]101<input type="hidden" name="cmd" value="SetParameters"> 
[530]102<input type="hidden" name="requestId" value="<%=requestId%>"> 
[528]103
[532]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""/>
[550]107<input type="hidden" id="dyeList" name="dyeList" value""/>
[547]108<input type="hidden" id="combinationList" name="combinationList" value""/>
[528]109
110
[531]111
[526]112<%
113  //first extract the factor names and the possible values
[528]114  String expFactors = inputDataBean.getExpFactors().trim();
[527]115  String[] rawFactors = expFactors.split("\n");
[526]116
[527]117  String[][] factorValues = new String[rawFactors.length][];
118  String[] factorNames = new String[rawFactors.length];
[526]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("("));
[527]124    factorNames[i] = factorName;
[526]125    //extract the possible values from between the parentheses
[528]126    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
[550]127    rawFactors[i].indexOf(")"));
[526]128    String[] values = allValues.split(",");
[527]129    factorValues[i] = values;
130  }
[526]131
[528]132  //here we get hold of the cartesian product of all the factor values
[527]133  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
[528]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 
[532]138  String zipFilePath = inputDataBean.getPath();
139  System.out.println("zipFilePath = " + zipFilePath);
[528]140  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
[547]141  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/") + 1);
[528]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  }
[547]157
158  String[] fileNamesArr = new String[fileNames.size()];
[528]159  fileNames.toArray(fileNamesArr);
160  Arrays.sort(fileNamesArr);
[547]161
[528]162  dc.close();
[547]163
[531]164  //next get the subjectNames and make up select boxes with these
165  //they too have to be mapped to filenames
[547]166  String[] subjectNames = inputDataBean.getSubjectNames().split("\n");
167
[531]168  //we also need to parse out the tissues string to produce another column of select boxes
[547]169  String[] tissueNames = inputDataBean.getTissues().split("\n");
170
[544]171  //work out the number of hybridizations
[548]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;
[550]178  }
[544]179  int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates());
[547]180  int numTreatmentGroups = Integer.parseInt(inputDataBean.getNumTreatmentGroups());
[544]181  int numTissues = inputDataBean.getTissues().split("\n").length;
[550]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
[544]195  System.out.println("numHybs = " + numHybs);
196  System.out.println("products.length = " + products.length);
[526]197%>
198
[550]199<h2>Tab2MAGE Import Wizard -- File Mappings</h2>
[528]200<p>
[526]201
[528]202The table below holds a list of all possible factor value combinations used in your experiment.
[531]203Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
[526]204
[528]205<!-- this table holds the combinations of factor values -->
[526]206
[528]207<table align="center" cellpadding="15">
[526]208
[528]209  <!-- column header row factor names -->
[526]210
[528]211  <tr>
212
213    <!-- file selector header -->
214    <td class="header"><h3>File</h3></td>
[531]215    <td class="header"><h3>Subject</h3></td>
216    <td class="header"><h3>Tissue</h3></td>
[550]217    <td class="header"><h3>Dye</h3></td>
[547]218    <td class="header"><h3>Factor Value Combination</h3></td>
[528]219
220  </tr>
221
222  <!-- now add as many rows as we have discrete combinations of factor values -->
223
[527]224  <%
[550]225      for (int i = 0; i < numHybs; i++)
226      {
[527]227  %>
[526]228
229  <tr>
230
[528]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
[531]233    <td class="input" ><select id="fileInput<%=i %>">
[528]234      <%
[550]235            for (int k = 0; k < fileNamesArr.length; k++)
236            {
[528]237      %>
238
239      <option><%=fileNamesArr[k]%></option>
240
241      <%
242      }
243      %>
244    </select></td>
[531]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-->
[528]247
[531]248    <td class="input" ><select id="subjectInput<%=i %>">
249      <%
[550]250            for (int k = 0; k < subjectNames.length; k++)
251            {
[531]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      <%
[550]265            for (int k = 0; k < tissueNames.length; k++)
266            {
[531]267      %>
268
269      <option><%=tissueNames[k]%></option>
270
271      <%
272      }
273      %>
274    </select></td>
275
[550]276    <!-- select your dye here-->
[526]277
[550]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
[547]299    <td>
300    <select id="combinationInput<%=i %>">
301      <%
[550]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++)
[547]308          {
[550]309            combi += products[k][j] + " ";
310          }
[547]311      %>
[527]312
[547]313      <option><%=combi%></option>
314
315      <%
316      }
317      %>
318    </select>
319    </td>
320
[526]321  </tr>
322
[527]323  <%
324  }
325  %>
[526]326
327</table>
[528]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
[529]340
341
[526]342</body>
343</html>
Note: See TracBrowser for help on using the repository browser.