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

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

new page added to gather additional info needed for autogeneration of t2m file

File size: 9.5 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
20<html>
21
22<head>
23
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">
27
28<script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script>
29<script language="JavaScript" type="text/javascript">
30
31//submits form
32function submit()
33{
34  gatherValues();
35  document.mappings.submit();
36}
37
38
39function getRoot()
40{
41  return '/base/';
42}
43
44function getScale()
45{
46  return 1.0;
47}
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{
54  var fileList = '';
55  var subjectList = '';
56  var tissueList = '';
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;
63    if(id.match("fileInput"))
64    {
65      fileList += frm.elements[i].value + '\t';
66    }
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    }
75    if(id.match("combinationInput"))
76    {
77      combinationList += frm.elements[i].value + '\t';
78    }
79  }
80  frm.fileList.value = fileList;
81  frm.subjectList.value = subjectList;
82  frm.tissueList.value = tissueList;
83  frm.combinationList.value = combinationList;
84}
85
86</script>
87
88</head>
89
90<body>
91
92
93
94<form name="mappings" action="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/submit.jsp?ID=<%=ID%>" method="post">
95
96<input type="hidden" name="ID" value="<%=ID%>"> 
97<input type="hidden" name="cmd" value="SetParameters"> 
98<input type="hidden" name="requestId" value="<%=requestId%>"> 
99
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""/>
103<input type="hidden" id="combinationList" name="combinationList" value""/>
104
105
106
107<%
108  //first extract the factor names and the possible values
109  String expFactors = inputDataBean.getExpFactors().trim();
110  String[] rawFactors = expFactors.split("\n");
111
112  String[][] factorValues = new String[rawFactors.length][];
113  String[] factorNames = new String[rawFactors.length];
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("("));
119    factorNames[i] = factorName;
120    //extract the possible values from between the parentheses
121    String allValues = rawFactors[i].substring(rawFactors[i].indexOf("(") + 1,
122        rawFactors[i].indexOf(")"));
123    String[] values = allValues.split(",");
124    factorValues[i] = values;
125  }
126
127  //here we get hold of the cartesian product of all the factor values
128  String[][] products = CartesianProduct.getCartesianProduct(factorValues);
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 
133  String zipFilePath = inputDataBean.getPath();
134  System.out.println("zipFilePath = " + zipFilePath);
135  String zipFileDirStr = zipFilePath.substring(0, zipFilePath.lastIndexOf("/"));
136  String zipFileName = zipFilePath.substring(zipFilePath.lastIndexOf("/") + 1);
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  }
152
153  String[] fileNamesArr = new String[fileNames.size()];
154  fileNames.toArray(fileNamesArr);
155  Arrays.sort(fileNamesArr);
156
157  dc.close();
158
159  //next get the subjectNames and make up select boxes with these
160  //they too have to be mapped to filenames
161  String[] subjectNames = inputDataBean.getSubjectNames().split("\n");
162
163  //we also need to parse out the tissues string to produce another column of select boxes
164  String[] tissueNames = inputDataBean.getTissues().split("\n");
165
166  //work out the number of hybridizations
167  String platform = inputDataBean.getPlatform();
168  //work out whether this is a single or dual channel experiment
169  boolean singleChannel = false;
170  if (platform.equalsIgnoreCase("affymetrix"))
171  {
172    singleChannel = true;
173  } 
174  int numReplicates = Integer.parseInt(inputDataBean.getNumReplicates());
175  int numTreatmentGroups = Integer.parseInt(inputDataBean.getNumTreatmentGroups());
176  int numTissues = inputDataBean.getTissues().split("\n").length;
177  int numHybs = Tab2MageWriter.calcNumHybs(singleChannel,numReplicates, numTreatmentGroups, numTissues);
178  System.out.println("numHybs = " + numHybs);
179  System.out.println("products.length = " + products.length);
180%>
181
182<h1>Tab2MAGE Import Wizard -- File Mappings</h1>
183<p>
184
185The table below holds a list of all possible factor value combinations used in your experiment.
186Please select, for each combination, the appropriate file, subject and tissue from the drop down menu.</p><p>
187
188<!-- this table holds the combinations of factor values -->
189
190<table align="center" cellpadding="15">
191
192  <!-- column header row factor names -->
193
194  <tr>
195
196    <!-- file selector header -->
197    <td class="header"><h3>File</h3></td>
198    <td class="header"><h3>Subject</h3></td>
199    <td class="header"><h3>Tissue</h3></td>
200    <td class="header"><h3>Factor Value Combination</h3></td>
201
202  </tr>
203
204  <!-- now add as many rows as we have discrete combinations of factor values -->
205
206  <%
207    for (int i = 0; i < numHybs; i++)
208    {
209  %>
210
211  <tr>
212
213    <!-- first we need a cell with a drop down menu where we can select a filename to match the combination of factor values-->
214
215    <td class="input" ><select id="fileInput<%=i %>">
216      <%
217          for (int k = 0; k < fileNamesArr.length; k++)
218          {
219      %>
220
221      <option><%=fileNamesArr[k]%></option>
222
223      <%
224      }
225      %>
226    </select></td>
227   
228    <!-- next  we need a cell with a drop down menu where we can select a subject name to match the combination of factor values-->
229
230    <td class="input" ><select id="subjectInput<%=i %>">
231      <%
232          for (int k = 0; k < subjectNames.length; k++)
233          {
234      %>
235
236      <option><%=subjectNames[k]%></option>
237
238      <%
239      }
240      %>
241    </select></td>
242   
243    <!-- next  we need a cell with a drop down menu where we can select a tissue name to match the combination of factor values-->
244
245    <td class="input" ><select id="tissueInput<%=i %>">
246      <%
247          for (int k = 0; k < tissueNames.length; k++)
248          {
249      %>
250
251      <option><%=tissueNames[k]%></option>
252
253      <%
254      }
255      %>
256    </select></td>
257
258<!-- need a single cell with a select box that lets the user select from a list of unique factor value combinations -->
259
260    <td>
261    <select id="combinationInput<%=i %>">
262      <%
263          for (int k = 0; k < products.length; k++)
264          {
265            //make a String with all the factor values in this combination
266            //separate values in each combi with a space
267            String combi = "";
268            for (int j = 0; j < products[k].length; j++)
269            {
270              combi += products[k][j] + " ";
271            }
272      %>
273
274      <option><%=combi%></option>
275
276      <%
277      }
278      %>
279    </select>
280    </td>
281
282  </tr>
283
284  <%
285  }
286  %>
287
288</table>
289
290<p>
291
292  <table align="center" class="noBorder" cellspacing="5"  cellpadding="5">
293  <tr class="noBorder">
294    <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>
295    <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>
296  </table>
297
298
299</form>
300
301
302
303</body>
304</html>
Note: See TracBrowser for help on using the repository browser.