Ignore:
Timestamp:
May 18, 2009, 2:19:18 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #212: Add support for exporting CGH data to MeV

I have changed the GUI a bit to make sure that it can handle both CGH and TDMS files. It is now also possible to generate a new export file directly from the MeV button.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.mev/trunk/resources/launch_mev.jsp

    r1070 r1083  
    3131  import="net.sf.basedb.core.Experiment"
    3232  import="net.sf.basedb.core.Directory"
     33  import="net.sf.basedb.core.File"
    3334  import="net.sf.basedb.core.User"
    3435  import="net.sf.basedb.core.DbControl"
     
    3637  import="net.sf.basedb.core.ItemContext"
    3738  import="net.sf.basedb.core.Item"
     39  import="net.sf.basedb.core.Include"
     40  import="net.sf.basedb.core.Permission"
    3841  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"
    3949  import="net.sf.basedb.clients.web.Base"
    4050  import="net.sf.basedb.clients.web.util.HTML"
    4151  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    4252  import="net.sf.basedb.util.Values"
     53  import="java.util.List"
    4354%>
    4455<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    4758final String ID = sc.getId();
    4859final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
    49 final String title = "Create MeV TDMS file?";
     60final String title = "Launch MeV";
     61final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
     62final String root = request.getContextPath()+"/";
     63
    5064DbControl dc = null;
    5165String defaultPath = "/";
    52 String defaultFileName = "";
    53 String jobName = "Create MeV TDMS file";
     66
    5467try
    5568{
     
    5871  ItemContext cc = sc.getCurrentContext(Item.BIOASSAYSET);
    5972  cc.setId(bioAssaySetId);
    60   defaultFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".tdms.txt", "");
    61   jobName += " for " + bas.getName();
     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  boolean allowCreateFile = bas.hasPermission(Permission.WRITE)
     78    && sc.hasPermission(Permission.CREATE, Item.FILE);
     79 
     80  // Get the avilable CGH export configurations
     81  ItemQuery<PluginConfiguration> cghQuery = PluginConfiguration.getQuery();
     82  cghQuery.restrict(Restrictions.eq(
     83      Hql.property("pluginDefinition.className"),
     84      Expressions.string("net.sf.basedb.mev.plugin.CghExporterPlugin")));
     85  cghQuery.order(Orders.asc(Hql.property("name")));
     86  cghQuery.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
     87  List<PluginConfiguration> cghConfigurations = cghQuery.list(dc);
     88  boolean canCreateCGHFile = cghConfigurations.size() > 0;
     89 
     90  // Default names of export files and export jobs
     91  String defaultTdmsFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".tdms.txt", "");
     92  String defaultCghFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".cgh.txt", "");
     93  String tdmsJobName = "Create TDMS file for " + bas.getName();
     94  String cghJobName = "Create CGH file for " + bas.getName();
     95 
     96  // Default home directory of either experiment or user
    6297  try
    6398  {
     
    76111  catch (Throwable t)
    77112  {}
    78 
     113%>
     114<base:page type="popup" title="<%=title%>">
     115<base:head>
     116  <script language="JavaScript">
     117  function launchMev(fileType)
     118  {
     119    var url = 'mev_jnlp.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
     120    url += '&filetype=' + fileType;
     121    window.opener.location.href = url;
     122    window.close();
     123  }
     124  function exportTdms()
     125  {
     126    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
     127    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.TdmsExporterPlugin';
     128    url += '&item_type=BIOASSAYSET&context_type=ITEM';
     129    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(tdmsJobName)%>');
     130    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultTdmsFileName)%>');
     131    url += '&parameter:attachToBioAssaySet=true';
     132    Main.openPopup(url, 'CreateTDMSFile', 740, 540);
     133    window.close();
     134  }
     135  function exportCgh()
     136  {
     137    var frm = document.forms['mev'];
     138    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
     139    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.CghExporterPlugin';
     140    url += '&pluginconfiguration_id=' + frm.cgh_configuration[frm.cgh_configuration.selectedIndex].value;
     141    url += '&item_type=BIOASSAYSET&context_type=ITEM';
     142    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(cghJobName)%>');
     143    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultCghFileName)%>');
     144    url += '&parameter:attachToBioAssaySet=true';
     145    Main.openPopup(url, 'CreateCGHFile', 740, 540);
     146    window.close();
     147  }
     148  </script>
     149</base:head>
     150<base:body>
     151
     152  <form name="mev">
     153  <h3><%=title%></h3>
     154  <div class="boxedbottom">
     155  <table class="form">
     156  <tr>
     157    <td class="prompt" colspan="2">TDMS - Tab-delimited multiple sample</td>
     158  </tr>
     159  <tr>
     160    <td><base:button title="Start MeV"
     161      onclick="launchMev('mev.tdms')"
     162      image="<%=tdmsFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>"
     163      disabled="<%=tdmsFile == null%>"/></td>
     164    <td>
     165    <%
     166    if (tdmsFile == null)
     167    {
     168      %>
     169      There is currently no TDMS file associated with the bioassay set.
     170      <%
     171    }
     172    else
     173    {
     174      %>
     175      Start MeV with the current TDMS file:<br>
     176      <%=HTML.encodeTags(tdmsFile.getName())%> <%=Base.getFileLinks(ID, tdmsFile, root) %>
     177      <%
     178    }
     179    %>
     180    </td>
     181  </tr>
     182  <tr>
     183    <td><base:button title="Export"
     184      onclick="exportTdms()"
     185      disabled="<%=!allowCreateFile%>"
     186      image="<%=allowCreateFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
     187    <td>
     188    <%
     189    if (allowCreateFile)
     190    {
     191      %>
     192      Export the spot data to a MeV TDMS file that can be opened with MeV.
     193      <%
     194    }
     195    else
     196    {
     197      %>
     198      You don't have enough permissions to create a MeV TDSM file.
     199      <%
     200    }
     201    %>
     202    </td>
     203  </tr>
     204  <tr>
     205    <td class="prompt" colspan="2">CGH - Comparative genomics hybridization</td>
     206  </tr>
     207  <tr>
     208    <td><base:button title="Start MeV"
     209      onclick="launchMev('mev.cgh')"
     210      image="<%=tdmsFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>"
     211      disabled="<%=cghFile == null%>"/></td>
     212    <td>
     213    <%
     214    if (cghFile == null)
     215    {
     216      %>
     217      There is currently no CGH file associated with the bioassay set.
     218      <%
     219    }
     220    else
     221    {
     222      %>
     223      Start MeV with the current CGH file:<br>
     224      <%=HTML.encodeTags(cghFile.getName())%> <%=Base.getFileLinks(ID, cghFile, root) %>
     225      <%
     226    }
     227    %>
     228    </td>
     229  </tr>
     230  <tr>
     231    <td><base:button title="Export"
     232      onclick="exportCgh()"
     233      disabled="<%=!canCreateCGHFile%>"
     234      image="<%=canCreateCGHFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
     235    <td>
     236    <%
     237    if (canCreateCGHFile)
     238    {
     239      %>
     240      Export the spot data to a MeV CGH file that can be opened with MeV.
     241      <%
     242    }
     243    else
     244    {
     245      %>
     246      You don't have enough permissions to create a MeV CGH file.
     247      <%
     248    }
     249    %>
     250    </td>
     251  </tr>
     252  <%
     253  if (canCreateCGHFile)
     254  {
     255    %>
     256    <tr>
     257      <td style="text-align: right;">-configuration</td>
     258      <td>
     259        <select name="cgh_configuration">
     260        <%
     261        for (PluginConfiguration cfg : cghConfigurations)
     262        {
     263          %>
     264          <option value="<%=cfg.getId()%>"><%=HTML.encodeTags(cfg.getName())%>
     265          <%
     266        }
     267        %>
     268        </select>
     269      </td>
     270    </tr>
     271    <%
     272  }
     273  %>
     274  </table>
     275  </div>
     276  </form>
     277
     278  <table align="center">
     279  <tr>
     280    <td><base:button onclick="window.close();" title="Close" /></td>
     281  </tr>
     282  </table>
     283
     284</base:body>
     285</base:page>
     286  <%
    79287}
    80288finally
     
    83291}
    84292%>
    85 <base:page type="popup" title="<%=title%>">
    86 <base:head>
    87   <script language="JavaScript">
    88   function createTDMS()
    89   {
    90     var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
    91     url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.TdmsExporterPlugin';
    92     url += '&item_type=BIOASSAYSET&context_type=ITEM';
    93     url += '&job_name=' + encodeURIComponent('<%=jobName%>');
    94     url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultFileName)%>');
    95     url += '&parameter:attachToBioAssaySet=true';
    96     Main.openPopup(url, 'CreateTDMSFile2', 740, 540);
    97     window.close();
    98   }
    99   </script>
    100 </base:head>
    101 <base:body>
    102 
    103   <base:note type="question" title="<%=title%>">
    104   The selected bioassay is not associated with a MeV TDMS file.
    105   Do you wish to create one with the MeV TDMS exporter plug-in?
    106   <br><br>
    107   </base:note>
    108   <p>
    109     <table align="center">
    110     <tr>
    111       <td width="50%"><base:button onclick="createTDMS()" title="Yes" /></td>
    112       <td width="50%"><base:button onclick="window.close()" title="No" /></td>
    113     </tr>
    114     </table>
    115   </div>
    116 
    117 </base:body>
    118 </base:page>
Note: See TracChangeset for help on using the changeset viewer.