source: extensions/net.sf.basedb.mev/trunk/resources/launch_mev.jsp @ 1156

Last change on this file since 1156 was 1156, checked in by Nicklas Nordborg, 14 years ago

References #241: Add MeV Analysis file as a file type for bioassay sets

The MeV analysis file type is now supported by the launch functionality. There is still no automatic installation. This must be done manually. Eg. create a data file type with external id=mev.anl; name=MeV analysis file; extension=anl; generic file type=Spot data; Item type=Bioassay set.

Also, MeV is not able to open the file yet. We need the wrapper for that.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.1 KB
Line 
1<%-- $Id: launch_mev.jsp 1156 2009-09-14 11:44:09Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Nicklas Nordborg
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 Jari, Nicklas
25--%>
26<%@ page
27  pageEncoding="UTF-8"
28  session="false"
29  import="net.sf.basedb.core.Application"
30  import="net.sf.basedb.core.BioAssaySet"
31  import="net.sf.basedb.core.Experiment"
32  import="net.sf.basedb.core.Directory"
33  import="net.sf.basedb.core.File"
34  import="net.sf.basedb.core.User"
35  import="net.sf.basedb.core.DbControl"
36  import="net.sf.basedb.core.SessionControl"
37  import="net.sf.basedb.core.ItemContext"
38  import="net.sf.basedb.core.Item"
39  import="net.sf.basedb.core.Include"
40  import="net.sf.basedb.core.Permission"
41  import="net.sf.basedb.core.Path"
42  import="net.sf.basedb.core.FileStoreUtil"
43  import="net.sf.basedb.core.ItemQuery"
44  import="net.sf.basedb.core.PluginConfiguration"
45  import="net.sf.basedb.core.query.Restrictions"
46  import="net.sf.basedb.core.query.Expressions"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.core.query.Orders"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.util.Values"
53  import="java.util.List"
54%>
55<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
56<%
57final SessionControl sc = Base.getExistingSessionControl(request, true);
58final String ID = sc.getId();
59final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
60final String title = "Launch MeV";
61final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
62final String root = request.getContextPath()+"/";
63
64DbControl dc = null;
65String defaultPath = "/";
66
67try
68{
69  dc = sc.newDbControl();
70  BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId);
71  ItemContext cc = sc.getCurrentContext(Item.BIOASSAYSET);
72  cc.setId(bioAssaySetId);
73
74  // Get the current files
75  File tdmsFile = FileStoreUtil.getDataFile(dc, bas, "mev.tdms");
76  File cghFile = FileStoreUtil.getDataFile(dc, bas, "mev.cgh");
77  File anlFile = FileStoreUtil.getDataFile(dc, bas, "mev.anl");
78  boolean allowCreateFile = bas.hasPermission(Permission.WRITE)
79    && sc.hasPermission(Permission.CREATE, Item.FILE);
80 
81  // Get the avilable CGH export configurations
82  ItemQuery<PluginConfiguration> cghQuery = PluginConfiguration.getQuery();
83  cghQuery.restrict(Restrictions.eq(
84      Hql.property("pluginDefinition.className"),
85      Expressions.string("net.sf.basedb.mev.plugin.CghExporterPlugin")));
86  cghQuery.order(Orders.asc(Hql.property("name")));
87  cghQuery.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
88  List<PluginConfiguration> cghConfigurations = cghQuery.list(dc);
89  boolean canCreateCGHFile = cghConfigurations.size() > 0;
90 
91  // Default names of export files and export jobs
92  String defaultTdmsFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".tdms.txt", "");
93  String defaultCghFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".cgh.txt", "");
94  String tdmsJobName = "Create TDMS file for " + bas.getName();
95  String cghJobName = "Create CGH file for " + bas.getName();
96 
97  // Default home directory of either experiment or user
98  try
99  {
100    Experiment exp = bas.getExperiment();
101    Directory dir = exp.getDirectory();
102    if (dir == null)
103    {
104      User user = User.getById(dc, sc.getLoggedInUserId());
105      dir = user.getHomeDirectory();
106    }
107    if (dir != null)
108    {
109      defaultPath = dir.getPath().toString() + "/";
110    }
111  }
112  catch (Throwable t)
113  {}
114%>
115<base:page type="popup" title="<%=title%>">
116<base:head>
117  <script language="JavaScript">
118  function launchMev(fileType)
119  {
120    var url = 'mev_jnlp.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
121    url += '&filetype=' + fileType;
122    window.opener.location.href = url;
123    setTimeout('window.close()', 500);
124  }
125  function exportTdms()
126  {
127    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
128    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.TdmsExporterPlugin';
129    url += '&item_type=BIOASSAYSET&context_type=ITEM';
130    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(tdmsJobName)%>');
131    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultTdmsFileName)%>');
132    url += '&parameter:attachToBioAssaySet=true';
133    Main.openPopup(url, 'CreateTDMSFile', 740, 540);
134    window.close();
135  }
136  function exportCgh()
137  {
138    var frm = document.forms['mev'];
139    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
140    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.CghExporterPlugin';
141    url += '&pluginconfiguration_id=' + frm.cgh_configuration[frm.cgh_configuration.selectedIndex].value;
142    url += '&item_type=BIOASSAYSET&context_type=ITEM';
143    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(cghJobName)%>');
144    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultCghFileName)%>');
145    url += '&parameter:attachToBioAssaySet=true';
146    Main.openPopup(url, 'CreateCGHFile', 740, 540);
147    window.close();
148  }
149  </script>
150</base:head>
151<base:body>
152
153  <form name="mev">
154  <h3><%=title%></h3>
155  <div class="boxedbottom">
156  <table class="form">
157  <tr>
158    <td class="prompt" colspan="2">MeV analysis file</td>
159  </tr>
160  <tr>
161    <td><base:button title="Start MeV" 
162      onclick="launchMev('mev.anl')" 
163      image="<%=anlFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>" 
164      disabled="<%=anlFile == null%>"/></td>
165    <td>
166    <%
167    if (anlFile == null)
168    {
169      %>
170      There is currently no MeV analysis file associated with the bioassay set.
171      <%
172    }
173    else
174    {
175      %>
176      Start MeV with the current analysis file:<br>
177      <%=HTML.encodeTags(anlFile.getName())%> <%=Base.getFileLinks(ID, anlFile, root) %>
178      <%
179    }
180    %>
181    </td>
182  </tr>
183  <tr>
184    <td class="prompt" colspan="2">TDMS - Tab-delimited multiple sample</td>
185  </tr>
186  <tr>
187    <td><base:button title="Start MeV" 
188      onclick="launchMev('mev.tdms')" 
189      image="<%=tdmsFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>" 
190      disabled="<%=tdmsFile == null%>"/></td>
191    <td>
192    <%
193    if (tdmsFile == null)
194    {
195      %>
196      There is currently no TDMS file associated with the bioassay set.
197      <%
198    }
199    else
200    {
201      %>
202      Start MeV with the current TDMS file:<br>
203      <%=HTML.encodeTags(tdmsFile.getName())%> <%=Base.getFileLinks(ID, tdmsFile, root) %>
204      <%
205    }
206    %>
207    </td>
208  </tr>
209  <tr>
210    <td><base:button title="Export" 
211      onclick="exportTdms()"
212      disabled="<%=!allowCreateFile%>" 
213      image="<%=allowCreateFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
214    <td>
215    <%
216    if (allowCreateFile)
217    {
218      %>
219      Export the spot data to a MeV TDMS file that can be opened with MeV.
220      <%
221    }
222    else
223    {
224      %>
225      You don't have enough permissions to create a MeV TDSM file.
226      <%
227    }
228    %>
229    </td>
230  </tr>
231  <tr>
232    <td class="prompt" colspan="2">CGH - Comparative genomics hybridization</td>
233  </tr>
234  <tr>
235    <td><base:button title="Start MeV" 
236      onclick="launchMev('mev.cgh')" 
237      image="<%=cghFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>" 
238      disabled="<%=cghFile == null%>"/></td>
239    <td>
240    <%
241    if (cghFile == null)
242    {
243      %>
244      There is currently no CGH file associated with the bioassay set.
245      <%
246    }
247    else
248    {
249      %>
250      Start MeV with the current CGH file:<br>
251      <%=HTML.encodeTags(cghFile.getName())%> <%=Base.getFileLinks(ID, cghFile, root) %>
252      <%
253    }
254    %>
255    </td>
256  </tr>
257  <tr>
258    <td><base:button title="Export" 
259      onclick="exportCgh()" 
260      disabled="<%=!canCreateCGHFile%>" 
261      image="<%=canCreateCGHFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
262    <td>
263    <%
264    if (canCreateCGHFile)
265    {
266      %>
267      Export the spot data to a MeV CGH file that can be opened with MeV.
268      <%
269    }
270    else
271    {
272      %>
273      You don't have enough permissions to create a MeV CGH file.
274      <%
275    }
276    %>
277    </td>
278  </tr>
279  <%
280  if (canCreateCGHFile)
281  {
282    %>
283    <tr>
284      <td style="text-align: right;">-configuration</td>
285      <td>
286        <select name="cgh_configuration">
287        <%
288        for (PluginConfiguration cfg : cghConfigurations)
289        {
290          %>
291          <option value="<%=cfg.getId()%>"><%=HTML.encodeTags(cfg.getName())%>
292          <%
293        }
294        %>
295        </select>
296      </td>
297    </tr>
298    <%
299  }
300  %>
301  </table>
302  </div>
303  </form>
304
305  <table align="center">
306  <tr>
307    <td><base:button onclick="window.close();" title="Close" /></td>
308  </tr>
309  </table>
310
311</base:body>
312</base:page>
313  <%
314}
315finally
316{
317  if (dc != null) dc.close();
318}
319%>
Note: See TracBrowser for help on using the repository browser.