Changeset 1128


Ignore:
Timestamp:
Jun 15, 2009, 2:43:42 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #222, #218, #229. Several changes just to make things work.

Location:
extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/GenePattern.java

    r1119 r1128  
    4747    return ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options");
    4848  }
     49 
     50  /**
     51    Get the servlet directory URL for the GenePattern extension.
     52  */
     53  public static final String getServletUrl(String servletName)
     54  {
     55    return ExtensionsControl.getServletUrl("net.sf.basedb.genepattern.options",
     56        servletName);
     57  }
    4958   
    5059}
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/plugin/GenePatternAnalysisPlugin.java

    r1119 r1128  
    99import org.genepattern.webservice.WebServiceException;
    1010
     11import net.sf.basedb.clients.web.extensions.ExtensionsControl;
    1112import net.sf.basedb.clients.web.formatter.FormatterFactory;
    1213import net.sf.basedb.core.AnnotationType;
     
    2021import net.sf.basedb.core.Experiment;
    2122import net.sf.basedb.core.File;
     23import net.sf.basedb.core.FileStoreUtil;
    2224import net.sf.basedb.core.Item;
    2325import net.sf.basedb.core.ItemQuery;
     
    109111    try
    110112    {
    111       String baseUrl = (String)configuration.getValue("baseUrl");
    112       gw = new FileTransferGateway(baseUrl + "/extensions/gp-integration.jar");
    113      
    114113      // Export files and prepare parameters to GenePattern
    115114      if (progress != null) progress.display(0, "Copying files to GenePattern server");
     
    118117      GPServer gpServer = GPServer.get(sc, (String)job.getValue("gpServer"));
    119118     
     119      gw = new FileTransferGateway(gpServer.getBaseUrl() + "/" + GenePattern.getServletUrl("Download"));
    120120      GPClient gp = new GPClient(gpServer);
    121121      ParameterInfo[] info = gp.getParameters(gpModule, null);     
     
    162162      try
    163163      {
    164         result = gp.waitFor(jobId, 5000);
     164        result = gp.waitFor(jobId, 5);
    165165      }
    166166      catch (InterruptedException ex)
     
    303303        storeValue(configuration, request, ri.getParameter("gpModule"));
    304304        storeValue(configuration, request, ri.getParameter("gpServer"));
    305         storeValue(configuration, request, ri.getParameter("baseUrl"));
    306305        response.setContinue(CONFIGURE_GP_PARAMETERS);
    307306      }
     
    319318        for (PluginParameter<?> pp : ri.getParameters())
    320319        {
    321           storeValue(wrapper, request, pp);
     320          if (pp.getParameterType() != null) storeValue(wrapper, request, pp);
    322321        }
    323322        response.setDone("Configuration complete");       
     
    474473      new StringParameterType(255, null, true)
    475474    ));
    476     parameters.add(new PluginParameter<String>(
    477         "baseUrl",
    478         "URL to BASE",
    479         "Enter the URL to your BASE server as seen from the GenePattern server. " +
    480         "NOTE! In the future this will be detected automatically",
    481         new StringParameterType(255, "http://" + Application.getHostName() + ":8080/base2", true)
    482       ));
    483475
    484476    configurePlugin = new RequestInformation(
     
    501493    GPServer gpServer = GPServer.get(sc,
    502494        context == null ? (String)configuration.getValue("gpServer") : (String)job.getValue("gpServer"));
    503    
     495    boolean forJob = context != null;
    504496    try
    505497    {
     
    508500      ParameterInfo[] info = gp.getParameters(gpModule, null);
    509501      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(info.length);
    510      
     502      List<PluginParameter<?>> fileParameters = new ArrayList<PluginParameter<?>>(info.length);
     503      sc.getCurrentContext(Item.FILE).setId(0);
    511504      for (ParameterInfo pi : info)
    512505      {
    513         if (context != null || !pi.isInputFile())
    514         {
    515           PluginParameter<?> pp = pi.createPluginParameter("gp.");
    516           if (pp != null) parameters.add(pp);
    517         }
     506        PluginParameter<?> pp = null;
     507        if (forJob)
     508        {
     509          Object defaultValue = configuration.getValue("gp." + pi.getName());
     510          if (pi.isInputFile())
     511          {
     512            String fileType = (String)configuration.getValue("filetype." + pi.getName());
     513            DbControl dc = sc.newDbControl();
     514            BioAssaySet bioAssaySet = getCurrentBioAssaySet(dc);
     515            defaultValue = FileStoreUtil.getDataFile(dc, bioAssaySet, fileType);
     516            dc.close();
     517          }
     518          pp = pi.createPluginParameter("gp.", defaultValue);
     519        }
     520        else
     521        {
     522          if (pi.isInputFile())
     523          {
     524            List<String> options = new ArrayList<String>();
     525            options.add(GenePattern.GCT_FILE);
     526            String defaultOption = null;
     527            String description = pi.getDescription();
     528            if (defaultOption == null && description.contains(".gct"))
     529            {
     530              defaultOption = GenePattern.GCT_FILE;
     531            }
     532            pp = new PluginParameter<String>(
     533                "filetype." + pi.getName(),
     534                pi.getLabel(),
     535                pi.getDescription(),
     536                new StringParameterType(255, defaultOption, false, 1, 0, 0, options)
     537            );
     538          }
     539          else
     540          {
     541            pp = pi.createPluginParameter("gp.", null);
     542          }
     543        }
     544        if (pp != null)
     545        {
     546          if (pi.isInputFile())
     547          {
     548            fileParameters.add(pp);
     549          }
     550          else
     551          {
     552            parameters.add(pp);
     553          }
     554        }
     555      }
     556     
     557      if (fileParameters.size() > 0)
     558      {
     559        if (parameters.size() > 0)
     560        {
     561          parameters.add(0, new PluginParameter<String>(
     562              "otherSection",
     563              "Other parameters",
     564              "In this section you can specify default values " +
     565              "for all other parameters. The values may be overriden " +
     566              "when used for an actual job.",
     567              null
     568          ));
     569        }
     570        parameters.addAll(0, fileParameters);
     571        parameters.add(0, new PluginParameter<String>(
     572            "filesSection",
     573            "Input files",
     574            "For each input file you can specify a file type " +
     575            "which makes it possible for BASE to generate a sensible " +
     576            "default value or automatically export a file with the data.",
     577            null
     578          ));
    518579      }
    519580     
    520581      configureGpParameters = new RequestInformation(
    521582        CONFIGURE_GP_PARAMETERS,
    522         "Default parameters values",
     583        "Files and default parameters values",
    523584        "Set default values for the parameters that " +
    524585        "are required by this module/pipeline.",
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/servlet/Test.java

    r1118 r1128  
    6060{
    6161
    62   public static final String GP_EXT = "http://auster.thep.lu.se:8080/trunk/extensions/gp-integration.jar";
     62  public static final String DOWNLOAD_SERVLET = "http://auster.thep.lu.se:8080/trunk/extensions/servlet/gp-integration.jar/Download";
    6363  public static final String GP_HOME = "http://kundera.thep.lu.se:8088";
    6464  public static final String GP_LOGIN = "nicklas@thep.lu.se";
     
    7878    final String ID = sc.getId();
    7979    DbControl dc = sc.newDbControl();
    80     FileTransferGateway gw = new FileTransferGateway(GP_EXT);
     80    FileTransferGateway gw = new FileTransferGateway(DOWNLOAD_SERVLET);
    8181    try
    8282    {
    83      
     83      /*
    8484      File gctFile = File.getByPath(dc, new Path(GCT_FILE, Path.Type.FILE), false);
    8585      File clsFile = File.getByPath(dc, new Path(CLS_FILE, Path.Type.FILE), false);
     
    8787      Parameter gctParameter = gw.addFile("input.file", new BaseFileProxy(gctFile));
    8888      Parameter clsParameter = gw.addFile("cls.file", new BaseFileProxy(clsFile));
     89    */
    8990      dc.close();
    90 
     91   
    9192      GPClient gp = new GPClient(GP_HOME, GP_LOGIN, GP_PWD);
    92       //AdminProxy ap = new AdminProxy(GP_HOME, GP_LOGIN, GP_PWD);
    9393     
    9494      TaskInfo[] tasks = gp.getModules(null);
     
    116116
    117117     
    118       ParameterInfo[] info = gp.getParameters("urn:lsid:broad.mit.edu:cancer.software.genepattern.module.analysis:00044:5", null);
     118      ParameterInfo[] info = gp.getParameters("ImputeMissingValuesKNN", null);
    119119      //PrintWriter out = response.getWriter();
    120120      out.println("<b>Parameters</b><br>");
     
    136136      }
    137137      out.flush();
    138      
     138      /*
    139139      int jobId = gp.runAnalysisNoWait(
    140140        "urn:lsid:broad.mit.edu:cancer.software.genepattern.module.analysis:00044:5",
     
    163163        out.println("<a href=\"" + url + "\" target=\"_new\">" + f + ": " + url + "</a><br>");
    164164      }
     165      */
    165166
    166167    }
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/wrapper/ParameterInfo.java

    r1115 r1128  
    8989  public String getDefaultValue()
    9090  {
    91     return Values.getStringOrNull(getGPParameterInfo().getDefaultValue());
     91    String d = getGPParameterInfo().getDefaultValue();
     92    if (hasChoices())
     93    {
     94      Map<String, String> choices = getChoices();
     95      if (!choices.values().contains(d))
     96      {
     97        d = choices.get(d);
     98      }
     99    }
     100    return Values.getStringOrNull(d);
    92101  }
    93102
     
    168177  */
    169178  @SuppressWarnings("unchecked")
    170   public PluginParameter<?> createPluginParameter(String prefix)
     179  public PluginParameter createPluginParameter(String prefix, Object defaultValue)
    171180  {
    172181    String type = getType();
    173     ParameterType<?> pt = null; 
     182    ParameterType<?> pt = null;
    174183    if (isInputFile())
    175184    {
     
    178187    else if (hasChoices())
    179188    {
    180       pt = new StringParameterType(255, getDefaultValue(), !isOptional(),
    181           1, 0, 0, getChoicesAsEnumeration());
     189      pt = new StringParameterType(255, getDefaultValue(), !isOptional(), 1, 0, 0, getChoicesAsEnumeration());
    182190    }
    183191    else if (type.equals("java.lang.String"))
     
    188196    {
    189197      pt = new IntegerParameterType(null, null,
    190           Values.getInteger(getDefaultValue(), null), isOptional());
     198          Values.getInteger(getDefaultValue(), null), !isOptional());
    191199    }
    192200    else if (type.equals("java.lang.Float"))
     
    206214        getLabel(),
    207215        getDescription(),
     216        defaultValue,
    208217        pt
    209       );
     218        );
    210219    return parameter;
    211220  }
Note: See TracChangeset for help on using the changeset viewer.