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

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

number of issues fixed in UI

File size: 9.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");
[547]17
[527]18%>
[526]19
20<html>
21
22<head>
23
[528]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">
[526]27
[528]28<script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script>
[526]29<script language="JavaScript" type="text/javascript">
[529]30
31//submits form
32function submit()
33{
[530]34  gatherValues();
35  document.mappings.submit();
[529]36}
37
38
39function getRoot()
40{
41  return '/base/';
42}
43
44function getScale()
45{
46  return 1.0;
47}
[530]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
52function gatherValues()
53{
[531]54  var fileList = '';
55  var subjectList = '';
56  var tissueList = '';
[530]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;
[531]63    if(id.match("fileInput"))
[530]64    {
[531]65      fileList += frm.elements[i].value + '\t';
[530]66    }
[531]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    }
[547]75    if(id.match("combinationInput"))
76    {
77      combinationList += frm.elements[i].value + '\t';
78    }
[530]79  }
[531]80  frm.fileList.value = fileList;
81  frm.subjectList.value = subjectList;
82  frm.tissueList.value = tissueList;
[547]83  frm.combinationList.value = combinationList;
[530]84}
85
[526]86</script>
[527]87
[526]88</head>
89
90<body>
91
[528]92
93
[543]94<form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post">
[528]95
96<input type="hidden" name="ID" value="<%=ID%>"> 
[529]97<input type="hidden" name="cmd" value="SetParameters"> 
[530]98<input type="hidden" name="requestId" value="<%=requestId%>"> 
[528]99
[532]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""/>
[547]103<input type="hidden" id="combinationList" name="combinationList" value""/>
[528]104
105
[531]106
[526]107<%
108  //first extract the factor names and the possible values
[528]109  String expFactors = inputDataBean.getExpFactors().trim();
[527]110  String[] rawFactors = expFactors.split("\n");
[526]111
[527]112  String[][] factorValues = new String[rawFactors.length][];
113  String[] factorNames = new String[rawFactors.length];
[526]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("("));
[527]119    factorNames[i] = factorName;
[526]120    //extract the possible values from between the parentheses
[528]121    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
122        rawFactors[i].indexOf(")"));
[526]123    String[] values = allValues.split(",");
[527]124    factorValues[i] = values;
125  }
[526]126
[528]127  //here we get hold of the cartesian product of all the factor values
[527]128  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
[528]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 
[532]133  String zipFilePath = inputDataBean.getPath();
134  System.out.println("zipFilePath = " + zipFilePath);
[528]135  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
[547]136  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/") + 1);
[528]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  }
[547]152
153  String[] fileNamesArr = new String[fileNames.size()];
[528]154  fileNames.toArray(fileNamesArr);
155  Arrays.sort(fileNamesArr);
[547]156
[528]157  dc.close();
[547]158
[531]159  //next get the subjectNames and make up select boxes with these
160  //they too have to be mapped to filenames
[547]161  String[] subjectNames = inputDataBean.getSubjectNames().split("\n");
162
[531]163  //we also need to parse out the tissues string to produce another column of select boxes
[547]164  String[] tissueNames = inputDataBean.getTissues().split("\n");
165
[544]166  //work out the number of hybridizations
167  int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates());
[547]168  int numTreatmentGroups = Integer.parseInt(inputDataBean.getNumTreatmentGroups());
[544]169  int numTissues = inputDataBean.getTissues().split("\n").length;
[547]170  int numHybs = Tab2MageWriter.calcNumHybs(numReplicates, numTreatmentGroups, numTissues);
[544]171  System.out.println("numHybs = " + numHybs);
172  System.out.println("products.length = " + products.length);
[526]173%>
174
[532]175<h1>Tab2MAGE Import Wizard -- File Mappings</h1>
[528]176<p>
[526]177
[528]178The table below holds a list of all possible factor value combinations used in your experiment.
[531]179Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
[526]180
[528]181<!-- this table holds the combinations of factor values -->
[526]182
[528]183<table align="center" cellpadding="15">
[526]184
[528]185  <!-- column header row factor names -->
[526]186
[528]187  <tr>
188
189    <!-- file selector header -->
190    <td class="header"><h3>File</h3></td>
[531]191    <td class="header"><h3>Subject</h3></td>
192    <td class="header"><h3>Tissue</h3></td>
[547]193    <td class="header"><h3>Factor Value Combination</h3></td>
[528]194
195  </tr>
196
197  <!-- now add as many rows as we have discrete combinations of factor values -->
198
[527]199  <%
[544]200    for (int i = 0; i < numHybs; i++)
[527]201    {
202  %>
[526]203
204  <tr>
205
[528]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
[531]208    <td class="input" ><select id="fileInput<%=i %>">
[528]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>
[531]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-->
[528]222
[531]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
[547]251<!-- need a single cell with a select box that lets the user select from a list of unique factor value combinations -->
[526]252
[547]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      %>
[527]266
[547]267      <option><%=combi%></option>
268
269      <%
270      }
271      %>
272    </select>
273    </td>
274
[526]275  </tr>
276
[527]277  <%
278  }
279  %>
[526]280
281</table>
[528]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
[529]294
295
[526]296</body>
297</html>
Note: See TracBrowser for help on using the repository browser.