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

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

file mappings now filter through into tab2mage file but still have to implement two channel arrays

File size: 11.6 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 fileString = '';
54  var frm = document.forms['mappings'];
55  var numElements = frm.elements.length;
56  //document.write(numElements);
57  //document.write("<br />");
58  for(var i = 0; i < numElements; i++)
59  {
60    var value = frm.elements[i].value;
61    var id = frm.elements[i].id;
62
63    if(id.match("fileinput"))
64    {
65      //document.write("id = " + id);
66      //document.write("<br />");
67      //document.write("value = " + value);
68      //document.write("<br />");
69      fileString += frm.elements[i].value + '\t';
70    }
71  }
72  //document.write('combined output = ' + fileString);
73  frm.fileStringParam.value = fileString;
74  //document.write('value of hidden input = ' + frm.fileStringParam.value);
75}
76
77</script>
78
79</head>
80
81<body>
82
83
84
85<form name="mappings" action="<%= request.getContextPath()%>/common/plugin/index.jsp" method="post">
86
87<input type="hidden" name="ID" value="<%=ID%>"> 
88<input type="hidden" name="cmd" value="SetParameters"> 
89<input type="hidden" name="requestId" value="<%=requestId%>"> 
90<input type="hidden" id="fileStringParam" name="parameter:fileStringParam" value""/>
91
92<!-- 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 -->
93
94<!-- inputs from experiment.jsp page -->
95<input type="hidden" name="parameter:domain" value="<%=inputDataBean.getDomain()%>">
96<input type="hidden" name="parameter:accession" value="<%=inputDataBean.getAccession()%>">
97<input type="hidden" name="parameter:qualityControl" value="<%=inputDataBean.getQualityControl()%>">
98<input type="hidden" name="parameter:experimentalDesign" value="<%=inputDataBean.getExperimentalDesign()%>">
99<input type="hidden" name="parameter:experimentName" value="<%=inputDataBean.getExperimentName()%>">
100<input type="hidden" name="parameter:description" value="<%=inputDataBean.getDescription()%>">
101<input type="hidden" name="parameter:releaseDate" value="<%=inputDataBean.getReleaseDate()%>">
102<input type="hidden" name="parameter:submissionDate" value="<%=inputDataBean.getSubmissionDate()%>">
103<input type="hidden" name="parameter:submitter" value="<%=inputDataBean.getSubmitter()%>">
104<input type="hidden" name="parameter:organization" value="<%=inputDataBean.getOrganization()%>">
105<input type="hidden" name="parameter:publicationTitle" value="<%=inputDataBean.getPublicationTitle()%>">
106<input type="hidden" name="parameter:authors" value="<%=inputDataBean.getAuthors()%>">
107<input type="hidden" name="parameter:journal" value="<%=inputDataBean.getJournal()%>">
108<input type="hidden" name="parameter:volume" value="<%=inputDataBean.getVolume()%>">
109<input type="hidden" name="parameter:issue" value="<%=inputDataBean.getIssue()%>">
110<input type="hidden" name="parameter:pages" value="<%=inputDataBean.getPages()%>">
111<input type="hidden" name="parameter:year" value="<%=inputDataBean.getYear()%>">
112<input type="hidden" name="parameter:pubmedId" value="<%=inputDataBean.getPubmedId()%>">
113<input type="hidden" name="parameter:experimentId" value="<%=inputDataBean.getExperimentId()%>">
114<!-- inputs from protocols.jsp page -->
115<input type="hidden" name="parameter:treatmentProtocol" value="<%=inputDataBean.getTreatmentProtocol()%>">
116<input type="hidden" name="parameter:extractionProtocol" value="<%=inputDataBean.getExtractionProtocol()%>">
117<input type="hidden" name="parameter:labelingProtocol" value="<%=inputDataBean.getLabelingProtocol()%>">
118<input type="hidden" name="parameter:hybridizationProtocol" value="<%=inputDataBean.getHybridizationProtocol()%>">
119<input type="hidden" name="parameter:scanningProtocol" value="<%=inputDataBean.getScanningProtocol()%>">
120<input type="hidden" name="parameter:treatmentProtocolParams" value="<%=inputDataBean.getTreatmentProtocolParams()%>">
121<input type="hidden" name="parameter:extractionProtocolParams" value="<%=inputDataBean.getExtractionProtocolParams()%>">
122<input type="hidden" name="parameter:labelingProtocolParams" value="<%=inputDataBean.getLabelingProtocolParams()%>">
123<input type="hidden" name="parameter:hybridizationProtocolParams" value="<%=inputDataBean.getHybridizationProtocolParams()%>">
124<input type="hidden" name="parameter:scanningProtocolParams" value="<%=inputDataBean.getScanningProtocolParams()%>">
125<!-- inputs from hybridizations.jsp page -->
126<input type="hidden" name="parameter:platform" value="<%=inputDataBean.getPlatform()%>">
127<input type="hidden" name="parameter:organism" value="<%=inputDataBean.getOrganism()%>">
128<input type="hidden" name="parameter:numDesigns" value="<%=inputDataBean.getNumDesigns()%>">
129<input type="hidden" name="parameter:dyeSwap" value="<%=inputDataBean.getDyeSwap()%>">
130<input type="hidden" name="parameter:refSample" value="<%=inputDataBean.getRefSample()%>">
131<input type="hidden" name="parameter:numTreatmentGroups" value="<%=inputDataBean.getNumTreatmentGroups()%>">
132<input type="hidden" name="parameter:expFactors" value="<%=inputDataBean.getExpFactors()%>">
133<input type="hidden" name="parameter:numReplicates" value="<%=inputDataBean.getNumReplicates()%>">
134<input type="hidden" name="parameter:tissues" value="<%=inputDataBean.getTissues()%>">
135<input type="hidden" name="parameter:pooling" value="<%=inputDataBean.getPooling()%>">
136<input type="hidden" name="parameter:zipFile" value="<%=request.getParameter("path") %>" id="zipFile">
137
138<%
139  System.out.println("all parameter values for mappings.jsp:");
140  for (java.util.Enumeration e = request.getParameterNames(); e.hasMoreElements();)
141  {
142    String name = (String) e.nextElement();
143    String value = request.getParameter(name);
144    System.out.println("parameter " + name + " = " + value);
145  }
146
147  //first extract the factor names and the possible values
148  String expFactors = inputDataBean.getExpFactors().trim();
149  String[] rawFactors = expFactors.split("\n");
150
151  String[][] factorValues = new String[rawFactors.length][];
152  String[] factorNames = new String[rawFactors.length];
153
154  for (int i = 0; i < rawFactors.length; i++)
155  {
156    //extract the factor name
157    String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("("));
158    factorNames[i] = factorName;
159    //extract the possible values from between the parentheses
160    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
161        rawFactors[i].indexOf(")"));
162    String[] values = allValues.split(",");
163    factorValues[i] = values;
164  }
165
166  //here we get hold of the cartesian product of all the factor values
167  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
168
169  //now inspect the content of the zip file and list all the individual files therein
170
171  //first parse the filepath from the input page 
172  String zipFilePath = (String) request.getParameter("path");
173  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
174  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/")+1);
175
176  //get hold of the appropriate BASE objects for this
177  DbControl dc = sc.newDbControl();
178  Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY));
179  File zipFile = File.getFile(dc, zipFileDir, zipFileName, false);
180
181  //now inspect the file content and store the names in the List
182  Vector<String> fileNames = new Vector<String>();
183  ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0));
184  ZipEntry entry = zipStream.getNextEntry();
185  while (entry != null)
186  {
187    fileNames.add(entry.getName());
188    entry = zipStream.getNextEntry();
189  }
190 
191  String [] fileNamesArr = new String[fileNames.size()];
192  fileNames.toArray(fileNamesArr);
193  Arrays.sort(fileNamesArr);
194 
195  dc.close();
196%>
197
198<h1>Tab2MAGE Importer -- File Mappings</h1>
199Page 4 of 4
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 name 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
216    <!-- factor names -->
217    <%
218      for (int i = 0; i < products[i].length; i++)
219      {
220    %>
221    <td class="header"><h3><%=factorNames[i]%></h3></td>
222    <%
223    }
224    %>
225  </tr>
226
227  <!-- now add as many rows as we have discrete combinations of factor values -->
228
229  <%
230    for (int i = 0; i < products.length; i++)
231    {
232  %>
233
234  <tr>
235
236    <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values-->
237
238    <td class="input" ><select id="fileinput<%=i %>">
239      <%
240          for (int k = 0; k < fileNamesArr.length; k++)
241          {
242      %>
243
244      <option><%=fileNamesArr[k]%></option>
245
246      <%
247      }
248      %>
249    </select></td>
250
251<!-- now print the values of this factor value combination, each in a separate cell -->
252    <%
253        for (int j = 0; j < products[i].length; j++)
254        {
255    %>
256    <td class="border"><%=products[i][j]%></td>
257    <%
258    }
259    %>
260
261
262  </tr>
263
264  <%
265  }
266  %>
267
268</table>
269
270<p>
271
272  <table align="center" class="noBorder" cellspacing="5"  cellpadding="5">
273  <tr class="noBorder">
274    <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>
275    <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>
276  </table>
277
278
279</form>
280
281
282
283</body>
284</html>
Note: See TracBrowser for help on using the repository browser.