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

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

submission with existing tab2mage file implemented

File size: 8.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="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  System.out.println("mappings.jsp: inputDataBean = " + inputDataBean.toString());
19  System.out.println("mappings.jsp: ID = " + ID);
20%>
21
22<html>
23
24<head>
25
26<link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" />
27<link rel="stylesheet" type="text/css" href="/base/include/styles/main.css">
28<link rel="stylesheet" type="text/css" href="/base/include/styles/size_m.css">
29
30<script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script>
31<script language="JavaScript" type="text/javascript">
32
33//submits form
34function submit()
35{
36  gatherValues();
37  document.mappings.submit();
38}
39
40
41function getRoot()
42{
43  return '/base/';
44}
45
46function getScale()
47{
48  return 1.0;
49}
50
51
52//collects all the values from the file selector boxes and strings them together so they can be
53//passed on as a single parameter for plugin configuration
54function gatherValues()
55{
56  var fileList = '';
57  var subjectList = '';
58  var tissueList = '';
59  var frm = document.forms['mappings'];
60  var numElements = frm.elements.length;
61  for(var i = 0; i < numElements; i++)
62  {
63    var value = frm.elements[i].value;
64    var id = frm.elements[i].id;
65    if(id.match("fileInput"))
66    {
67      fileList += frm.elements[i].value + '\t';
68    }
69    if(id.match("subjectInput"))
70    {
71      subjectList += frm.elements[i].value + '\t';
72    }
73    if(id.match("tissueInput"))
74    {
75      tissueList += frm.elements[i].value + '\t';
76    }
77  }
78  frm.fileList.value = fileList;
79  frm.subjectList.value = subjectList;
80  frm.tissueList.value = tissueList;
81}
82
83</script>
84
85</head>
86
87<body>
88
89
90
91<form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post">
92
93<input type="hidden" name="ID" value="<%=ID%>"> 
94<input type="hidden" name="cmd" value="SetParameters"> 
95<input type="hidden" name="requestId" value="<%=requestId%>"> 
96
97<input type="hidden" id="fileList" name="fileList" value""/>
98<input type="hidden" id="subjectList" name="subjectList" value""/>
99<input type="hidden" id="tissueList" name="tissueList" value""/>
100
101
102
103<%
104
105  //first extract the factor names and the possible values
106  String expFactors = inputDataBean.getExpFactors().trim();
107  String[] rawFactors = expFactors.split("\n");
108
109  String[][] factorValues = new String[rawFactors.length][];
110  String[] factorNames = new String[rawFactors.length];
111
112  for (int i = 0; i < rawFactors.length; i++)
113  {
114    //extract the factor name
115    String factorName = rawFactors[i].substring(0, rawFactors[i].indexOf("("));
116    factorNames[i] = factorName;
117    //extract the possible values from between the parentheses
118    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
119        rawFactors[i].indexOf(")"));
120    String[] values = allValues.split(",");
121    factorValues[i] = values;
122  }
123
124  //here we get hold of the cartesian product of all the factor values
125  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
126
127  //now inspect the content of the zip file and list all the individual files therein
128
129  //first parse the filepath from the input page 
130  String zipFilePath = inputDataBean.getPath();
131  System.out.println("zipFilePath = " + zipFilePath);
132  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
133  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/")+1);
134
135  //get hold of the appropriate BASE objects for this
136  DbControl dc = sc.newDbControl();
137  Directory zipFileDir = Directory.getByPath(dc, new Path(zipFileDirStr, Path.Type.DIRECTORY));
138  File zipFile = File.getFile(dc, zipFileDir, zipFileName, false);
139
140  //now inspect the file content and store the names in the List
141  Vector<String> fileNames = new Vector<String>();
142  ZipInputStream zipStream = new ZipInputStream(zipFile.getDownloadStream(0));
143  ZipEntry entry = zipStream.getNextEntry();
144  while (entry != null)
145  {
146    fileNames.add(entry.getName());
147    entry = zipStream.getNextEntry();
148  }
149 
150  String [] fileNamesArr = new String[fileNames.size()];
151  fileNames.toArray(fileNamesArr);
152  Arrays.sort(fileNamesArr);
153 
154  dc.close();
155 
156  //next get the subjectNames and make up select boxes with these
157  //they too have to be mapped to filenames
158  String [] subjectNames = inputDataBean.getSubjectNames().split("\n");
159 
160  //we also need to parse out the tissues string to produce another column of select boxes
161  String [] tissueNames = inputDataBean.getTissues().split("\n");
162 
163 
164  //work out the number of hybridizations
165  int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates());
166  int numTreatmentGroups =Integer.parseInt(inputDataBean.getNumTreatmentGroups());
167  int numTissues = inputDataBean.getTissues().split("\n").length;
168  int numHybs = Tab2MageWriter.calcNumHybs( numReplicates, numTreatmentGroups,  numTissues);
169  System.out.println("numHybs = " + numHybs);
170  System.out.println("products.length = " + products.length);
171%>
172
173<h1>Tab2MAGE Import Wizard -- File Mappings</h1>
174<p>
175
176The table below holds a list of all possible factor value combinations used in your experiment.
177Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
178
179<!-- this table holds the combinations of factor values -->
180
181<table align="center" cellpadding="15">
182
183  <!-- column header row factor names -->
184
185  <tr>
186
187    <!-- file selector header -->
188    <td class="header"><h3>File</h3></td>
189    <td class="header"><h3>Subject</h3></td>
190    <td class="header"><h3>Tissue</h3></td>
191
192    <!-- factor names -->
193    <%
194      for (int i = 0; i < products[i].length; i++)
195      {
196    %>
197    <td class="header"><h3><%=factorNames[i]%></h3></td>
198    <%
199    }
200    %>
201  </tr>
202
203  <!-- now add as many rows as we have discrete combinations of factor values -->
204
205  <%
206    for (int i = 0; i < numHybs; i++)
207    {
208  %>
209
210  <tr>
211
212    <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values-->
213
214    <td class="input" ><select id="fileInput<%=i %>">
215      <%
216          for (int k = 0; k < fileNamesArr.length; k++)
217          {
218      %>
219
220      <option><%=fileNamesArr[k]%></option>
221
222      <%
223      }
224      %>
225    </select></td>
226   
227    <!-- next  we need a cell with a drop down menu where we can select a subject name to match the combination of factor values-->
228
229    <td class="input" ><select id="subjectInput<%=i %>">
230      <%
231          for (int k = 0; k < subjectNames.length; k++)
232          {
233      %>
234
235      <option><%=subjectNames[k]%></option>
236
237      <%
238      }
239      %>
240    </select></td>
241   
242    <!-- next  we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values-->
243
244    <td class="input" ><select id="tissueInput<%=i %>">
245      <%
246          for (int k = 0; k < tissueNames.length; k++)
247          {
248      %>
249
250      <option><%=tissueNames[k]%></option>
251
252      <%
253      }
254      %>
255    </select></td>
256
257<!-- now print the values of this factor value combination, each in a separate cell -->
258    <%
259        for (int j = 0; j < products[i].length; j++)
260        {
261    %>
262    <td class="border"><%=products[i][j]%></td>
263    <%
264    }
265    %>
266
267
268  </tr>
269
270  <%
271  }
272  %>
273
274</table>
275
276<p>
277
278  <table align="center" class="noBorder" cellspacing="5"  cellpadding="5">
279  <tr class="noBorder">
280    <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>
281    <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>
282  </table>
283
284
285</form>
286
287
288
289</body>
290</html>
Note: See TracBrowser for help on using the repository browser.