1 | <%-- $Id: list_spotdata.jsp 4306 2008-05-21 13:39:59Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg |
---|
4 | Copyright (C) 2007 Johan Enell |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 2 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with this program; if not, write to the Free Software |
---|
21 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
22 | Boston, MA 02111-1307, USA. |
---|
23 | ------------------------------------------------------------------ |
---|
24 | |
---|
25 | @author Nicklas |
---|
26 | @version 2.0 |
---|
27 | --%> |
---|
28 | <%@ page session="false" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.DbControl" |
---|
31 | import="net.sf.basedb.core.Item" |
---|
32 | import="net.sf.basedb.core.Type" |
---|
33 | import="net.sf.basedb.core.ItemContext" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.Experiment" |
---|
36 | import="net.sf.basedb.core.BioAssaySet" |
---|
37 | import="net.sf.basedb.core.BioAssay" |
---|
38 | import="net.sf.basedb.core.RawDataType" |
---|
39 | import="net.sf.basedb.core.BaseException" |
---|
40 | import="net.sf.basedb.core.DynamicSpotQuery" |
---|
41 | import="net.sf.basedb.core.DynamicResultIterator" |
---|
42 | import="net.sf.basedb.core.PluginDefinition" |
---|
43 | import="net.sf.basedb.core.Formula" |
---|
44 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
45 | import="net.sf.basedb.core.plugin.Plugin" |
---|
46 | import="net.sf.basedb.core.query.SqlResult" |
---|
47 | import="net.sf.basedb.util.Enumeration" |
---|
48 | import="net.sf.basedb.util.ColorGenerator" |
---|
49 | import="net.sf.basedb.clients.web.Base" |
---|
50 | import="net.sf.basedb.clients.web.ModeInfo" |
---|
51 | import="net.sf.basedb.clients.web.DynamicUtil" |
---|
52 | import="net.sf.basedb.clients.web.WebException" |
---|
53 | import="net.sf.basedb.clients.web.util.HTML" |
---|
54 | import="net.sf.basedb.util.Values" |
---|
55 | import="net.sf.basedb.clients.web.taglib.table.TableColumn" |
---|
56 | import="java.util.Map" |
---|
57 | import="java.util.HashMap" |
---|
58 | import="java.util.List" |
---|
59 | import="java.util.LinkedList" |
---|
60 | import="java.util.ArrayList" |
---|
61 | import="java.util.Set" |
---|
62 | import="java.util.HashSet" |
---|
63 | import="java.util.Arrays" |
---|
64 | import="java.awt.Color" |
---|
65 | %> |
---|
66 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
67 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
68 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
69 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
70 | <%! |
---|
71 | private static final Item itemType = Item.SPOTDATA; |
---|
72 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
73 | %> |
---|
74 | <% |
---|
75 | final int bioAssayId = Values.getInt(request.getParameter("bioassay_id")); |
---|
76 | final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id")); |
---|
77 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
78 | final String ID = sc.getId(); |
---|
79 | |
---|
80 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
81 | final String callback = request.getParameter("callback"); |
---|
82 | final String title = mode.generateTitle("spot data", "spot data"); |
---|
83 | final DbControl dc = sc.newDbControl(); |
---|
84 | DynamicResultIterator spotData = null; |
---|
85 | try |
---|
86 | { |
---|
87 | final BioAssay bioAssay = bioAssayId == 0 ? null : BioAssay.getById(dc, bioAssayId); |
---|
88 | final BioAssaySet bioAssaySet = bioAssay != null ? bioAssay.getBioAssaySet() : BioAssaySet.getById(dc, bioAssaySetId); |
---|
89 | final Experiment experiment = bioAssaySet.getExperiment(); |
---|
90 | final int experimentId = experiment.getId(); |
---|
91 | final RawDataType rawDataType = bioAssaySet.getRawDataType(); |
---|
92 | Map<Short, String> bioAssayMap = null; |
---|
93 | |
---|
94 | final String subContext = rawDataType.getId(); |
---|
95 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null); |
---|
96 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
97 | |
---|
98 | List<TableColumn> columns = new LinkedList<TableColumn>(); |
---|
99 | DynamicUtil.addSpotColumns(columns, dc, rawDataType.getChannels()); |
---|
100 | DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm.", "", true); |
---|
101 | DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] "); |
---|
102 | DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] "); |
---|
103 | DynamicUtil.addReporterColumns(columns, dc, "rep.", "@", "[Rep] "); |
---|
104 | DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false); |
---|
105 | if (bioAssay == null && cc.getSetting("columns").indexOf("COLUMN") >= 0) |
---|
106 | { |
---|
107 | selected.selectedIds.add("COLUMN"); |
---|
108 | selected.selectedProperties.add("COLUMN"); |
---|
109 | } |
---|
110 | try |
---|
111 | { |
---|
112 | final DynamicSpotQuery query = bioAssay != null ? bioAssay.getSpotData() : bioAssaySet.getSpotData(); |
---|
113 | cc.configureQuery(dc, query, selected.selectedProperties); |
---|
114 | spotData = query.iterate(dc); |
---|
115 | } |
---|
116 | catch (Throwable t) |
---|
117 | { |
---|
118 | cc.setMessage(t.getMessage()); |
---|
119 | } |
---|
120 | |
---|
121 | int numListed = 0; |
---|
122 | %> |
---|
123 | <base:page title="<%=title%>"> |
---|
124 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
125 | <script language="JavaScript"> |
---|
126 | var submitPage = 'index.jsp'; |
---|
127 | var formId = 'spotdata'; |
---|
128 | function configureColumns() |
---|
129 | { |
---|
130 | Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
131 | } |
---|
132 | function presetOnChange() |
---|
133 | { |
---|
134 | Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>'); |
---|
135 | } |
---|
136 | function runPlugin(cmd) |
---|
137 | { |
---|
138 | Table.submitToPopup(formId, cmd, 800, 500); |
---|
139 | } |
---|
140 | function switchTab(tabControlId, tabId) |
---|
141 | { |
---|
142 | if (tabId == 'properties.bioassay') |
---|
143 | { |
---|
144 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=properties'; |
---|
145 | } |
---|
146 | else if (tabId == 'annotations.bioassay') |
---|
147 | { |
---|
148 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=annotations'; |
---|
149 | } |
---|
150 | else if (tabId == 'properties.bioassayset') |
---|
151 | { |
---|
152 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=properties'; |
---|
153 | } |
---|
154 | else if (tabId == 'annotations.bioassayset') |
---|
155 | { |
---|
156 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=annotations'; |
---|
157 | } |
---|
158 | else if (tabId == 'overviewplots' || tabId == 'cfplots') |
---|
159 | { |
---|
160 | location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experimentId%>&item_id=<%=bioAssaySetId%>&tab='+tabId; |
---|
161 | } |
---|
162 | else if (tabId == 'bioassays') |
---|
163 | { |
---|
164 | location.href = '../bioassays/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>&bioassayset_id=<%=bioAssaySetId%>&tab='+tabId; |
---|
165 | } |
---|
166 | else |
---|
167 | { |
---|
168 | TabControl.setActiveTab(tabControlId, tabId); |
---|
169 | } |
---|
170 | } |
---|
171 | function newReporterList() |
---|
172 | { |
---|
173 | Table.submitToPopup(formId, 'CreateReporterList', 540, 400); |
---|
174 | } |
---|
175 | </script> |
---|
176 | </base:head> |
---|
177 | <base:body> |
---|
178 | <p> |
---|
179 | <p:path> |
---|
180 | <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" /> |
---|
181 | <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" |
---|
182 | href="<%="../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" /> |
---|
183 | |
---|
184 | <% |
---|
185 | if (bioAssay == null) |
---|
186 | { |
---|
187 | %> |
---|
188 | <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" /> |
---|
189 | <% |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | %> |
---|
194 | <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" |
---|
195 | href="<%="../bioassays/index.jsp?ID="+ID+"&bioassayset_id="+bioAssaySet.getId()%>" /> |
---|
196 | <p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" /> |
---|
197 | <% |
---|
198 | } |
---|
199 | %> |
---|
200 | </p:path> |
---|
201 | |
---|
202 | <t:tabcontrol id="main" active="spotdata" switch="switchTab"> |
---|
203 | <t:tab id="properties.bioassay" title="Properties" visible="<%=bioAssay != null%>"/> |
---|
204 | <t:tab id="properties.bioassayset" title="Properties" visible="<%=bioAssay == null%>"/> |
---|
205 | |
---|
206 | <t:tab id="annotations.bioassay" title="Annotations" |
---|
207 | tooltip="View annotation values" visible="<%=bioAssay != null%>" /> |
---|
208 | <t:tab id="annotations.bioassayset" title="Annotations" |
---|
209 | tooltip="View annotation values" visible="<%=bioAssay == null%>" /> |
---|
210 | |
---|
211 | <t:tab id="bioassays" visible="<%=bioAssay == null%>" title="BioAssays" /> |
---|
212 | <t:tab id="spotdata" title="Spot data" > |
---|
213 | <% |
---|
214 | if (cc.getMessage() != null) |
---|
215 | { |
---|
216 | %> |
---|
217 | <div class="error"><%=cc.getMessage()%></div> |
---|
218 | <% |
---|
219 | cc.setMessage(null); |
---|
220 | } |
---|
221 | %> |
---|
222 | <tbl:table |
---|
223 | id="spotdata" |
---|
224 | clazz="itemlist" |
---|
225 | columns="<%=cc.getSetting("columns")%>" |
---|
226 | sortby="<%=cc.getSortProperty()%>" |
---|
227 | direction="<%=cc.getSortDirection()%>" |
---|
228 | title="<%=title%>" |
---|
229 | action="index.jsp" |
---|
230 | sc="<%=sc%>" |
---|
231 | item="<%=itemType%>" |
---|
232 | subcontext="<%=subContext%>" |
---|
233 | > |
---|
234 | <tbl:hidden |
---|
235 | name="mode" |
---|
236 | value="<%=mode.getName()%>" |
---|
237 | /> |
---|
238 | <tbl:hidden |
---|
239 | name="bioassayset_id" |
---|
240 | value="<%=String.valueOf(bioAssaySetId)%>" |
---|
241 | /> |
---|
242 | <tbl:hidden |
---|
243 | name="bioassay_id" |
---|
244 | value="<%=String.valueOf(bioAssayId)%>" |
---|
245 | /> |
---|
246 | <tbl:hidden |
---|
247 | name="callback" |
---|
248 | value="<%=callback%>" |
---|
249 | skip="<%=callback == null%>" |
---|
250 | /> |
---|
251 | |
---|
252 | <% |
---|
253 | for (TableColumn tc : columns) |
---|
254 | { |
---|
255 | %> |
---|
256 | <tbl:columndef |
---|
257 | id="<%=tc.getId()%>" |
---|
258 | property="<%=tc.getProperty()%>" |
---|
259 | datatype="<%=tc.getDatatype().getStringValue()%>" |
---|
260 | title="<%=tc.getTitle()%>" |
---|
261 | sortable="<%=tc.getSortable()%>" |
---|
262 | filterable="<%=tc.getFilterable()%>" |
---|
263 | exportable="<%=tc.getExportable()%>" |
---|
264 | show="<%=tc.getShow()%>" |
---|
265 | formatter="<%=tc.getFormatter()%>" |
---|
266 | /> |
---|
267 | <% |
---|
268 | } |
---|
269 | %> |
---|
270 | <% |
---|
271 | if (bioAssay == null) |
---|
272 | { |
---|
273 | bioAssayMap = new HashMap<Short, String>(); |
---|
274 | Enumeration<String, String> bioAssayEnum = new Enumeration<String, String>(); |
---|
275 | for (BioAssay ba : bioAssaySet.getBioAssays().list(dc)) |
---|
276 | { |
---|
277 | short columnNo = ba.getDataCubeColumnNo(); |
---|
278 | bioAssayMap.put(columnNo, Base.getLinkedName(ID, ba, false, true)); |
---|
279 | bioAssayEnum.add(String.valueOf(columnNo), HTML.encodeTags(ba.getName())); |
---|
280 | } |
---|
281 | %> |
---|
282 | <tbl:columndef |
---|
283 | id="COLUMN" |
---|
284 | property="COLUMN" |
---|
285 | datatype="int" |
---|
286 | title="Bioassay" |
---|
287 | sortable="true" |
---|
288 | filterable="true" |
---|
289 | exportable="true" |
---|
290 | enumeration="<%=bioAssayEnum%>" |
---|
291 | /> |
---|
292 | <% |
---|
293 | } |
---|
294 | %> |
---|
295 | <tbl:columndef |
---|
296 | id="reporterList" |
---|
297 | property="£reporterList" |
---|
298 | datatype="int" |
---|
299 | title="Reporter list" |
---|
300 | filterable="true" |
---|
301 | enumeration="<%=Base.getReporterListsEnum(dc)%>" |
---|
302 | multiple="false" |
---|
303 | /> |
---|
304 | <tbl:toolbar |
---|
305 | visible="<%=mode.hasToolbar()%>" |
---|
306 | > |
---|
307 | <tbl:button |
---|
308 | image="columns.gif" |
---|
309 | onclick="configureColumns()" |
---|
310 | title="Columns…" |
---|
311 | tooltip="Show, hide and re-order columns" |
---|
312 | /> |
---|
313 | <tbl:button |
---|
314 | image="add.png" |
---|
315 | onclick="newReporterList()" |
---|
316 | title="New reporter list…" |
---|
317 | tooltip="Create a new reporter list from matching spots" |
---|
318 | visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>" |
---|
319 | /> |
---|
320 | <tbl:button |
---|
321 | image="export.gif" |
---|
322 | onclick="runPlugin('ExportItems')" |
---|
323 | title="Export…" |
---|
324 | tooltip="Export data" |
---|
325 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
326 | /> |
---|
327 | </tbl:toolbar> |
---|
328 | <tbl:navigator |
---|
329 | page="<%=cc.getPage()%>" |
---|
330 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
331 | totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" |
---|
332 | visible="<%=mode.hasNavigator()%>" |
---|
333 | /> |
---|
334 | <tbl:data> |
---|
335 | <tbl:columns> |
---|
336 | <tbl:presetselector |
---|
337 | clazz="columnheader" |
---|
338 | colspan="2" |
---|
339 | onchange="presetOnChange()" |
---|
340 | /> |
---|
341 | </tbl:columns> |
---|
342 | <tr> |
---|
343 | <tbl:header |
---|
344 | clazz="index" |
---|
345 | > </tbl:header> |
---|
346 | <tbl:header |
---|
347 | clazz="icons" |
---|
348 | visible="<%=mode.hasIcons()%>" |
---|
349 | > </tbl:header> |
---|
350 | <tbl:propertyfilter /> |
---|
351 | </tr> |
---|
352 | |
---|
353 | <tbl:rows> |
---|
354 | <% |
---|
355 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
356 | int selectedItemId = cc.getId(); |
---|
357 | if (spotData != null) |
---|
358 | { |
---|
359 | while (spotData.hasNext()) |
---|
360 | { |
---|
361 | SqlResult item = spotData.next(); |
---|
362 | index++; |
---|
363 | numListed++; |
---|
364 | %> |
---|
365 | <tbl:row> |
---|
366 | <tbl:header |
---|
367 | clazz="index" |
---|
368 | ><%=index%></tbl:header> |
---|
369 | <tbl:header |
---|
370 | clazz="icons" |
---|
371 | visible="<%=mode.hasIcons()%>" |
---|
372 | > </tbl:header> |
---|
373 | <% |
---|
374 | int i = 1; |
---|
375 | for (String columnId : selected.selectedIds) |
---|
376 | { |
---|
377 | Object value = item.getObject(i++); |
---|
378 | if ("COLUMN".equals(columnId)) |
---|
379 | { |
---|
380 | short columnNo = ((Number)value).shortValue(); |
---|
381 | value= bioAssayMap.get(columnNo); |
---|
382 | } |
---|
383 | %> |
---|
384 | <tbl:cell column="<%=columnId%>" value="<%=value%>" /> |
---|
385 | <% |
---|
386 | } |
---|
387 | %> |
---|
388 | </tbl:row> |
---|
389 | <% |
---|
390 | } |
---|
391 | } |
---|
392 | %> |
---|
393 | </tbl:rows> |
---|
394 | </tbl:data> |
---|
395 | <% |
---|
396 | if (numListed == 0) |
---|
397 | { |
---|
398 | %> |
---|
399 | <tbl:panel><%=spotData == null || spotData.getTotalCount() == 0 ? "No spot data were found" : "No spot data on this page. Please select another page!" %></tbl:panel> |
---|
400 | <% |
---|
401 | } |
---|
402 | else |
---|
403 | { |
---|
404 | %> |
---|
405 | <tbl:navigator |
---|
406 | page="<%=cc.getPage()%>" |
---|
407 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
408 | totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" |
---|
409 | visible="<%=mode.hasNavigator()%>" |
---|
410 | locked="true" |
---|
411 | /> |
---|
412 | <% |
---|
413 | } |
---|
414 | %> |
---|
415 | </tbl:table> |
---|
416 | <base:buttongroup align="center"> |
---|
417 | <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" /> |
---|
418 | <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" /> |
---|
419 | <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" /> |
---|
420 | </base:buttongroup> |
---|
421 | </t:tab> |
---|
422 | |
---|
423 | <t:tab id="overviewplots" |
---|
424 | visible="<%=bioAssay == null && rawDataType.getChannels() == 2%>" |
---|
425 | title="Overview plots" |
---|
426 | tooltip="MA-plots of each bioassay in this bioassay set" |
---|
427 | /> |
---|
428 | <t:tab id="cfplots" |
---|
429 | title="Correction factor plots" |
---|
430 | visible="<%=bioAssay == null && rawDataType.getChannels() == 2 && bioAssaySet.getTransformation().getSource() != null %>" |
---|
431 | /> |
---|
432 | |
---|
433 | </t:tabcontrol> |
---|
434 | |
---|
435 | </base:body> |
---|
436 | </base:page> |
---|
437 | <% |
---|
438 | } |
---|
439 | finally |
---|
440 | { |
---|
441 | if (dc != null) dc.close(); |
---|
442 | } |
---|
443 | %> |
---|