Ignore:
Timestamp:
Dec 6, 2007, 1:04:50 PM (14 years ago)
Author:
mbayer
Message:

have implemented a skeleton writer class which writes a dummy tab2mage file

Location:
branches/uk_ac_ebi_Tab2MageImporter
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/experiment.jsp

    r512 r513  
    6464final String ID = sc.getId();
    6565final String requestID = request.getParameter("requestId");
     66
     67//we also need to figure out the name/id of the currently selected experiment that this import is getting initiated from
     68ItemContext cc = sc.getCurrentContext(Item.EXPERIMENT);
     69int experimentID = cc.getId();
     70DbControl dc = sc.newDbControl();
     71Experiment experiment = Experiment.getById(dc,experimentID);
     72String expName = experiment.getName();
     73dc.close();
     74
     75//set the experiment id in the bean so we can get at it later in the plugin
     76inputDataBean.setExperimentId(new Integer(experimentID).toString());
    6677 %>
     78 
     79 experiment name = <%=expName %><br>
     80 experiment ID = <%=experimentID %>
    6781
    6882<h2>Tab2MAGE Importer -- Your Experiment</h2>
     
    256270    <td class="boldText">Experiment Name:</td>
    257271    <td class="input"> 
    258     <textarea rows="2" cols="30" name="experimentName">my numpty experiment</textarea>
     272    <textarea rows="2" cols="30" name="experimentName"><%=expName %></textarea>
    259273    </td>
    260274    <td>The name you have chosen for the Experiment.</td>
  • branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/hybridizations.jsp

    r512 r513  
    77<!-- submits the form data back to the bean assuming that each form element is matched to a variable in the bean by the same name -->
    88<jsp:setProperty name="inputDataBean" property="*" />
    9 
    10 
    11 <html>
    12 <head>
    13 <link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" />
    14 </head>
    15 <body>
    16 
    179
    1810<%
     
    2214 %>
    2315
     16
     17<html>
     18
     19<head>
     20
     21<link rel="stylesheet" type="text/css" href="<%= request.getContextPath()%>/plugins/uk/ac/ebi/nugo/plugins/styles.css" />
     22<link rel="stylesheet" type="text/css" href="/base/include/styles/main.css">
     23<link rel="stylesheet" type="text/css" href="/base/include/styles/size_m.css">
     24
     25<script language="JavaScript" src="<%= request.getContextPath()%>/include/scripts/main.js" type="text/javascript"></script>
     26
     27<script language="JavaScript" type="text/javascript">
     28    function getRoot()
     29    {
     30      return '/base/';
     31    }
     32    function getScale()
     33    {
     34      return 1.0;
     35    }
     36    function doImport()
     37    {
     38      var frm = document.forms['hybridizations'];
     39      if (Main.trimString(frm.path.value) == '')
     40      {
     41        alert("You must select a file to import from");
     42        frm.path.focus();
     43      }
     44      else
     45      {
     46        frm.submit();
     47      }
     48    }
     49    function browseOnClick()
     50    {
     51      var frm = document.forms['hybridizations'];
     52      var url = '<%= request.getContextPath()%>/filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&title=Select+file+to+import&callback=setFileCallback';
     53      url += '&filter:INT:location=1';
     54      Main.openPopup(url, 'SelectFile', 1000, 700);
     55    }
     56    function setFileCallback(fileId, path)
     57    {
     58      var frm = document.forms['hybridizations'];
     59      frm.file_id.value = fileId;
     60      frm.path.value = path;
     61      document.getElementById('zipFile').value = path;
     62      }
     63    function recentFileOnChange()
     64    {
     65      var frm = document.forms['hybridizations'];
     66      var selected = frm.recentFile[frm.recentFile.selectedIndex];
     67      setFileCallback(selected.value, selected.text);
     68      frm.recentFile.selectedIndex = 0;
     69    }
     70
     71   
     72    </script>
     73
     74</head>
     75
     76<body>
     77
     78
     79
     80
    2481<h2>Tab2MAGE Importer -- Your Hybridizations</h2>
    2582Page 3 of 3
    2683<p>
    27 <form action="<%= request.getContextPath()%>/common/plugin/index.jsp" method="post">
     84<form name="hybridizations"action="<%= request.getContextPath()%>/common/plugin/index.jsp" method="post">
    2885<input type="hidden" name="ID" value="<%=ID%>"> <input type="hidden" name="cmd" value="SetParameters">
    2986<input type="hidden"name="requestID" value="<%=requestID%>">
     
    57114<input type="hidden" name="parameter:hybridizationProtocolParams" value="<%=inputDataBean.getHybridizationProtocolParams()%>">
    58115<input type="hidden" name="parameter:scanningProtocolParams" value="<%=inputDataBean.getScanningProtocolParams()%>">
    59 
    60 <!-- 
    61 <input type="hidden" name="parameter:platform" value="<%=inputDataBean.getPlatform()%>">
    62 <input type="hidden" name="parameter:organism" value="<%=inputDataBean.getOrganism()%>">
    63 <input type="hidden" name="parameter:numDesigns" value="<%=inputDataBean.getNumDesigns()%>">
    64 <input type="hidden" name="parameter:dyeSwap" value="<%=inputDataBean.getDyeSwap()%>">
    65 <input type="hidden" name="parameter:refSample" value="<%=inputDataBean.getRefSample()%>">
    66 <input type="hidden" name="parameter:numTreatments" value="<%=inputDataBean.getNumTreatments()%>">
    67 <input type="hidden" name="parameter:expFactors" value="<%=inputDataBean.getExpFactors()%>">
    68 <input type="hidden" name="parameter:numReplicates" value="<%=inputDataBean.getNumReplicates()%>">
    69 <input type="hidden" name="parameter:tissues" value="<%=inputDataBean.getTissues()%>">
    70 <input type="hidden" name="parameter:pooling" value="<%=inputDataBean.getPooling()%>">
    71 <input type="hidden" name="parameter:zipFile" value="<%=inputDataBean.getZipFile()%>">
    72 -->
     116<input type="hidden" name="parameter:experimentId" value="<%=inputDataBean.getExperimentId()%>">
     117
     118<input type="hidden" name="file_id" value="">
     119<input type="hidden" name="parameter:zipFile" value=""  id="zipFile">
     120
    73121
    74122<!--  table with the input form -->
     
    79127    <td class="boldText">Microarray platform used:</td>
    80128    <td class="input"><select name="parameter:platform">
    81     <option >Genepix</option>
    82129    <option >Affymetrix</option>
     130    <option >Agilent</option>
     131    <option >AIDA</option>
     132    <option >BZScan</option>
     133    <option >ChipSkipper</option>
     134    <option >GenePix</option>
     135    <option >GeneTAC</option>
     136    <option >Illumina</option>
     137    <option >Imagene</option>
     138    <option >QuantArray Biotin</option>
     139    <option >QuantArray Cy</option>
     140    <option >Spotfinder</option>
    83141    </select></td>
    84142  </tr>
     
    154212  <tr>
    155213    <td class="boldText">Please select the zip file on your local disk that contains the data files for import:</td>
    156     <td class="input"><INPUT type="file" name="parameter:zipFile" size="50" value="test.txt"></td>
    157   </tr>
     214
     215    <td>
     216    <table border="0" cellspacing="0" cellpadding="0">
     217      <tr>
     218        <td><input type="text" class="text required" name="path" size="50" value="">&nbsp;&nbsp;&nbsp;</td>
     219        <td>
     220        <div class="buttonclass" onmouseover="this.className='buttonclass_hover';"
     221          onmouseout="this.className='buttonclass';" onclick="browseOnClick()">
     222
     223        <table border="0" cellspacing="0" cellpadding="0" class="noBorder">
     224          <tr class="noBorder">
     225            <td class="centered"><img src="/base/images/browse.png" border="0"></td>
     226            <td>Browse&hellip;</td>
     227          </tr>
     228        </table>
     229
     230        </div>
     231        </td>
     232
     233      </tr>
     234    </table>
     235    </td>
     236  </tr>
     237
     238
    158239
    159240</table>
  • branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/styles.css

    r511 r513  
    5555  text-align: center;
    5656  align: center;
     57  vertical-align: top;
    5758}
    5859
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/DataBean.java

    r512 r513  
    4343  String pooling;
    4444  String zipFile;
     45  String experimentId;
    4546 
    4647 
     
    356357  {
    357358    this.zipFile = zipFile;
     359  }
     360  public String getExperimentId()
     361  {
     362    return experimentId;
     363  }
     364  public void setExperimentId(String experimentId)
     365  {
     366    this.experimentId = experimentId;
    358367  }
    359368 
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java

    r512 r513  
    99import java.io.InputStream;
    1010import java.util.Arrays;
     11import java.util.Calendar;
    1112import java.util.Collections;
    1213import java.util.LinkedList;
     
    2526import net.sf.basedb.core.Item;
    2627import net.sf.basedb.core.Job;
     28import net.sf.basedb.core.Path;
    2729import net.sf.basedb.core.PluginConfigurationRequest;
    2830import net.sf.basedb.core.PluginParameter;
     
    4143import net.sf.basedb.core.plugin.Request;
    4244import net.sf.basedb.core.plugin.Response;
     45import net.sf.basedb.util.formatter.DateFormatter;
    4346import uk.ac.ebi.nugo.common.Helper;
    4447import uk.ac.ebi.nugo.common.ZipUnpacker;
     
    101104
    102105  private static final Set<GuiContext> guiContexts = Collections.singleton(experimentItemGuiContext);
     106 
    103107
    104108//  =====================================================c'tor================================== 
     
    120124  {   
    121125    //add all the parameter names to a String array for processing
    122     String [] paramNames = new String []{"domain","accession","qualityControl","experimentalDesign",
     126    String [] paramNames = new String []{"experimentId","domain","accession","qualityControl","experimentalDesign",
    123127            "experimentName","description","releaseDate","submissionDate","submitter","organization",
    124128            "publicationTitle","authors","journal","volume","issue","pages","year","pubmedId","treatmentProtocol",
     
    129133            "tissues","pooling","zipFile"};
    130134       
    131     // next create the parameter type
     135    // next create the parameter type - everyone is a String here
    132136    StringParameterType stringPT = new StringParameterType(255, null, true);
    133137   
     
    188192      }
    189193    }
    190     catch (Throwable ex)
    191     {
     194    catch (Exception ex)
     195    {
     196      System.out.println("exception in configure method");
    192197      ex.printStackTrace();
    193       response.setError(ex.getMessage(), Arrays.asList(ex));
     198      //response.setError(ex.getMessage(), Arrays.asList(ex));
    194199    }
    195200
     
    213218  public String isInContext(GuiContext context, Object item)
    214219  {
     220    System.out.println("isInContext called");
     221   
    215222    String message = null;
    216223    if (item == null)
     
    224231    }
    225232    else
    226     {
    227       Experiment exp = (Experiment) item;
    228       RawDataType rawDataType = exp.getRawDataType();
     233    {   
     234      Experiment exp = (Experiment)item;
     235      RawDataType rawDataType = exp.getRawDataType(); 
    229236      if (!Tab2MageHelper.supportedPlatforms(rawDataType.getId().toLowerCase()))
    230237      {
     
    342349    System.out.println("running Tab2MageImporter plugin");
    343350    response.setDone("Import plugin ended successfully");
    344     /*
     351
    345352   
    346353    DbControl dc=null;
     
    354361      User user= User.getById(dc, sc.getLoggedInUserId());
    355362
    356 
    357        //obtain all job parameters
    358 
    359       File file = (File) job.getValue("file");
    360       file= File.getById(dc, file.getId());
    361 
    362       String directoryName = (String)job.getValue("directory");
    363 
    364       String tab2MageFileName= (String) job.getValue("tab2mageFileName");
    365       hostName= (String) job.getValue("emailHost");
    366 
    367       if ((Boolean)job.getValue("overwrite") != null) overwrite = (Boolean)job.getValue("overwrite");
    368       if ((Boolean)job.getValue("validation") != null)  validation = (Boolean)job.getValue("validation");
    369 
    370       Experiment experiment= (Experiment)job.getValue("experiment");
    371       experiment= Experiment.getById(dc,experiment.getId());
     363      String tab2MageFileName= "tab2mage.txt";
     364      String zipFileName = (String)job.getValue("zipFile");
     365     
     366      File zipFile = File.getByPath(dc, new Path(zipFileName, Path.Type.FILE), false);
     367     
     368      // figure out where the zip file is located
     369      Directory zipFileDir = zipFile.getDirectory();
     370      System.out.println("zipFile is located in dir " + zipFileDir.toString());
     371
     372      // make a new subdir in that dir
     373      // the zip file should then be unzipped in here
     374      // give it the same name as that of the zip file plus a timestamp
     375      String timeStamp = new DateFormatter("ddMMyy_HHmmss").format(Calendar.getInstance().getTime());
     376      Directory subDir = Directory.getNew(dc, zipFileDir);
     377      String fileNameNoExt = zipFile.getName().substring(0, zipFile.getName().indexOf("."));
     378      System.out.println("new subDir = " + fileNameNoExt + timeStamp);
     379      subDir.setName(fileNameNoExt + timeStamp);
     380
     381      // save the new subDir
     382      dc.saveItem(subDir);
     383
     384//      String directoryName = (String)job.getValue("directory");
     385//      hostName= (String) job.getValue("emailHost");
     386//      if ((Boolean)job.getValue("overwrite") != null) overwrite = (Boolean)job.getValue("overwrite");
     387//      if ((Boolean)job.getValue("validation") != null)  validation = (Boolean)job.getValue("validation");
     388
     389      //get the experiment object that our data is meant to be imported into
     390      //this will be the experiment that the user is running the import from
     391      String experimentId= (String)job.getValue("experimentId");
     392      Experiment experiment= Experiment.getById(dc,Integer.parseInt(experimentId));
     393           
    372394      RawDataType rdt= experiment.getRawDataType(); // experiment platform
    373395
    374       String statusp=(String)job.getValue("statusPath");
    375       File statusFile=Helper.processFilePath(user,overwrite, sc,statusp);
     396//      String statusp=(String)job.getValue("statusPath");
     397//      File statusFile=Helper.processFilePath(user,overwrite, sc,statusp);
    376398
    377399        //FILE UNZIP MODULE: unzip the files into user specified directory
    378400         
    379       ZipUnpacker importUnpacker = new ZipUnpacker(file, user, sc);
    380       importUnpacker.unpack(directoryName);
     401      ZipUnpacker importUnpacker = new ZipUnpacker(zipFile, user, sc);
     402      importUnpacker.unpack(subDir.getName());
    381403      Directory dir= importUnpacker.getUnzippedFilesDirectory(); // this may return the id of the unzipped file directory instead
    382404      if (dir==null)
     
    396418      //use code from tab2mage exporter to do so
    397419     
     420      //PluginConfigurationRequest pcRequest = (PluginConfigurationRequest) sc.getSessionSetting("plugin.configure.request");     
     421      Tab2MageWriter t2mWriter = new Tab2MageWriter(request, dir,dc);
     422      t2mWriter.writeTab2MageFile();
     423     
     424     
    398425      /////////////////////////////////////////////////////////////////////////////////////////////////
    399426     
    400 
     427/*
    401428
    402429        //VALIDATION MODULE
     
    539566      }
    540567      // -- end of messaging module
    541      
     568      */
    542569      dc.commit();
    543570      response.setDone("Import plugin ended successfully");
     
    553580    }
    554581   
    555     */
     582   
    556583
    557584  }
Note: See TracChangeset for help on using the changeset viewer.