source: trunk/www/views/experiments/explorer/view/view.jsp @ 5140

Last change on this file since 5140 was 5140, checked in by Nicklas Nordborg, 13 years ago

References #1384: Move the annotation summary information table in experiment explorer

Removed some <div> tags that are not needed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 27.7 KB
Line 
1<%-- $Id: view.jsp 5140 2009-10-19 06:25:52Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Johan Enell, Nicklas Nordborg
4  Copyright (C) 2007 Nicklas Nordborg
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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.PropertyFilter"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.BioAssaySet"
34  import="net.sf.basedb.core.BioAssay"
35  import="net.sf.basedb.core.Experiment"
36  import="net.sf.basedb.core.RawDataType"
37  import="net.sf.basedb.core.RawBioAssay"
38  import="net.sf.basedb.core.RawDataUtil"
39  import="net.sf.basedb.core.ExtendedProperties"
40  import="net.sf.basedb.core.ExtendedProperty"
41  import="net.sf.basedb.core.AnnotationType"
42  import="net.sf.basedb.core.Annotation"
43  import="net.sf.basedb.core.Formula"
44  import="net.sf.basedb.core.IntensityTransform"
45  import="net.sf.basedb.core.ItemQuery"
46  import="net.sf.basedb.core.ItemResultList"
47  import="net.sf.basedb.core.DynamicSpotQuery"
48  import="net.sf.basedb.core.DynamicResultIterator"
49  import="net.sf.basedb.core.VirtualColumn"
50  import="net.sf.basedb.core.Type"
51  import="net.sf.basedb.core.data.ReporterData"
52  import="net.sf.basedb.core.data.RawData"
53  import="net.sf.basedb.core.query.Restrictions"
54  import="net.sf.basedb.core.query.Expressions"
55  import="net.sf.basedb.core.query.Dynamic"
56  import="net.sf.basedb.core.query.Orders"
57  import="net.sf.basedb.core.query.Selects"
58  import="net.sf.basedb.core.query.Aggregations"
59  import="net.sf.basedb.core.query.Hql"
60  import="net.sf.basedb.core.query.JoinType"
61  import="net.sf.basedb.core.query.SqlResult"
62  import="net.sf.basedb.util.Values"
63  import="net.sf.basedb.clients.web.Base"
64  import="net.sf.basedb.clients.web.DynamicUtil"
65  import="net.sf.basedb.clients.web.ExperimentExplorer"
66  import="net.sf.basedb.clients.web.ExperimentExplorer.AnnotationSummary"
67  import="net.sf.basedb.clients.web.ExperimentExplorer.AnnotationGroup"
68  import="net.sf.basedb.clients.web.WebException"
69  import="net.sf.basedb.clients.web.util.HTML"
70  import="net.sf.basedb.util.formatter.Formatter"
71  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
72  import="net.sf.basedb.clients.web.formatter.SpotImageFormatter"
73  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
74  import="java.util.Date"
75  import="java.util.List"
76  import="java.util.ArrayList"
77  import="java.util.LinkedList"
78  import="java.util.Collection"
79  import="java.util.Arrays"
80  import="java.util.Set"
81  import="java.util.Map"
82  import="java.util.HashMap"
83%>
84<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
85<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
86<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
87<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
88<%!
89  private static final Item itemType = Item.SPOTDATA;
90  private static final String defaultReporterColumns = "name,externalId,symbol,description";
91%>
92<%
93final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
94final String ID = sc.getId();
95final float scale = Base.getScale(sc);
96final String root = request.getContextPath();
97
98final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
99final DbControl dc = sc.newDbControl();
100DynamicResultIterator spotData = null;
101try
102{
103  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
104  String title = null;
105  final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
106  final Experiment experiment = bioAssaySet.getExperiment();
107  final RawDataType rawDataType = experiment.getRawDataType();
108  final int channels = rawDataType.getChannels();
109  final boolean hasRatio = channels == 2;
110  final int maxRawMappings = bioAssaySet.getMaxRawMappingsForSpot();
111  final IntensityTransform transform = bioAssaySet.getIntensityTransform();
112 
113  final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
114  final ItemContext cc = explorer.getAndSetSpotContext(sc, pageContext);
115  final ItemContext reporterContext = explorer.getAndSetReporterContext(sc, null);
116  final String subContext = cc.getSubContext();
117 
118  List<TableColumn> columns = new LinkedList<TableColumn>();
119  DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, 
120    transform, "frm.", "", maxRawMappings == 1);
121  DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
122  if (maxRawMappings == 1)
123  {
124    DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
125    columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, 
126      "[Raw] Spotimage", "", "auto", false, false, false, null, 
127      new SpotImageFormatter(dc, rawDataType, root)));
128  }
129
130  final int matchingReporters = explorer.getMatchingReporters(dc);
131  int reporterIndex = explorer.getReporterIndex();
132  if (reporterIndex >= matchingReporters) reporterIndex = matchingReporters - 1;
133  final ReporterData reporter = matchingReporters == 0 ? 
134      null : explorer.getReporter(dc, reporterIndex);
135
136  final int matchingPositions = matchingReporters == 0 ? 
137      0 : explorer.getNumPositions(dc, reporterIndex);
138 
139  int positionIndex = explorer.getPositionIndex();
140  if (positionIndex >= matchingPositions) positionIndex = matchingPositions - 1;
141  final boolean isAveraging = positionIndex == ExperimentExplorer.SPOT_AVG;
142 
143  final List<AnnotationType> annotationTypes = explorer.getAnnotationTypes(dc, true);
144  final Set<Integer> tmp = explorer.getAnnotationTypeIds();
145  final Map<AnnotationType, AnnotationSummary> selectedAnnotationTypes = 
146    new HashMap<AnnotationType, AnnotationSummary>(tmp.size());
147  for (Integer atId : tmp)
148  {
149    try
150    {
151      selectedAnnotationTypes.put(AnnotationType.getById(dc, atId), null);
152    }
153    catch (Throwable t)
154    {}
155  }
156
157  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, isAveraging);
158 
159  List<String> sortProperties = null;
160  if (isAveraging && cc.getSortProperty() != null)
161  {
162    // We must check that we are not sorting on a non-averagable property
163    sortProperties = new ArrayList<String>(Arrays.asList(cc.getSortProperty().split(",")));
164    for (TableColumn tc : columns)
165    {
166      if (!tc.isAveragable()) sortProperties.remove(tc.getProperty());
167    }
168    cc.setSortProperty(Values.getString(sortProperties, ",", true));
169  }
170 
171  if (matchingReporters > 0)
172  {
173    for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
174    {
175      entry.setValue(explorer.getAnnotationSummary(dc, entry.getKey()));
176    }
177    try
178    {
179      DynamicSpotQuery spotQuery = explorer.getSpotQuery(dc, reporterIndex, positionIndex, selected.selectedColumns);
180      spotData = spotQuery.iterate(dc);
181    }
182    catch (Throwable t)
183    {
184      cc.setMessage(t.getMessage());
185    }
186  }
187  %>
188  <base:page title="<%=title%>">
189  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css,explorer.css">
190  <script language="JavaScript">
191    var submitPage = 'index.jsp';
192    var formId = 'spotdata';
193    function configureColumns()
194    {
195      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
196    }
197    function configureReporterColumns()
198    {
199      var frm = document.forms['reporter'];
200      frm.cmd.value = 'SetReporterColumns';
201      Table.configureColumns('<%=ID%>', 'reporter', '<%=itemType.name()%>', '<%=defaultReporterColumns%>', '<%=subContext%>', 'reporter-columns');
202    }
203    function presetOnChange()
204    {
205      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
206    }
207    function validateReporterIndex()
208    {
209      var frm = document.forms['reporterIndex'];
210      var reporterIndex = parseInt(frm.newReporterIndex.value);
211      var maxIndex = <%=matchingReporters%>;
212      if (reporterIndex < 1 || reporterIndex > maxIndex)
213      {
214        alert('The reporter index must be between 1 and ' + maxIndex);
215        return false;
216      }
217      frm.cmd.value = 'SetReporterIndex';
218      Forms.createHidden(frm, 'reporterIndex', reporterIndex-1);
219      return true;
220    }
221    function validateSpotIndex()
222    {
223      var frm = document.forms['spotIndex'];
224      var spotIndex = parseInt(frm.newSpotIndex.value);
225      var maxIndex = <%=matchingPositions%>;
226      if (spotIndex < 1 || spotIndex > maxIndex)
227      {
228        alert('The spot index must be between 1 and ' + maxIndex);
229        return false;
230      }
231      frm.cmd.value = 'SetSpotIndex';
232      Forms.createHidden(frm, 'spotIndex', spotIndex-1);
233      return true;
234    }
235    function annotationTypeOnChange()
236    {
237      var frm = document.forms['explorer'];
238      frm.cmd.value = 'SetAnnotationType';
239      frm.submit();
240    }
241    function viewSearch()
242    {
243      location.href = '../search/index.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
244    }
245    function switchTab(tabControlId, tabId)
246    {
247      if (tabId == 'search')
248      {
249        viewSearch();
250      }
251      else
252      {
253        TabControl.setActiveTab(tabControlId, tabId);
254      }
255    }
256    function plotSpotData()
257    {
258      var url = 'plotter.jsp?ID=<%=ID%>&type=line';
259      url += '&bioAssaySetId=<%=bioAssaySetId%>';
260      url += '&reporterIndex=<%=reporterIndex%>';
261      url += '&positionIndex=<%=positionIndex%>';
262      Main.openPopup(url, 'SpotPlot', 1100, 700);
263    }
264    function boxPlot(annotationType)
265    {
266      var url = 'plotter.jsp?ID=<%=ID%>&type=box';
267      url += '&bioAssaySetId=<%=bioAssaySetId%>';
268      url += '&reporterIndex=<%=reporterIndex%>';
269      url += '&positionIndex=<%=positionIndex%>';
270      url += '&annotationTypeId=' + annotationType;
271      Main.openPopup(url, 'BoxPlot', 1100, 700);
272    }
273  </script>
274  </base:head>
275  <base:body>
276    <p>
277    <p:path>
278      <p:pathelement title="Experiments" href="<%="../../index.jsp?ID="+ID%>" />
279      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
280        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" />
281      <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
282        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+bioAssaySetId%>" />
283      <p:pathelement title="Explorer" />
284    </p:path>
285   
286    <t:tabcontrol id="explorer" switch="switchTab" remember="false" active="view">
287    <t:tab id="search" title="Reporter search" />
288   
289    <t:tab id="view" title="Reporter view">
290    <div class="boxed">
291   
292    <%
293    Collection<PropertyFilter> filters = reporterContext.getPropertyFilters();
294    String filter = filters != null && filters.size() > 0 ? 
295      "(" + Values.getString(filters, ") AND (", true).replaceAll("@|£", "") + ")" : "- none -";
296    %>
297    <table class="form">
298    <tr>
299      <td class="prompt">Filter</td>
300      <td>
301      <%=HTML.encodeTags(filter)%>
302      </td>
303    </tr>
304    </table>
305   
306   
307    <%
308    if (reporter != null)
309    {
310      %>
311      <form name="reporterIndex" action="index.jsp" method="post">
312      <input type="hidden" name="ID" value="<%=ID%>">
313      <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
314      <input type="hidden" name="cmd" value="SetReporterIndex">
315      <h4 class="docked">Current reporter
316            <input name="newReporterIndex" type="text" class="text" value="<%=reporterIndex+1%>" 
317        onkeypress="return Numbers.integerOnly(event, true, validateReporterIndex)"
318        size="6" maxlength="8" title="Enter a number between 1 and <%=matchingReporters%>">
319      of <%=matchingReporters %>
320      <%
321      if (reporterIndex == 0 || matchingReporters == 0)
322      {
323        %>
324        <base:icon image="first_gray.gif" />
325        <base:icon image="previous_gray.gif" />
326        <%
327      }
328      else
329      {
330        %>
331        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=0"
332          title="Go the first reporter"><base:icon image="first.gif" /></a>
333        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=reporterIndex-1%>"
334          title="Go the previous reporter"><base:icon image="previous.gif" /></a>
335        <%
336      }
337      %>
338      &nbsp;&nbsp;
339      <%
340      if (reporterIndex == matchingReporters - 1 || matchingReporters == 0)
341      {
342        %>
343        <base:icon image="next_gray.gif" />
344        <base:icon image="last_gray.gif" />
345        <%
346      }
347      else
348      {
349        %>
350        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=reporterIndex+1%>"
351          title="Go the next reporter"><base:icon image="next.gif" /></a>
352        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=matchingReporters-1%>"
353          title="Go the last reporter"><base:icon image="last.gif" /></a>
354        <%
355      }
356      %>
357      </h4>
358      </form>
359     
360      <tbl:toolbar>
361        <tbl:button 
362          image="columns.gif" 
363          onclick="configureReporterColumns()" 
364          title="Columns&hellip;" 
365          tooltip="Show, hide and re-order reporter columns" 
366        />
367      </tbl:toolbar>
368   
369    <div class="boxedbottom">
370    <tbl:table 
371      id="reporter" 
372      clazz="form" 
373      columns="<%=Values.getString(cc.getSetting("reporter-columns"), defaultReporterColumns)%>"
374      action="index.jsp"
375      sc="<%=sc%>"
376      item="<%=itemType%>"
377      subcontext="<%=subContext%>"
378      >
379      <tbl:hidden 
380        name="bioassayset_id" 
381        value="<%=String.valueOf(bioAssaySetId)%>" 
382      />
383      <tbl:columndef id="name" title="Name" show="always" clazz="prompt"/>
384      <tbl:columndef id="externalId" title="External ID" clazz="prompt"/>
385      <tbl:columndef id="symbol" title="Gene symbol" clazz="prompt"/>
386      <tbl:columndef id="lastUpdate" title="Last update" clazz="prompt"/>
387      <tbl:columndef id="type" title="Type" clazz="prompt"/>
388      <tbl:columndef id="description" title="Description" clazz="prompt"/>
389      <%
390      List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
391      if (reporterProperties != null)
392      {
393        for (ExtendedProperty ep : reporterProperties)
394        {
395          String name = ep.getName();
396          Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
397          %>
398          <tbl:columndef 
399            id="<%=ep.getName()%>" 
400            title="<%=HTML.encodeTags(ep.getTitle())%>" 
401            clazz="prompt" 
402            formatter="<%=formatter%>"
403          />
404          <%
405        }
406      }
407      %>
408      <tbl:form width="2">
409        <tbl:cell column="name"><%=Base.getLink(ID, reporter.getName(), Item.REPORTER, reporter.getId(), true)%></tbl:cell>
410        <tbl:cell column="externalId"><%=HTML.encodeTags(reporter.getExternalId())%></tbl:cell>
411        <tbl:cell column="symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell>
412        <tbl:cell column="lastUpdate"><%=dateFormatter.format(reporter.getLastUpdate())%></tbl:cell>
413        <tbl:cell column="type"><base:propertyvalue dbcontrol="<%=dc%>" item="<%=reporter%>" property="reporterType" /></tbl:cell>
414        <tbl:cell column="description"><%=HTML.niceFormat(reporter.getDescription())%></tbl:cell>
415        <%
416        if (reporterProperties != null)
417        {
418          for (ExtendedProperty ep : reporterProperties)
419          {
420            String name = ep.getName();
421            Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
422            %>
423            <tbl:cell column="<%=ep.getName()%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell>
424            <%
425          }
426        }
427        %>
428      </tbl:form>
429    </tbl:table>
430    </div>
431    <%
432    }
433    else
434    {
435      %>
436      No reporters found.
437      <%
438    }
439    %>
440   
441    <base:section
442      id="annotation"
443      title="<%="Annotation summary (" + selectedAnnotationTypes.size() + " selected)"%>"
444      context="<%=cc%>"
445      >
446      <form name="annotationSummary" action="index.jsp" method="POST" onsubmit="return false;">
447      <input type="hidden" name="ID" value="<%=ID%>">
448      <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
449      <input type="hidden" name="cmd" value="SetAnnotationType">
450        <table border="0" cellspacing="0" cellpadding="0"><tr><td>
451        <div class="multiselect">
452          <input type="text" class="text" size="40" name="display:annotationTypes"
453            title="Click to select experimental factor"><img 
454            class="smartimage" src="../../../../images/pull_down.gif" 
455            onclick="MultiOptions.activateAndDisplay('annotationSummary','display:annotationTypes')"></div>
456          <input type="hidden" name="annotationtype_id" value="">
457          </td></tr></table>
458        <%
459        if (selectedAnnotationTypes.size() > 0)
460        {
461          for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
462          {
463            AnnotationType at = entry.getKey();
464            AnnotationSummary summary = entry.getValue();
465            %>
466            <table border="0" cellspacing="0" cellpadding="2" class="annotationsummary">
467            <tr>
468              <td class="summaryheader"><%=Base.getLinkedName(ID, at, false, true)%></td>
469              <td class="summaryheader"><base:icon
470                image="plotter.gif"
471                onclick="<%="boxPlot(" + at.getId() + ")"%>"
472                tooltip="Box plot for selected spot data per annotation group"
473              /></td>
474              <%
475              for (AnnotationGroup ag : summary.getAnnotationGroups())
476              {
477                %>
478                <td class="groupheader" style="background: <%=ag.getColor()%>;" width="50px">
479                <%=ag.getTitle()%>
480                </td>
481                <%
482              }
483              %>
484              </tr>
485              <%
486              for (int ch = 1; ch <= channels; ++ch)
487              {
488                %>
489                <tr>
490                <td colspan="2">Mean ch <%=ch%> int.</td>
491                <%
492                for (AnnotationGroup ag : summary.getAnnotationGroups())
493                {
494                  %>
495                  <td class="value" style="background: <%=ag.getColor()%>;"
496                    id="mean.<%=at.getId()%>.<%=ag.getId()%>.ch<%=ch%>"></td>
497                  <%
498                }
499                %>
500                </tr>
501                <%
502              }
503              if (hasRatio)
504              {
505                %>
506                <tr>
507                <td colspan="2" title="The geometric mean of the ratios">G. mean ratio</td>
508                <%
509                for (AnnotationGroup ag : summary.getAnnotationGroups())
510                {
511                  %>
512                  <td class="value" style="background: <%=ag.getColor()%>;"
513                    id="gmean.<%=at.getId()%>.<%=ag.getId()%>"></td>
514                  <%
515                }
516                %>
517                </tr>
518                <tr>
519                <td colspan="2" title="Standard deviation of log2 ratios">log2ratio SD</td>
520                <%
521                for (AnnotationGroup ag : summary.getAnnotationGroups())
522                {
523                  %>
524                  <td class="value" style="background: <%=ag.getColor()%>;"
525                    id="sd.<%=at.getId()%>.<%=ag.getId()%>"></td>
526                  <%
527                }
528                %>
529                </tr>
530                <%
531              }
532              %>
533              <tr>
534              <td colspan="2" title="The number of spots falling in this group">Count</td>
535              <%
536              for (AnnotationGroup ag : summary.getAnnotationGroups())
537              {
538                %>
539                <td class="value" style="background: <%=ag.getColor()%>;"
540                  id="count.<%=at.getId()%>.<%=ag.getId()%>"></td>
541                <%
542              }
543              %>
544              </tr>
545            </table>
546            <%
547          }
548        }
549        %>
550        </form>
551    </base:section>
552
553    <form name="spotIndex" action="index.jsp" method="post">
554    <input type="hidden" name="ID" value="<%=ID%>">
555    <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
556    <input type="hidden" name="cmd" value="SetSpotIndex">
557   
558      <h4 class="docked">Current spot
559      <input name="newSpotIndex" type="text" class="text" value="<%=positionIndex == -1 ? "all" : positionIndex == -2 ? "avg" : String.valueOf(positionIndex+1)%>" 
560        onkeypress="return Numbers.integerOnly(event, true, validateSpotIndex)"
561        size="6" maxlength="8" title="Enter a number between 1 and <%=matchingPositions%>">
562        of <%=matchingPositions%>
563     
564        <%
565        if (positionIndex == 0)
566        {
567          %>
568          <base:icon image="first_gray.gif" />
569          <%
570        }
571        else
572        {
573          %>
574          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=0"
575            title="Go the first position"><base:icon image="first.gif" /></a>
576          <%
577        }
578        if (positionIndex <= 0)
579        {
580          %>
581          <base:icon image="previous_gray.gif" />
582          <%
583        }
584        else
585        {
586          %>
587          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=positionIndex-1%>"
588            title="Go the previous position"><base:icon image="previous.gif" /></a>
589          <%
590        }
591        %>
592        &nbsp;&nbsp;
593        <%
594        if (positionIndex == matchingPositions - 1 || positionIndex < 0)
595        {
596          %>
597          <base:icon image="next_gray.gif" />
598          <%
599        }
600        else
601        {
602          %>
603          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=positionIndex+1%>"
604            title="Go the next position"><base:icon image="next.gif" /></a>
605          <%
606        }
607        if (positionIndex == matchingPositions - 1)
608        {
609          %>
610          <base:icon image="last_gray.gif" />
611          <%
612        }
613        else
614        {
615          %>
616          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=matchingPositions-1%>"
617            title="Go the last position"><base:icon image="last.gif" /></a>
618          <%
619        }
620        %>
621        [ <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-1"
622          title="Show all positions">all</a>
623        | <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-2"
624          title="Calculate average values for each bioassay">avg</a>
625        ]
626        </h4>
627     
628      </form>
629    <%
630    if (cc.getMessage() != null)
631    {
632      %>
633      <div class="error"><%=cc.getMessage()%></div>
634      <%
635      cc.setMessage(null);
636    }
637    %>
638   
639    <%
640    if (spotData != null)
641    {
642      Formatter<Number> numberFormatter = FormatterFactory.getNumberFormatter(sc);
643      %>
644
645    <tbl:table 
646      id="spotdata" 
647      clazz="itemlist" 
648      columns="<%=cc.getSetting("columns")%>"
649      sortby="<%=cc.getSortProperty()%>" 
650      direction="<%=cc.getSortDirection()%>"
651      title="<%=title%>"
652      action="index.jsp"
653      sc="<%=sc%>"
654      item="<%=itemType%>"
655      subcontext="<%=subContext%>"
656      >
657      <tbl:hidden 
658        name="bioassayset_id" 
659        value="<%=String.valueOf(bioAssaySetId)%>" 
660      />
661      <%
662      for (AnnotationType at : selectedAnnotationTypes.keySet())
663      {
664        %>
665        <tbl:columndef
666          id="<%="annotation." + at.getId()%>"
667          title="<%=HTML.encodeTags(at.getName()) %>"
668          show="always"
669        />
670        <%
671      }
672      %>
673      <tbl:columndef
674        id="bioassay"
675        property="COLUMN"
676        title="Bioassay"
677        show="always"
678        sortable="true"
679      />
680      <tbl:columndef
681        id="position"
682        property="POSITION"
683        title="Position"
684        show="<%=isAveraging ? "never" : "always" %>"
685        sortable="true"
686      />
687      <tbl:columndef
688        id="count"
689        title="Count"
690        show="<%=isAveraging ? "always" : "never" %>"
691      />
692      <%
693      for (int ch = 1; ch <= channels; ++ch)
694      {
695        %>
696        <tbl:columndef
697          id="<%="ch"+ch%>"
698          property="<%="%"+ch%>"
699          datatype="float"
700          title="<%="Ch " + ch%>"
701          tooltip="<%=transform.isTransformed() ? transform.toString() : null %>"
702          sortable="true"
703          filterable="true"
704          exportable="true"
705          formatter="<%=numberFormatter%>"
706        />
707        <%
708      }
709      %>
710      <%
711      for (TableColumn tc : columns)
712      {
713        %>
714        <tbl:columndef
715          id="<%=tc.getId()%>"
716          property="<%=tc.getProperty()%>"
717          datatype="<%=tc.getDatatype().getStringValue()%>"
718          title="<%=HTML.encodeTags(tc.getTitle())%>"
719          sortable="<%=tc.getSortable()%>"
720          filterable="<%=tc.getFilterable()%>"
721          exportable="<%=tc.getExportable()%>"
722          show="<%=!isAveraging || tc.isAveragable() ? tc.getShow() : "never"%>"
723          formatter="<%=tc.getFormatter()%>"
724        />
725        <%
726      }
727      %>
728       
729      <tbl:toolbar>
730        <tbl:button 
731          image="columns.gif" 
732          onclick="configureColumns()" 
733          title="Columns&hellip;" 
734          tooltip="Show, hide and re-order columns" 
735        />
736        <tbl:button 
737          image="plotter.gif"
738          onclick="plotSpotData()"
739          title="Plot&hellip;"
740          tooltip="Plot selected data from this table"
741        />
742      </tbl:toolbar>
743      <tbl:data>
744        <tbl:columns />
745        <tbl:rows>
746        <%
747        int index = 0;
748        float[] intensity = new float[channels+1];
749        while (spotData.hasNext())
750        {
751          SqlResult item = spotData.next();
752          index++;
753          BioAssay bioAssay = explorer.getBioAssay(dc, item.getShort(1));
754          for (int ch = 1; ch <= channels; ++ch)
755          {
756            intensity[ch] = item.getFloat(2+ch);
757          }
758          %>
759          <tbl:row>
760            <%
761            for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
762            {
763              AnnotationType at = entry.getKey();
764              AnnotationGroup annotationGroup = entry.getValue().getAnnotationGroup(bioAssay.getDataCubeColumnNo());
765              String allValues = annotationGroup.getTitle();
766              if (hasRatio)
767              {
768                float logRatio = (float)(Math.log(transform.unTransform(intensity[1]) / transform.unTransform(intensity[2])));
769                annotationGroup.addStatistics("logratio", logRatio);
770                annotationGroup.addStatistics("logratio2", logRatio * logRatio);
771              }
772              for (int ch = 1; ch <= channels; ++ch)
773              {
774                annotationGroup.addValue(ch, (float)transform.unTransform(intensity[ch]));
775              }
776              %>
777              <tbl:cell column="<%="annotation."+at.getId()%>" style="<%="background: "+annotationGroup.getColor()+";"%>">
778              <%=allValues%>
779              </tbl:cell>
780              <%
781            }
782            %>
783            <tbl:cell column="bioassay"><%=Base.getLinkedName(ID, bioAssay, false, true)%></tbl:cell>
784            <tbl:cell column="position"><%=item.getInt(2)%></tbl:cell>
785            <tbl:cell column="count"><%=item.getInt(2)%></tbl:cell>
786            <%
787            for (int ch = 1; ch <= channels; ++ch)
788            {
789              %>
790              <tbl:cell column="<%="ch" + ch%>" value="<%=intensity[ch]%>" />
791              <%
792            }
793            %>
794            <%
795            int colIndex = 3 + channels;
796            for (String columnId : selected.selectedIds)
797            {
798              %>
799              <tbl:cell column="<%=columnId%>" value="<%=item.getObject(colIndex++)%>" />
800              <%
801            }
802            %>
803          </tbl:row>
804          <%
805        }
806      %>
807      </tbl:rows>
808      </tbl:data>
809      </tbl:table>
810      </div>
811      <%
812      }
813      %>
814      <script language="JavaScript" defer="defer">
815      <%
816      for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
817      {
818        AnnotationType at = entry.getKey();
819        AnnotationSummary summary = entry.getValue();
820        %>
821        <%
822        for (AnnotationGroup ag : summary.getAnnotationGroups())
823        {
824          for (int ch = 1; ch <= channels; ++ch)
825          {
826            %>
827            var div = document.getElementById('mean.<%=at.getId()%>.<%=ag.getId()%>.ch<%=ch%>');
828            div.innerHTML = '<%=Values.formatNumber(ag.getMean(ch), 2)%>';
829            <%
830          }
831          %>
832          var div = document.getElementById('count.<%=at.getId()%>.<%=ag.getId()%>');
833          div.innerHTML = '<%=ag.getCount(1)%>';
834          <%
835          if (hasRatio)
836          {
837            float r = ag.getStatistics("logratio");
838            int count = ag.getCount(1);
839            float gMean = count > 0 ? (float)Math.exp(r / count) : Float.NaN;
840            float sd = count > 1 ? 
841              (float)Math.sqrt((ag.getStatistics("logratio2") - r * (r / count))/(count-1))
842              : Float.NaN;
843            %>
844            var div = document.getElementById('gmean.<%=at.getId()%>.<%=ag.getId()%>');
845            div.innerHTML = '<%=Values.formatNumber(gMean, 2)%>';
846            var div = document.getElementById('sd.<%=at.getId()%>.<%=ag.getId()%>');
847            div.innerHTML = '<%=Values.formatNumber(sd, 2)%>';
848            <%
849          }
850        }
851      }
852      %>
853      MultiOptions.init();
854      var options = new Array();
855      <%
856      if (annotationTypes != null)
857      {
858        for (AnnotationType at : annotationTypes)
859        {
860          String isSelected = selectedAnnotationTypes.containsKey(at) ? "true" : "false";
861          %>
862          options[options.length] = {key:'<%=at.getId()%>', value:'<%=HTML.javaScriptEncode(at.getName())%>', selected:<%=isSelected%>};
863          <%
864        }
865      }
866      %>
867      MultiOptions.enableForField('annotationSummary', 'display:annotationTypes', 'annotationtype_id', 1, options);
868      </script>
869     
870      </t:tab>
871      </t:tabcontrol>
872
873  </base:body>
874  </base:page>
875  <%
876}
877finally
878{
879  if (spotData != null) spotData.close();
880  if (dc != null) dc.close();
881}
882
883%>
Note: See TracBrowser for help on using the repository browser.