1 | <%-- $Id: jep_intensity_transformer.jsp 2993 2006-12-01 14:34:35Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) Authors contributing to this file. |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 2 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page session="false" |
---|
28 | import="net.sf.basedb.core.SessionControl" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.RawDataType" |
---|
33 | import="net.sf.basedb.core.BioAssaySet" |
---|
34 | import="net.sf.basedb.core.Formula" |
---|
35 | import="net.sf.basedb.core.Job" |
---|
36 | import="net.sf.basedb.core.ItemQuery" |
---|
37 | import="net.sf.basedb.core.ItemResultList" |
---|
38 | import="net.sf.basedb.core.Include" |
---|
39 | import="net.sf.basedb.core.PluginConfigurationRequest" |
---|
40 | import="net.sf.basedb.core.RequestInformation" |
---|
41 | import="net.sf.basedb.core.query.Orders" |
---|
42 | import="net.sf.basedb.core.query.Hql" |
---|
43 | import="net.sf.basedb.clients.web.Base" |
---|
44 | import="net.sf.basedb.clients.web.WebException" |
---|
45 | import="net.sf.basedb.clients.web.util.HTML" |
---|
46 | import="net.sf.basedb.util.Values" |
---|
47 | import="java.util.List" |
---|
48 | %> |
---|
49 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
50 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
51 | <% |
---|
52 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
53 | final String ID = sc.getId(); |
---|
54 | final ItemContext cc = sc.getCurrentContext(Item.BIOASSAYSET); |
---|
55 | DbControl dc = null; |
---|
56 | try |
---|
57 | { |
---|
58 | String errorMessage = (String)sc.getSessionSetting("plugin.configure.errors.message"); |
---|
59 | List<Throwable> errors = (List<Throwable>)sc.getSessionSetting("plugin.configure.errors.list"); |
---|
60 | |
---|
61 | PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request"); |
---|
62 | RequestInformation info = pcRequest.getRequestInformation(); |
---|
63 | |
---|
64 | dc = sc.newDbControl(); |
---|
65 | Job job = (Job)sc.getSessionSetting("plugin.configure.job"); |
---|
66 | dc.reattachItem(job); |
---|
67 | BioAssaySet source = null; |
---|
68 | source = (BioAssaySet)job.getParameterValue("source"); |
---|
69 | if (source == null && cc.getId() != 0) source = BioAssaySet.getById(dc, cc.getId()); |
---|
70 | if (source == null) throw new WebException("popup", "No current bioassay set", |
---|
71 | "Could not find any current bioassay set. Please select a bioassay set before trying again"); |
---|
72 | int maxRawMappings = source.getMaxRawMappingsForSpot(); |
---|
73 | |
---|
74 | RawDataType rdt = source.getRawDataType(); |
---|
75 | |
---|
76 | // Current parameter values |
---|
77 | String childName = Values.getString((String)job.getParameterValue("childName"), source.getName()); |
---|
78 | String childDescription = (String)job.getParameterValue("childDescription"); |
---|
79 | String transformationName = (String)job.getParameterValue("transformationName"); |
---|
80 | |
---|
81 | // Predefined formulas |
---|
82 | ItemQuery<Formula> formulaQuery = Formula.getQuery(Formula.Type.INTENSITY_TRANSFORMATION, rdt); |
---|
83 | formulaQuery.order(Orders.asc(Hql.property("name"))); |
---|
84 | formulaQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); |
---|
85 | ItemResultList<Formula> formulas = formulaQuery.list(dc); |
---|
86 | %> |
---|
87 | <base:page type="popup" title="Transform intensities"> |
---|
88 | <base:head styles="parameters.css"> |
---|
89 | <script language="JavaScript"> |
---|
90 | function hideErrorList() |
---|
91 | { |
---|
92 | Main.hide('errorlist'); |
---|
93 | Main.show('showerrorlist'); |
---|
94 | } |
---|
95 | function showErrorList() |
---|
96 | { |
---|
97 | Main.show('errorlist'); |
---|
98 | Main.hide('showerrorlist'); |
---|
99 | } |
---|
100 | function presetOnChange() |
---|
101 | { |
---|
102 | var frm = document.forms['transformation']; |
---|
103 | var formulaId = frm.presets[frm.presets.selectedIndex].value; |
---|
104 | frm['parameter:transformationName'].value = frm.presets[frm.presets.selectedIndex].text; |
---|
105 | for (var ch = 1; ch <= <%=rdt.getChannels()%>; ch++) |
---|
106 | { |
---|
107 | frm['parameter:ch'+ch+'.expression'].value = formulas[formulaId+'.'+ch]; |
---|
108 | } |
---|
109 | frm.presets.selectedIndex = 0; |
---|
110 | } |
---|
111 | function openExpressionBuilder(title, inputName) |
---|
112 | { |
---|
113 | Main.expressionBuilder('<%=ID%>', title, 'transformation', inputName, 'INTENSITY_TRANSFORMATION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false, '<%=source.getId()%>'); |
---|
114 | } |
---|
115 | function validate() |
---|
116 | { |
---|
117 | var frm = document.forms['transformation']; |
---|
118 | for (var ch = 1; ch <= <%=rdt.getChannels()%>; ch++) |
---|
119 | { |
---|
120 | var inputName = 'parameter:ch'+ch+'.expression'; |
---|
121 | if (Main.trimString(frm[inputName].value) == '') |
---|
122 | { |
---|
123 | alert('You must enter an expression for channel ' + ch); |
---|
124 | frm[inputName].focus(); |
---|
125 | return false; |
---|
126 | } |
---|
127 | else if (<%=maxRawMappings != 1 ? "true" : "false"%> && frm[inputName].value.search(/raw\(/) != -1) |
---|
128 | { |
---|
129 | alert('Can\'t use function raw() for bioassaysets with multiple mappings to raw data'); |
---|
130 | frm[inputName].focus(); |
---|
131 | return false; |
---|
132 | } |
---|
133 | } |
---|
134 | return true; |
---|
135 | } |
---|
136 | function doNext() |
---|
137 | { |
---|
138 | if (validate()) |
---|
139 | { |
---|
140 | var frm = document.forms['transformation']; |
---|
141 | frm.submit(); |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | var formulas = new Array(); |
---|
146 | function init() |
---|
147 | { |
---|
148 | <% |
---|
149 | for (Formula f : formulas) |
---|
150 | { |
---|
151 | for (int ch = 1; ch <= rdt.getChannels(); ++ch) |
---|
152 | { |
---|
153 | String formula = f.getFormula(ch-1); |
---|
154 | %> |
---|
155 | formulas['<%=f.getId()%>.<%=ch%>'] = '<%=HTML.javaScriptEncode(formula)%>'; |
---|
156 | <% |
---|
157 | } |
---|
158 | } |
---|
159 | %> |
---|
160 | } |
---|
161 | </script> |
---|
162 | </base:head> |
---|
163 | <base:body onload="init()"> |
---|
164 | <form name="transformation" action="index.jsp" method="get" onsubmit="return false;"> |
---|
165 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
166 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
167 | <input type="hidden" name="parameter:source" value="<%=source.getId()%>"> |
---|
168 | |
---|
169 | <h3 class="docked">Transform intensities <base:help helpid="jepintensitytransformer.options"/></h3> |
---|
170 | <div class="boxed"> |
---|
171 | <% |
---|
172 | if (errorMessage != null || (errors != null && errors.size() > 0)) |
---|
173 | { |
---|
174 | %> |
---|
175 | <div id="errors" style="margin-bottom: 12px;" class="parameterhelp"> |
---|
176 | <div class="error" style="margin: 0px;"> |
---|
177 | <%=errorMessage %> |
---|
178 | </div> |
---|
179 | <% |
---|
180 | if (errors != null && errors.size() > 0) |
---|
181 | { |
---|
182 | %> |
---|
183 | <div id="showerrorlist" style="display: none;"> |
---|
184 | <base:icon image="bullet.gif" /><a href="javascript:showErrorList()">Show details</a> |
---|
185 | </div> |
---|
186 | <div id="errorlist"> |
---|
187 | <ol> |
---|
188 | <% |
---|
189 | for (Throwable t : errors) |
---|
190 | { |
---|
191 | %> |
---|
192 | <li><%=t.getMessage()%><br> |
---|
193 | <% |
---|
194 | } |
---|
195 | %> |
---|
196 | </ol> |
---|
197 | <base:icon image="bullet.gif" /><a href="javascript:hideErrorList()">Hide details</a> |
---|
198 | </div> |
---|
199 | <% |
---|
200 | } |
---|
201 | %> |
---|
202 | </div> |
---|
203 | <% |
---|
204 | } |
---|
205 | %> |
---|
206 | |
---|
207 | <table class="form" width="100%"> |
---|
208 | <tr valign="top"> |
---|
209 | <td class="prompt">Source bioassay set</td> |
---|
210 | <td><%=HTML.encodeTags(source.getName())%></td> |
---|
211 | </tr> |
---|
212 | <tr> |
---|
213 | <td class="prompt" colspan="2">Child bioassay set</td> |
---|
214 | </tr> |
---|
215 | <tr> |
---|
216 | <td style="text-align: right">Name</td> |
---|
217 | <td> |
---|
218 | <input type="text" class="text required" size="50" maxlength="255" name="parameter:childName" |
---|
219 | value="<%=HTML.encodeTags(childName)%>"></td> |
---|
220 | </tr> |
---|
221 | <tr valign="top"> |
---|
222 | <td style="text-align: right">Description</td> |
---|
223 | <td nowrap> |
---|
224 | <textarea class="text" rows="4" cols="50" name="parameter:childDescription" wrap="virtual" |
---|
225 | ><%=HTML.encodeTags(childDescription)%></textarea> |
---|
226 | <a href="javascript:Main.zoom('Description', 'transformation', 'parameter:childDescription')" |
---|
227 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
228 | </td> |
---|
229 | </tr> |
---|
230 | <tr> |
---|
231 | <td class="prompt">Transformation</td> |
---|
232 | <td> |
---|
233 | <% |
---|
234 | if (formulas.size() > 0) |
---|
235 | { |
---|
236 | %> |
---|
237 | <select name="presets" style="width: 32em;" |
---|
238 | onchange="presetOnChange()" |
---|
239 | > |
---|
240 | <option value="">- select from list or enter formula below - |
---|
241 | <% |
---|
242 | for (Formula f : formulas) |
---|
243 | { |
---|
244 | boolean ok = true; |
---|
245 | if (maxRawMappings != 1) |
---|
246 | { |
---|
247 | for (String formula : f.getFormulas()) |
---|
248 | { |
---|
249 | ok &= !formula.contains("raw("); |
---|
250 | } |
---|
251 | } |
---|
252 | if (ok) |
---|
253 | { |
---|
254 | %> |
---|
255 | <option value="<%=f.getId()%>" title="<%=HTML.encodeTags(f.getDescription())%>" |
---|
256 | ><%=HTML.encodeTags(f.getName())%> |
---|
257 | <% |
---|
258 | } |
---|
259 | } |
---|
260 | %> |
---|
261 | </select> |
---|
262 | <% |
---|
263 | } |
---|
264 | %> |
---|
265 | </td> |
---|
266 | </tr> |
---|
267 | <tr> |
---|
268 | <td style="text-align: right">Name</td> |
---|
269 | <td> |
---|
270 | <input type="text" class="text" size="50" maxlength="255" name="parameter:transformationName" |
---|
271 | value="<%=HTML.encodeTags(transformationName)%>"></td> |
---|
272 | </tr> |
---|
273 | |
---|
274 | <% |
---|
275 | for (int ch = 1; ch <= rdt.getChannels(); ++ch) |
---|
276 | { |
---|
277 | String inputName = "parameter:ch" + ch + ".expression"; |
---|
278 | String value = (String)job.getParameterValue("ch"+ch+".expression"); |
---|
279 | if (value == null) value = (String)info.getParameter("ch"+ch+".expression").getParameterType().getDefaultValue(); |
---|
280 | %> |
---|
281 | <tr valign="top"> |
---|
282 | <td style="text-align: right">Ch <%=ch%></td> |
---|
283 | <td> |
---|
284 | <table border="0" cellspacing="0" cellpadding="0"> |
---|
285 | <tr valign="top"> |
---|
286 | <td> |
---|
287 | <input type="text" class="text required" name="<%=inputName%>" |
---|
288 | size="50" |
---|
289 | value="<%=HTML.encodeTags(value)%>"> |
---|
290 | </td> |
---|
291 | <td><base:button onclick="<%="openExpressionBuilder('Ch "+ch+" expression', '"+inputName+"')"%>" |
---|
292 | title="" |
---|
293 | image="expression_builder.gif" |
---|
294 | tooltip="A simple utility for building expressions" /> |
---|
295 | </td> |
---|
296 | </tr> |
---|
297 | </table> |
---|
298 | </td> |
---|
299 | </tr> |
---|
300 | <% |
---|
301 | } |
---|
302 | %> |
---|
303 | </table> |
---|
304 | </div> |
---|
305 | </form> |
---|
306 | |
---|
307 | <table align="center"> |
---|
308 | <tr> |
---|
309 | <td width="50%"><base:button onclick="doNext();" title="Next" /></td> |
---|
310 | <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td> |
---|
311 | </tr> |
---|
312 | </table> |
---|
313 | </base:body> |
---|
314 | </base:page> |
---|
315 | <% |
---|
316 | } |
---|
317 | finally |
---|
318 | { |
---|
319 | if (dc != null) dc.close(); |
---|
320 | }%> |
---|