Changeset 1083


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.

Location:
extensions/net.sf.basedb.mev/trunk
Files:
2 added
2 deleted
5 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.mev/trunk/META-INF/extensions.xml

    r1068 r1083  
    2929      </factory-class>
    3030      <parameters>
    31         <requireMevFile>true</requireMevFile>
     31        <requireSpotData>true</requireSpotData>
    3232        <title>Start MeV</title>
    33         <tooltip>Launch MeV with data from this bioassay set</tooltip>
     33        <tooltip>
     34          Launch MeV with data from this bioassay set. If
     35          you have not yet created any MeV file you will be
     36          given the option to do so.
     37        </tooltip>
    3438        <onClick>MeV.launch($ID$)</onClick>
    3539        <icon>~/images/tm4_launch.png</icon>
    36         <script>~/scripts/mev.jsp</script>
    37       </parameters>
    38     </action-factory>
    39   </extension>
    40   <extension
    41     id="net.sf.basedb.mev.launchexport"
    42     extends="net.sf.basedb.clients.web.bioassayset.list.tools"
    43     >
    44     <index>2</index>
    45     <about>
    46       <name>MeV TDMS Export</name>
    47       <description>
    48         Adds an action to the "Tools" column that exports data to a
    49         MeV TDMS file.
    50       </description>
    51     </about>
    52     <action-factory>
    53       <factory-class>
    54         net.sf.basedb.mev.factory.MevButtonFactory
    55       </factory-class>
    56       <parameters>
    57         <requireMevFile>false</requireMevFile>
    58         <requireSpotData>true</requireSpotData>
    59         <requireWritePermission>true</requireWritePermission>
    60         <title>Generate MeV TDMS file</title>
    61         <tooltip>Create a MeV TDMS file from the data in this bioassay set</tooltip>
    62         <onClick>MeV.createTDMS($ID$)</onClick>
    63         <icon>~/images/tm4_export.png</icon>
    6440        <script>~/scripts/mev.jsp</script>
    6541      </parameters>
  • 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>
  • extensions/net.sf.basedb.mev/trunk/resources/mev_jnlp.jsp

    r1028 r1083  
    4040final String ID = sc.getId();
    4141final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
     42final String fileType = Values.getString(request.getParameter("filetype"));
     43final String mevFileType = "mev.cgh".equals(fileType) ? "cgh" : "tdms";
    4244final String scheme = request.getScheme();
    4345final String serverName = request.getServerName();
     
    121123  <application-desc main-class="org.tigr.microarray.mev.TMEV">
    122124    <argument>-fileType</argument>
    123     <argument>tdms</argument>
     125    <argument><%=mevFileType%></argument>
    124126    <argument>-fileUrl</argument>
    125     <argument><%=fullHomeUrl%>/MevExport/<%=ID%>/<%=bioAssaySetId%>.servlet</argument>
     127    <argument><%=fullHomeUrl%>/MevExport/<%=ID%>/<%=bioAssaySetId%>/<%=fileType%>.servlet</argument>
    126128  </application-desc>
    127129</jnlp>
  • extensions/net.sf.basedb.mev/trunk/resources/scripts/mev.jsp

    r1069 r1083  
    1515    url += '?ID='+getSessionId();
    1616    url += '&bioassayset_id=' + bioAssaySetId;
    17     location.href = url;
    18   }
    19  
    20   this.createTDMS = function(bioAssaySetId)
    21   {
    22     var url = '<%=homeUrl%>/launch_export.jsp';
    23     url += '?ID='+getSessionId();
    24     url += '&bioassayset_id=' + bioAssaySetId;
    25     Main.openPopup(url, 'CreateTDMSFile', 400, 300);
     17    Main.openPopup(url, 'LaunchMev', 500, 340);
    2618  }
    2719
  • extensions/net.sf.basedb.mev/trunk/src/net/sf/basedb/mev/factory/MevButtonFactory.java

    r974 r1083  
    6363  extends FixedButtonFactory
    6464{
    65   private Boolean requireMevFile;
     65  private String requireMevFile;
    6666  private Boolean requireSpotData;
    6767  private Boolean requireWritePermission;
     
    8686      BioAssaySet bas = (BioAssaySet)currentItem;
    8787      DbControl dc = context.getClientContext().getDbControl();
    88       boolean hasMevFile = hasAccessibleMevFile(dc, bas);
    8988      boolean hasSpotData = bas.getNumSpots() > 0;
    9089      boolean hasWritePermission = bas.hasPermission(Permission.WRITE);
    9190      boolean createAction = true;
    92       if (getRequireMevFile() != null) createAction &= getRequireMevFile() == hasMevFile;
     91      if (getRequireMevFile() != null) createAction &= hasAccessibleMevFile(dc, bas, getRequireMevFile());
    9392      if (getRequireSpotData() != null) createAction &= getRequireSpotData() == hasSpotData;
    9493      if (getRequireWritePermission() != null) createAction &= getRequireWritePermission() == hasWritePermission;
     
    114113
    115114  /**
    116     @since 1.1
     115    @since 1.3
    117116  */
    118117  public void setRequireMevFile(String requireMevFile)
    119118  {
    120     this.requireMevFile = Values.getBoolean(requireMevFile);
     119    this.requireMevFile = requireMevFile;
    121120  }
    122121 
    123122  /**
    124     @since 1.1
     123    @since 1.3
    125124  */
    126   public Boolean getRequireMevFile()
     125  public String getRequireMevFile()
    127126  {
    128127    return requireMevFile;
     
    161160  }
    162161 
    163   private boolean hasAccessibleMevFile(DbControl dc, BioAssaySet bas)
     162  private boolean hasAccessibleMevFile(DbControl dc, BioAssaySet bas, String fileType)
    164163  {
    165164    File mevFile = null;
    166165    try
    167166    {
    168       mevFile = FileStoreUtil.getDataFile(dc, bas, DataFileType.MEV_TDMS);
     167      mevFile = FileStoreUtil.getDataFile(dc, bas, fileType);
    169168      if (mevFile != null)
    170169      {
  • extensions/net.sf.basedb.mev/trunk/src/net/sf/basedb/mev/plugin/CghExporterPlugin.java

    r1082 r1083  
    361361          Config.getCharset()));
    362362      parameters.add(getOverwriteParameter(null, null));
    363       if (checkCghFileType(dc) == null)
     363      if (checkCghFileType(dc) != null)
    364364      {
    365365        parameters.add(new PluginParameter<Boolean>(
  • extensions/net.sf.basedb.mev/trunk/src/net/sf/basedb/mev/servlet/MevExport.java

    r974 r1083  
    2626import net.sf.basedb.core.Application;
    2727import net.sf.basedb.core.BioAssaySet;
    28 import net.sf.basedb.core.DataFileType;
    2928import net.sf.basedb.core.File;
    3029import net.sf.basedb.core.FileStoreUtil;
     
    3231import net.sf.basedb.core.SessionControl;
    3332import net.sf.basedb.core.DbControl;
     33import net.sf.basedb.mev.Mev;
    3434import net.sf.basedb.util.Values;
    3535
     
    6363    // The bioassay set to export
    6464    int bioAssaySetId = 0;
    65    
     65    // The file type to look for
     66    String fileType = Mev.TDMS_FILE;
    6667    DbControl dc = null;
    6768    try
     
    6970      if (request.getQueryString() != null)
    7071      {
    71         // Paremeters where given on query string: ?ID=...&bioassayset_id=...
     72        // Paremeters where given on query string: ?ID=...&bioassayset_id=...&filetype=...
    7273        ID = request.getParameter("ID");
    7374        bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
     75        fileType = Values.getString(request.getParameter("filetype"), fileType);
    7476      }
    7577      else if (request.getPathInfo() != null)
    7678      {
    77         // Parameters are given as path: /ID/bioassayset_id
     79        // Parameters are given as path: /ID/bioassayset_id/filetype
    7880        String[] path = request.getPathInfo().split("/");
    79         ID = path[path.length-2];
    80         bioAssaySetId = Values.getInt(path[path.length-1]);
    81       }   
     81        ID = path[path.length-3];
     82        bioAssaySetId = Values.getInt(path[path.length-2]);
     83        fileType = path[path.length-1];
     84      }
    8285      final SessionControl sc = Application.getSessionControl(ID, request.getRemoteAddr());
    8386
     
    8588      dc = sc.newDbControl();
    8689      BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId);
    87       File mevFile = FileStoreUtil.getDataFile(dc, bas, DataFileType.MEV_TDMS);
     90      File mevFile = FileStoreUtil.getDataFile(dc, bas, fileType);
    8891     
    8992      if (mevFile == null)
    9093      {
    91         throw new ItemNotFoundException("No MeV TDMS file found on bioassay set: " +
     94        throw new ItemNotFoundException("No " + fileType + " file found on bioassay set: " +
    9295          bas.getName());
    9396      }
Note: See TracChangeset for help on using the changeset viewer.