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

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

had to add in ability for user to configure subject names and tissues against filenames and factors too - this implemented in UI now
also restructured code in writer class and test class

File size: 12.9 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="application" />
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  }
75  frm.fileList.value = fileList;
76  frm.subjectList.value = subjectList;
77  frm.tissueList.value = tissueList;
78}
79
80</script>
81
82</head>
83
84<body>
85
86
87
88<form name="mappings" action="<%= request.getContextPath()%>/common/plugin/index.jsp" method="post">
89
90<input type="hidden" name="ID" value="<%=ID%>"> 
91<input type="hidden" name="cmd" value="SetParameters"> 
92<input type="hidden" name="requestId" value="<%=requestId%>"> 
93<input type="hidden" id="fileList" name="parameter:fileList" value""/>
94<input type="hidden" id="subjectList" name="parameter:subjectList" value""/>
95<input type="hidden" id="tissueList" name="parameter:tissueList" value""/>
96
97<!-- these are the parameters from the previous input pages; need to pick them up individually from the bean here; ugly as hell but can't be done any other way -->
98
99<!-- inputs from experiment.jsp page -->
100<input type="hidden" name="parameter:domain" value="<%=inputDataBean.getDomain()%>">
101<input type="hidden" name="parameter:accession" value="<%=inputDataBean.getAccession()%>">
102<input type="hidden" name="parameter:qualityControl" value="<%=inputDataBean.getQualityControl()%>">
103<input type="hidden" name="parameter:experimentalDesign" value="<%=inputDataBean.getExperimentalDesign()%>">
104<input type="hidden" name="parameter:experimentName" value="<%=inputDataBean.getExperimentName()%>">
105<input type="hidden" name="parameter:description" value="<%=inputDataBean.getDescription()%>">
106<input type="hidden" name="parameter:releaseDate" value="<%=inputDataBean.getReleaseDate()%>">
107<input type="hidden" name="parameter:submissionDate" value="<%=inputDataBean.getSubmissionDate()%>">
108<input type="hidden" name="parameter:submitter" value="<%=inputDataBean.getSubmitter()%>">
109<input type="hidden" name="parameter:organization" value="<%=inputDataBean.getOrganization()%>">
110<input type="hidden" name="parameter:publicationTitle" value="<%=inputDataBean.getPublicationTitle()%>">
111<input type="hidden" name="parameter:authors" value="<%=inputDataBean.getAuthors()%>">
112<input type="hidden" name="parameter:journal" value="<%=inputDataBean.getJournal()%>">
113<input type="hidden" name="parameter:volume" value="<%=inputDataBean.getVolume()%>">
114<input type="hidden" name="parameter:issue" value="<%=inputDataBean.getIssue()%>">
115<input type="hidden" name="parameter:pages" value="<%=inputDataBean.getPages()%>">
116<input type="hidden" name="parameter:year" value="<%=inputDataBean.getYear()%>">
117<input type="hidden" name="parameter:pubmedId" value="<%=inputDataBean.getPubmedId()%>">
118<input type="hidden" name="parameter:experimentId" value="<%=inputDataBean.getExperimentId()%>">
119<!-- inputs from protocols.jsp page -->
120<input type="hidden" name="parameter:treatmentProtocol" value="<%=inputDataBean.getTreatmentProtocol()%>">
121<input type="hidden" name="parameter:extractionProtocol" value="<%=inputDataBean.getExtractionProtocol()%>">
122<input type="hidden" name="parameter:labelingProtocol" value="<%=inputDataBean.getLabelingProtocol()%>">
123<input type="hidden" name="parameter:hybridizationProtocol" value="<%=inputDataBean.getHybridizationProtocol()%>">
124<input type="hidden" name="parameter:scanningProtocol" value="<%=inputDataBean.getScanningProtocol()%>">
125<input type="hidden" name="parameter:treatmentProtocolParams" value="<%=inputDataBean.getTreatmentProtocolParams()%>">
126<input type="hidden" name="parameter:extractionProtocolParams" value="<%=inputDataBean.getExtractionProtocolParams()%>">
127<input type="hidden" name="parameter:labelingProtocolParams" value="<%=inputDataBean.getLabelingProtocolParams()%>">
128<input type="hidden" name="parameter:hybridizationProtocolParams" value="<%=inputDataBean.getHybridizationProtocolParams()%>">
129<input type="hidden" name="parameter:scanningProtocolParams" value="<%=inputDataBean.getScanningProtocolParams()%>">
130<!-- inputs from hybridizations.jsp page -->
131<input type="hidden" name="parameter:platform" value="<%=inputDataBean.getPlatform()%>">
132<input type="hidden" name="parameter:organism" value="<%=inputDataBean.getOrganism()%>">
133<input type="hidden" name="parameter:numDesigns" value="<%=inputDataBean.getNumDesigns()%>">
134<input type="hidden" name="parameter:dyeSwap" value="<%=inputDataBean.getDyeSwap()%>">
135<input type="hidden" name="parameter:refSample" value="<%=inputDataBean.getRefSample()%>">
136<input type="hidden" name="parameter:numTreatmentGroups" value="<%=inputDataBean.getNumTreatmentGroups()%>">
137<input type="hidden" name="parameter:expFactors" value="<%=inputDataBean.getExpFactors()%>">
138<input type="hidden" name="parameter:numReplicates" value="<%=inputDataBean.getNumReplicates()%>">
139<input type="hidden" name="parameter:tissues" value="<%=inputDataBean.getTissues()%>">
140<input type="hidden" name="parameter:pooling" value="<%=inputDataBean.getPooling()%>">
141<input type="hidden" name="parameter:zipFile" value="<%=request.getParameter("path") %>" id="zipFile">
142<input type="hidden" name="parameter:subjectNames" value="<%=inputDataBean.getSubjectNames()%>">
143
144
145<%
146  System.out.println("all parameter values for mappings.jsp:");
147  for (java.util.Enumeration e = request.getParameterNames(); e.hasMoreElements();)
148  {
149    String name = (String) e.nextElement();
150    String value = request.getParameter(name);
151    System.out.println("parameter " + name + " = " + value);
152  }
153
154  //first extract the factor names and the possible values
155  String expFactors = inputDataBean.getExpFactors().trim();
156  String[] rawFactors = expFactors.split("\n");
157
158  String[][] factorValues = new String[rawFactors.length][];
159  String[] factorNames = new String[rawFactors.length];
160
161  for (int i = 0; i < rawFactors.length; i++)
162  {
163    //extract the factor name
164    String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("("));
165    factorNames[i] = factorName;
166    //extract the possible values from between the parentheses
167    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
168        rawFactors[i].indexOf(")"));
169    String[] values = allValues.split(",");
170    factorValues[i] = values;
171  }
172
173  //here we get hold of the cartesian product of all the factor values
174  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
175
176  //now inspect the content of the zip file and list all the individual files therein
177
178  //first parse the filepath from the input page 
179  String zipFilePath = (String) request.getParameter("path");
180  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
181  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/")+1);
182
183  //get hold of the appropriate BASE objects for this
184  DbControl dc = sc.newDbControl();
185  Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY));
186  File zipFile = File.getFile(dc, zipFileDir, zipFileName, false);
187
188  //now inspect the file content and store the names in the List
189  Vector<String> fileNames = new Vector<String>();
190  ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0));
191  ZipEntry entry = zipStream.getNextEntry();
192  while (entry != null)
193  {
194    fileNames.add(entry.getName());
195    entry = zipStream.getNextEntry();
196  }
197 
198  String [] fileNamesArr = new String[fileNames.size()];
199  fileNames.toArray(fileNamesArr);
200  Arrays.sort(fileNamesArr);
201 
202  dc.close();
203 
204  //next get the subjectNames and make up select boxes with these
205  //they too have to be mapped to filenames
206  String [] subjectNames = request.getParameter("subjectNames").split("\n");
207 
208  //we also need to parse out the tissues string to produce another column of select boxes
209  String [] tissueNames = request.getParameter("tissues").split("\n");
210%>
211
212<h1>Tab2MAGE Importer -- File Mappings</h1>
213Page 4 of 4
214<p>
215
216The table below holds a list of all possible factor value combinations used in your experiment.
217Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
218
219<!-- this table holds the combinations of factor values -->
220
221<table align="center" cellpadding="15">
222
223  <!-- column header row factor names -->
224
225  <tr>
226
227    <!-- file selector header -->
228    <td class="header"><h3>File</h3></td>
229    <td class="header"><h3>Subject</h3></td>
230    <td class="header"><h3>Tissue</h3></td>
231
232    <!-- factor names -->
233    <%
234      for (int i = 0; i < products[i].length; i++)
235      {
236    %>
237    <td class="header"><h3><%=factorNames[i]%></h3></td>
238    <%
239    }
240    %>
241  </tr>
242
243  <!-- now add as many rows as we have discrete combinations of factor values -->
244
245  <%
246    for (int i = 0; i < products.length; i++)
247    {
248  %>
249
250  <tr>
251
252    <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values-->
253
254    <td class="input" ><select id="fileInput<%=i %>">
255      <%
256          for (int k = 0; k < fileNamesArr.length; k++)
257          {
258      %>
259
260      <option><%=fileNamesArr[k]%></option>
261
262      <%
263      }
264      %>
265    </select></td>
266   
267    <!-- next  we need a cell with a drop down menu where we can select a subject name to match the combination of factor values-->
268
269    <td class="input" ><select id="subjectInput<%=i %>">
270      <%
271          for (int k = 0; k < subjectNames.length; k++)
272          {
273      %>
274
275      <option><%=subjectNames[k]%></option>
276
277      <%
278      }
279      %>
280    </select></td>
281   
282    <!-- next  we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values-->
283
284    <td class="input" ><select id="tissueInput<%=i %>">
285      <%
286          for (int k = 0; k < tissueNames.length; k++)
287          {
288      %>
289
290      <option><%=tissueNames[k]%></option>
291
292      <%
293      }
294      %>
295    </select></td>
296
297<!-- now print the values of this factor value combination, each in a separate cell -->
298    <%
299        for (int j = 0; j < products[i].length; j++)
300        {
301    %>
302    <td class="border"><%=products[i][j]%></td>
303    <%
304    }
305    %>
306
307
308  </tr>
309
310  <%
311  }
312  %>
313
314</table>
315
316<p>
317
318  <table align="center" class="noBorder" cellspacing="5"  cellpadding="5">
319  <tr class="noBorder">
320    <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>
321    <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>
322  </table>
323
324
325</form>
326
327
328
329</body>
330</html>
Note: See TracBrowser for help on using the repository browser.