Changeset 2128


Ignore:
Timestamp:
Mar 30, 2006, 8:01:48 AM (18 years ago)
Author:
Gregory Vincic
Message:

Merged base/trunk revision 2116:2127 with base/branches/rf1

Location:
branches/rf1
Files:
1 deleted
8 edited
5 copied

Legend:

Unmodified
Added
Removed
  • branches/rf1/src/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java

    r1972 r2128  
    2727import net.sf.basedb.core.ProgressReporter;
    2828
     29import net.sf.basedb.core.BaseException;
     30import net.sf.basedb.core.Formula;
     31import net.sf.basedb.core.Include;
     32import net.sf.basedb.core.InvalidDataException;
     33import net.sf.basedb.core.Item;
     34import net.sf.basedb.core.ItemParameterType;
     35import net.sf.basedb.core.ItemQuery;
     36import net.sf.basedb.core.PluginParameter;
     37import net.sf.basedb.core.RequestInformation;
     38import net.sf.basedb.core.StringParameterType;
    2939import net.sf.basedb.core.Transformation;
    3040import net.sf.basedb.core.BioAssaySet;
     
    3747import net.sf.basedb.core.plugin.AboutImpl;
    3848import net.sf.basedb.core.plugin.AbstractPlugin;
     49import net.sf.basedb.core.plugin.GuiContext;
    3950import net.sf.basedb.core.plugin.Plugin;
     51import net.sf.basedb.core.plugin.InteractivePlugin;
    4052import net.sf.basedb.core.plugin.Request;
    4153import net.sf.basedb.core.plugin.Response;
    42 import net.sf.basedb.core.IntensityFormula;
     54import net.sf.basedb.core.query.Hql;
     55import net.sf.basedb.core.query.Orders;
    4356import net.sf.basedb.util.IntensityCalculator;
    4457import net.sf.basedb.util.IntensityCalculatorUtil;
    4558
     59import java.util.ArrayList;
     60import java.util.Arrays;
     61import java.util.Collections;
    4662import java.util.List;
     63import java.util.Set;
    4764
    4865/**
    49    This plugin provides methods to calculate the intensity for a root bioassayset using different formulas.
    50    It needs the following parameters
     66   This plugin provides methods to calculate the intensity for a root bioassayset
     67   using different formulas. It needs the following parameters:
    5168
    5269   <pre>
    53    String              : name
    54    Experiment          : experiment
    55    List<RawBioAssay>   : rawBioAssays 
    56    String              : formula
     70   String              : name; The name of the new bioassayset
     71   Experiment          : experiment; The experiment we are working on
     72   List&gt;RawBioAssay&lt;   : rawBioAssays; The raw bioassays to create bioassays for
     73     (must be part of the experiment)
     74   Formula             : formula; The formula to use to for calculating intesities
    5775   </pre>
    5876
    59    @author Gregory
     77   @author Gregory, Nicklas
     78   @version 2.0
     79   @base.modified $Date$
    6080*/
    6181public class IntensityCalculatorPlugin
    6282  extends AbstractPlugin
    63   implements Plugin
     83  implements InteractivePlugin
    6484{
    6585
     
    7090          new AboutImpl
    7191    (
    72       "Intensity calculator",
    73       "This plugin is used to calculate intensities from raw data creating an initial raw bioassay.",
    74       "1.0",
     92      "Formula intensity calculator",
     93      "This plugin is used to calculate intensities from raw data creating an initial root bioassay set. "+
     94      "The intensities are calculated using Formula objects registered for the experiment's raw data type. " +
     95      "Thus, the functionality of this plugin can be extended by adding more formula objects to the database.",
     96      "2.0",
    7597      "2006, Department of Theoretical Physics, Lund University",
    7698      null,
     
    79101    );
    80102
    81 
     103  private static final Set<GuiContext> guiContexts =
     104    Collections.singleton(new GuiContext(Item.BIOASSAYSET, GuiContext.Type.LIST));
     105
     106  private static final RequestInformation configurePlugin = new RequestInformation
     107  (
     108    Request.COMMAND_CONFIGURE_PLUGIN,
     109    "Configure intensity calculator",
     110    "This plugin has no configuration options.",
     111    null
     112  );
     113
     114  private static final StringParameterType nameType =
     115    new StringParameterType(BioAssaySet.MAX_NAME_LENGTH, "New bioassayset", true);
     116  private static final PluginParameter<String> nameParameter = new PluginParameter<String>(
     117    "name", "Bioassay set name", "The name of the root bioassayset", nameType);
     118
     119  private ItemParameterType<Experiment> experimentType;
     120  private PluginParameter<Experiment> experimentParameter;
     121
     122  private ItemParameterType<RawBioAssay> rawBioAssaysType;
     123  private PluginParameter<RawBioAssay> rawBioAssaysParameter;
     124
     125  private ItemParameterType<Formula> formulaType;
     126  private PluginParameter<Formula> formulaParameter;
     127
     128  private RequestInformation configureJob;
     129 
    82130  /**
    83131     Constructor should be empty.
     
    86134  {}
    87135 
    88 
    89   /*
    90     Plugin interface implementation
    91     -------------------------------
     136  /*
     137    From the Plugin interface
     138    -------------------------------------------
    92139  */
    93140  public About getAbout()
     
    95142    return about;
    96143  }
    97 
    98 
    99144  /**
    100145     Returns the main plugin type this plugin belongs to.
     
    106151  }
    107152
    108 
    109   /**
    110      @param request
    111      @param response
    112      @param progress
    113   */
    114153  @SuppressWarnings("unchecked")
    115154  public void run(Request request, Response response, ProgressReporter progress)
     
    118157    try
    119158    {
    120       /* name parameter */
     159      // name parameter
    121160      String name = (String)job.getValue("name");
    122161 
    123       /* experiment parameter*/
    124  
    125       Integer experimentId = (Integer)job.getValue("experiment_id");
    126       if(experimentId != null)
    127       {
    128         Experiment experiment = Experiment.getById(dc, experimentId.intValue());
    129  
    130         /* rawBioAssays parameter*/
    131         List<RawBioAssay> sources = (List<RawBioAssay>)job.getValues("rawBioAssays");
    132         for (RawBioAssay rba : sources)
    133         {
    134           dc.reattachItem(rba);
    135         }
    136  
    137         /* formula parameter */
    138         String formula = (String)job.getValue("formula");
    139  
    140         /* intensity calculation */
    141         RawDataType rdt = experiment.getRawDataType();
    142         IntensityFormula intensityFormula = rdt.getIntensityFormula( formula );
    143         IntensityCalculator iCalc = IntensityCalculatorUtil.createJepIntensityCalculator(dc, rdt, intensityFormula.getExpressions());
    144         int jobId = job.getId();
    145         Job thisJob = Job.getById(dc, jobId);
    146         BioAssaySet rootBas = IntensityCalculatorUtil.createRootBioAssaySet(dc, experiment, sources, thisJob, iCalc, progress);
    147         rootBas.setName(name);
    148         Transformation t = rootBas.getTransformation();
    149         t.setName(intensityFormula.getTitle());
    150         dc.commit();
    151         response.setDone("Done");
     162      // experiment parameter
     163      Experiment experiment = (Experiment)job.getValue("experiment");
     164     
     165      // To avoid disconnection/reconnection issues
     166      experiment = Experiment.getById(dc, experiment.getId());
     167 
     168      // rawBioAssays parameter
     169      List<RawBioAssay> sources = (List<RawBioAssay>)job.getValues("rawBioAssays");
     170      for (RawBioAssay rba : sources)
     171      {
     172        dc.reattachItem(rba);
    152173      }
    153       else
    154       {
    155         response.setError("Experiment id is null", null);
     174
     175      // Formula parameter
     176      Formula formula = (Formula)job.getValue("formula");
     177      formula = Formula.getById(dc, formula.getId());
     178 
     179      // intensity calculation
     180      RawDataType rdt = experiment.getRawDataType();
     181
     182      // IntensityFormula intensityFormula = rdt.getIntensityFormula( formula );
     183      IntensityCalculator iCalc =
     184        IntensityCalculatorUtil.createJepIntensityCalculator(dc, rdt,
     185        formula.getFormulas().toArray(new String[formula.getNumFormulas()]));
     186      int jobId = job.getId();
     187      Job thisJob = Job.getById(dc, jobId);
     188
     189      BioAssaySet rootBas = IntensityCalculatorUtil.createRootBioAssaySet(dc, experiment, sources, thisJob, iCalc, progress);
     190      rootBas.setName(name);
     191      Transformation t = rootBas.getTransformation();
     192      t.setName(formula.getName());
     193      dc.commit();
     194      response.setDone("Done");
     195    }
     196    finally
     197    {
     198      if (dc != null) dc.close();
     199    }
     200  }
     201  // -------------------------------------------
     202
     203  /*
     204    From the InteractivePlugin interface
     205    -------------------------------------------
     206  */
     207  public Set<GuiContext> getGuiContexts()
     208  {
     209    return guiContexts;
     210  }
     211  /**
     212    Always false, since plugin doesn't operate on individual items.
     213  */
     214  public boolean isInContext(GuiContext context, Object item)
     215  {
     216    return false;
     217  }
     218  /**
     219    The {@link Request#COMMAND_CONFIGURE_PLUGIN} command will not ask for
     220    any parameters.
     221    The {@link Request#COMMAND_CONFIGURE_JOB} command will ask for
     222    the parameters mentioned in the class documentation.
     223  */
     224  public RequestInformation getRequestInformation(GuiContext context, String command)
     225    throws BaseException
     226  {
     227    RequestInformation requestInformation = null;
     228    if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
     229    {
     230      requestInformation = configurePlugin;
     231    }
     232    else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     233    {
     234      requestInformation = getConfigureJobParameters();
     235    }
     236    return requestInformation;
     237  }
     238  /**
     239    Store configuration settings for {@link Request#COMMAND_CONFIGURE_PLUGIN},
     240    and {@link Request#COMMAND_CONFIGURE_JOB}.
     241  */
     242  @SuppressWarnings("unchecked")
     243  public void configure(GuiContext context, Request request, Response response)
     244  {
     245    String command = request.getCommand();
     246   
     247    try
     248    {
     249      if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
     250      {
     251        response.setDone("No configuration needed.");
    156252      }
    157     }
    158     finally
    159     {
    160       if (dc != null) dc.close();
    161     }
    162   }
     253      else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     254      {
     255        List<Throwable> errors = validateRequestParameters(configureJob.getParameters(), request);
     256        if (errors != null)
     257        {
     258          response.setError(errors.size()+" invalid parameter(s) were found in the request", errors);
     259          return;
     260        }
     261       
     262        Experiment experiment = (Experiment)request.getParameterValue("experiment");
     263        DbControl dc = sc.newDbControl();
     264        int numSpots = 0;
     265        try
     266        {
     267          experiment = Experiment.getById(dc, experiment.getId());
     268          List<RawBioAssay> rawBioAssays = (List<RawBioAssay>)request.getParameterValues("rawBioAssays");
     269          for (RawBioAssay rba : rawBioAssays)
     270          {
     271            if (!experiment.isUsing(rba))
     272            {
     273              throw new InvalidDataException("Raw bioassay '" + rba.getName() +
     274                "' is not part of the experiment '" + experiment.getName()+"'");
     275            }
     276            numSpots += rba.getSpots();
     277          }
     278        }
     279        finally
     280        {
     281          if (dc != null) dc.close();
     282        }
     283       
     284        Formula formula = (Formula)request.getParameterValue("formula");
     285        if (formula.getFormulaType() != Formula.Type.INTENSITY_EXPRESSION)
     286        {
     287          throw new InvalidDataException("The selected formula is not an intensity expression formula: " +
     288            formula.getName());
     289        }
     290        if (formula.getRawDataType() != experiment.getRawDataType())
     291        {
     292          throw new InvalidDataException("The selected formula '"+formula.getName()+
     293            "' uses a different raw data type than the experiment '" + experiment.getName()+"'");
     294        }
     295       
     296        storeValue(job, request, nameParameter);
     297        storeValue(job, request, experimentParameter);
     298        storeValues(job, request, rawBioAssaysParameter);
     299        storeValue(job, request, formulaParameter);
     300       
     301        Job.ExecutionTime execTime = Job.ExecutionTime.SHORT;
     302        // TODO - this should be configurable in some way
     303        if (numSpots > 1000000 && numSpots < 10000000)
     304        {
     305          execTime = Job.ExecutionTime.MEDIUM;
     306        }
     307        else
     308        {
     309          execTime = Job.ExecutionTime.LONG;
     310        }
     311       
     312        response.setDone("Job configuration complete", execTime);
     313      }
     314    }
     315    catch (Throwable ex)
     316    {
     317      response.setError(ex.getMessage(), Arrays.asList(ex));
     318      ex.printStackTrace();
     319    }
     320  }
     321
     322 
     323  private RequestInformation getConfigureJobParameters()
     324  {
     325    if (configureJob == null)
     326    {
     327      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
     328     
     329      experimentType = new ItemParameterType<Experiment>(Experiment.class, null, true, 1, null);
     330      experimentParameter = new PluginParameter<Experiment>(
     331        "experiment", "Experiment", "The experiment we are working with", experimentType);
     332     
     333      parameters.add(experimentParameter);
     334      parameters.add(nameParameter);
     335     
     336      DbControl dc = sc.newDbControl();
     337      try
     338      {
     339        int experimentId = sc.getCurrentContext(Item.EXPERIMENT).getId();
     340        Experiment experiment = Experiment.getById(dc, experimentId);
     341       
     342        ItemQuery<RawBioAssay> rawBioAssayQuery = experiment.getRawBioAssays();
     343        rawBioAssayQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
     344        rawBioAssayQuery.order(Orders.asc(Hql.property("name")));
     345        List<RawBioAssay> rawBioAssays = new ArrayList<RawBioAssay>(rawBioAssayQuery.list(dc));
     346        rawBioAssaysType = new ItemParameterType<RawBioAssay>(RawBioAssay.class, null, true, 0, rawBioAssays);
     347        rawBioAssaysParameter = new PluginParameter<RawBioAssay>(
     348          "rawBioAssays", "Raw bioassays", "Select the raw bioassays to use when creating the root bioassay set",
     349          rawBioAssaysType);
     350       
     351        parameters.add(rawBioAssaysParameter);
     352       
     353        ItemQuery<Formula> formulaQuery = Formula.getQuery(Formula.Type.INTENSITY_EXPRESSION,
     354            experiment.getRawDataType());
     355        formulaQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
     356        formulaQuery.order(Orders.asc(Hql.property("name")));
     357        List<Formula> formulas = new ArrayList<Formula>(formulaQuery.list(dc));
     358        formulaType = new ItemParameterType<Formula>(Formula.class, null, true, 1, formulas);
     359        formulaParameter = new PluginParameter<Formula>(
     360          "formula", "Formula", "Select the expression to use for calculating the intensities",
     361          formulaType);
     362        parameters.add(formulaParameter);
     363      }
     364      finally
     365      {
     366        if (dc != null) dc.close();
     367      }     
     368      configureJob = new RequestInformation
     369      (
     370        Request.COMMAND_CONFIGURE_JOB,
     371        "Intensity calculation options",
     372        "Select which raw bioassays to use and a formula for the calculations",
     373        parameters
     374      );
     375    }
     376    return configureJob;
     377  }
     378
    163379}
  • branches/rf1/src/core/net/sf/basedb/plugins/MedianRatioNormalization.java

    r2036 r2128  
    4848import net.sf.basedb.core.SpotBatcher;
    4949import net.sf.basedb.core.Transformation;
     50import net.sf.basedb.core.Type;
    5051import net.sf.basedb.core.VirtualColumn;
    5152import net.sf.basedb.core.plugin.About;
     
    5859import net.sf.basedb.core.plugin.Request;
    5960import net.sf.basedb.core.plugin.Response;
     61import net.sf.basedb.core.query.Aggregations;
    6062import net.sf.basedb.core.query.Dynamic;
    6163import net.sf.basedb.core.query.Expressions;
     
    102104    "highExclude",
    103105    "Exclude top",
    104     "Exclude top %",
     106    "A percentage of the highest values that are ignored when calculating the median.",
    105107    new FloatParameterType(0F, 100F, 5F, true)
    106108  );
     
    110112    "lowExclude",
    111113    "Exclude low",
    112     "Exclude low %",
     114    "A percentage of the lowest values that are ignored when calculating the median.",
    113115    new FloatParameterType(0F, 100F, 5F, true)
    114116  );
     
    185187      try
    186188      {
     189        int blockGroupSize = (Integer) job.getValue(blockGroupParameter.getName());
    187190        BioAssaySet bioAssaySet = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
    188191        bioAssaySet = BioAssaySet.getById(dc, bioAssaySet.getId());
     
    193196        child.setName(bioAssaySet.getName());
    194197        dc.saveItem(child);
    195 
    196198        batcher = child.getSpotBatcher();
    197199
     
    201203
    202204        Select ratio = Selects.expression(Expressions.divide(Dynamic.column(VirtualColumn.channel(1)), Dynamic.column(VirtualColumn.channel(2))), "ratio");
    203 
     205        Restriction intensityRestriction = Restrictions.and
     206        (
     207          Restrictions.gt(Dynamic.column(VirtualColumn.channel(1)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName()))),
     208          Restrictions.gt(Dynamic.column(VirtualColumn.channel(2)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName())))
     209        );
     210        float lowExclude = (Float) job.getValue(lowExcludeParameter.getName());
     211        float highExclude = (Float) job.getValue(highExcludeParameter.getName());
     212       
     213        DynamicSpotQuery query;
     214        DynamicResultIterator resultIter;
    204215        List<BioAssay> assays = bioAssaySet.getBioAssays().list(dc);
    205216        for (BioAssay assay : assays)
    206217        {
    207218          //TODO use block numbers to create subgroups
    208           DynamicSpotQuery query = getQuery(assay.getSpotData());
    209           query.select(ratio);
    210           query.order(Orders.asc(Expressions.selected(ratio)));
    211 
    212           int count = query.count(dc);
    213           numSpots -= assay.getNumSpots() - count;
    214           progress.display((normalizedSpots * 100) / numSpots, (assay.getNumSpots() - count)+ " spots removed from assay " + assay.getName());
    215 
    216           // check count > 0
    217           double median;
    218           if (count % 2 == 0)
    219           {
    220             query.setFirstResult((count/2)-1);
    221             query.setMaxResults(2);
    222             DynamicResultIterator iter = query.iterate(dc);
    223             median = Math.sqrt(iter.next().getFloat(iter.getIndex("ratio"))*iter.next().getFloat(iter.getIndex("ratio")));
    224           }
    225           else
    226           {
    227             query.setFirstResult((count-1)/2);
    228             query.setMaxResults(1);
    229             DynamicResultIterator iter = query.iterate(dc);
    230             median = iter.next().getFloat(iter.getIndex("ratio"));
    231           }
    232          
    233           float sqrtMedRatio = (float) Math.sqrt(median);
    234           float invSqrtMedRatio = 1/sqrtMedRatio;
    235           Select newCh1 = Selects.expression
    236           (
    237             Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(1))), Expressions.aFloat(invSqrtMedRatio)),
    238             "newCh1"
    239           );
    240           Select newCh2 = Selects.expression
    241           (
    242             Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(2))), Expressions.aFloat(sqrtMedRatio)),
    243             "newCh2"
    244           );
    245 
    246           query = getQuery(assay.getSpotData());
    247           query.select(Dynamic.select(VirtualColumn.COLUMN));
    248           query.select(Dynamic.select(VirtualColumn.POSITION));
    249           query.select(newCh1);
    250           query.select(newCh2);
    251          
    252219          dc.saveItem(child.newBioAssay(assay));
    253220         
    254           DynamicResultIterator iter = query.iterate(dc);
    255           int column = iter.getIndex(VirtualColumn.COLUMN.getName());
    256           int position = iter.getIndex(VirtualColumn.POSITION.getName());
    257           int ch1 = iter.getIndex("newCh1");
    258           int ch2 = iter.getIndex("newCh2");
    259           while (iter.hasNext())
     221          query = assay.getSpotData();
     222          query.restrict(intensityRestriction);
     223          query.joinRawData(JoinType.LEFT);
     224          query.select(Selects.expression(Aggregations.max(Expressions.selected(Dynamic.selectRawData("block"))), "max"));
     225          resultIter = query.iterate(dc);
     226          int maxBlock = resultIter.next().getInt(resultIter.getIndex("max"));
     227
     228          for (int i = 0; i < maxBlock; i += blockGroupSize)
    260229          {
    261             SqlResult r = iter.next();
    262             batcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1), r.getFloat(ch2));
    263             normalizedSpots++;
    264             progress.display((normalizedSpots * 100) / numSpots, normalizedSpots + " spots normalized");
     230            Restriction blockRestriction = Restrictions.between
     231            (
     232              Expressions.selected(Dynamic.selectRawData("block")),
     233              Expressions.integer(i),
     234              Expressions.integer(i+blockGroupSize)
     235            );
     236           
     237            query = assay.getSpotData();
     238            query.joinRawData(JoinType.LEFT);
     239            query.select(Dynamic.select(VirtualColumn.channel(1)));
     240            query.select(Dynamic.select(VirtualColumn.channel(2)));
     241            query.select(Dynamic.selectRawData("block"));
     242            query.select(ratio);
     243            query.restrict(intensityRestriction);
     244            query.restrict(blockRestriction);
     245            query.order(Orders.asc(Expressions.selected(ratio)));
     246           
     247            int count = query.count(dc);
     248            if (count <= 0) continue;
     249            int lowCount = (int) Math.floor(count * lowExclude / 100);
     250            int highCount = (int) Math.floor(count * highExclude / 100);
     251            numSpots -= assay.getNumSpots() - count;
     252            progress.display((normalizedSpots * 100) / numSpots, (assay.getNumSpots() - count) + " spots removed from assay " + assay.getName());
     253
     254            // check count > 0
     255            int include = count - lowCount - highCount;
     256            if (include <= 0) continue;
     257            double median;
     258            if (include % 2 == 0)
     259            {
     260              query.setFirstResult((include / 2) - 1 + lowCount);
     261              query.setMaxResults(2);
     262              DynamicResultIterator iter = query.iterate(dc);
     263              median = Math.sqrt(iter.next().getFloat(iter.getIndex("ratio")) * iter.next().getFloat(iter.getIndex("ratio")));
     264            }
     265            else
     266            {
     267              query.setFirstResult(((include - 1) / 2) + lowCount);
     268              query.setMaxResults(1);
     269              DynamicResultIterator iter = query.iterate(dc);
     270              median = iter.next().getFloat(iter.getIndex("ratio"));
     271            }
     272
     273            float sqrtMedRatio = (float) Math.sqrt(median);
     274            float invSqrtMedRatio = 1 / sqrtMedRatio;
     275            Select newCh1 = Selects.expression(Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(1))),
     276              Expressions.aFloat(invSqrtMedRatio)), "newCh1");
     277            Select newCh2 = Selects.expression(Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(2))),
     278              Expressions.aFloat(sqrtMedRatio)), "newCh2");
     279
     280            query = assay.getSpotData();
     281            query.joinRawData(JoinType.LEFT);
     282            query.select(Dynamic.select(VirtualColumn.COLUMN));
     283            query.select(Dynamic.select(VirtualColumn.POSITION));
     284            query.select(newCh1);
     285            query.select(newCh2);
     286            query.restrict(intensityRestriction);
     287            query.restrict(blockRestriction);
     288            query.setParameter("low", new Integer(i), Type.INT);
     289            query.setParameter("high", new Integer(i + blockGroupSize), Type.INT);
     290
     291            DynamicResultIterator iter = query.iterate(dc);
     292            int column = iter.getIndex(VirtualColumn.COLUMN.getName());
     293            int position = iter.getIndex(VirtualColumn.POSITION.getName());
     294            int ch1 = iter.getIndex("newCh1");
     295            int ch2 = iter.getIndex("newCh2");
     296            while (iter.hasNext())
     297            {
     298              SqlResult r = iter.next();
     299              batcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1), r.getFloat(ch2));
     300              normalizedSpots++;
     301              progress.display((normalizedSpots * 100) / numSpots, normalizedSpots + " spots normalized");
     302            }
    265303          }
    266304        }
     
    358396  }
    359397  // -------------------------------------------
    360 
    361   private DynamicSpotQuery getQuery(DynamicSpotQuery query)
    362   {
    363     Restriction restriction = Restrictions.and
    364     (
    365       Restrictions.gt(Dynamic.column(VirtualColumn.channel(1)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName()))),
    366       Restrictions.gt(Dynamic.column(VirtualColumn.channel(2)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName())))
    367     );
    368 
    369     query.restrictPermanent(restriction);
    370     query.joinRawData(JoinType.LEFT);
    371     query.selectPermanent(Dynamic.select(VirtualColumn.channel(1)));
    372     query.selectPermanent(Dynamic.select(VirtualColumn.channel(2)));
    373     query.selectPermanent(Dynamic.selectRawData("block"));
    374     return query;
    375   }
    376398}
  • branches/rf1/www/admin/clients/view_client.jsp

    r2004 r2128  
    106106      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
    107107    }
     108    function viewHelp()
     109    {
     110      location.href = 'help/index.jsp?ID=<%=ID%>&cmd=List&client_id=<%=itemId%>';
     111    }
     112    function switchTab(tabControlId, tabId)
     113    {
     114      if (tabId == 'help')
     115      {
     116        viewHelp();
     117      }
     118      else
     119      {
     120        TabControl.setActiveTab(tabControlId, tabId);
     121      }
     122    }
    108123    </script>
    109124  </base:head>
     
    115130    </p:path>
    116131   
    117     <t:tabcontrol id="main" active="properties">
     132    <t:tabcontrol id="main" active="properties" switch="switchTab">
    118133    <t:tab id="properties" title="Properties">
    119134   
     
    207222    </div>
    208223      </t:tab>
     224     
     225      <t:tab id="help" title="Help" tooltip="View and manage help texts for this client application" />
    209226      </t:tabcontrol>
    210227
  • branches/rf1/www/common/plugin/configure.jsp

    r2073 r2128  
    129129            }
    130130            // Finally we use the parameters default value
    131             if (values == null || values.size() == 0)
     131            if ((values == null || values.size() == 0) && pType.getDefaultValue() != null)
    132132            {
    133133              values = Collections.singletonList(pType.getDefaultValue());
     
    579579                  {
    580580                    %>
    581                     <select name="<%=inputName%>" multiple size="10"
     581                    <select name="<%=inputName%>" multiple size="10" style="width: 30em;"
    582582                      onchange="setEnumValues('<%=inputName%>')">
    583583                    <%
     
    587587                    String listValue = "";
    588588                    String listText = "";
     589                    String listTitle = "";
    589590                    if (value instanceof Date)
    590591                    {
     
    596597                      BasicItem item = (BasicItem)value;
    597598                      listValue = Integer.toString(item.getId());
    598                       listText = HTML.encodeTags(item instanceof Nameable ? ((Nameable)item).getName() : item.toString());
     599                      if (item instanceof Nameable)
     600                      {
     601                        Nameable nameable = (Nameable)item;
     602                        listText = HTML.encodeTags(nameable.getName());
     603                        listTitle = HTML.encodeTags(nameable.getDescription());
     604                      }
     605                      else
     606                      {
     607                        listText = item.toString();
     608                      }
    599609                    }
    600610                    else
     
    604614                    }
    605615                    %>
    606                     <option value="<%=listValue%>"><%=listText%>
     616                    <option value="<%=listValue%>" title="<%=listTitle%>"><%=listText%>
    607617                    <%
    608618                  }
     
    786796                  if (cc.getId() != 0)
    787797                  {
     798                    BasicItem item = parameterItemType.getById(dc, cc.getId());
     799                    String display = "";
     800                    if (item instanceof Nameable)
     801                    {
     802                      Nameable nameable = (Nameable)item;
     803                      display = nameable.getName();
     804                    }
     805                    else
     806                    {
     807                      display = item.toString();
     808                    }
    788809                    %>
    789                     <%=parameterItemType.getById(dc, cc.getId()).toString()%>
     810                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
     811                    <input class="text disabled" size="50" type="text" disabled value="<%=HTML.encodeTags(display)%>">
    790812                    <%
    791813                  }
  • branches/rf1/www/exception/exception.jsp

    r1973 r2128  
    3636--%>
    3737<%@ page
     38  import="net.sf.basedb.core.Application"
     39  import="net.sf.basedb.core.Config"
    3840  import="net.sf.basedb.core.NotLoggedInException"
    3941  import="net.sf.basedb.core.PermissionDeniedException"
     
    111113<base:body onload="fixWindow()">
    112114  <base:note type="error" title="<%=exceptionClassName + " on page "+request.getAttribute("javax.servlet.error.request_uri")%>" style="width:90%;">
    113     <%=HTML.formatLineBreaks(HTML.encodeTags(ex.getMessage(), ""))%>
     115    <table border="0" cellpadding="0" cellspacing="0" class="form">
     116    <tr>
     117      <td class="prompt">Base version</td>
     118      <td><%=Application.getMajorVersion() + "." +Application.getMinorVersion() + " (build #" + Application.getBuild()+")"%></td>
     119    </tr>
     120    <tr>
     121      <td class="prompt">Web server</td>
     122      <td><%=application.getServerInfo()%></td>
     123    </tr>
     124    <tr>
     125      <td class="prompt">Database Dialect</td>
     126      <td><%=Config.getString("db.dialect")%></td>
     127    </tr>
     128    <tr>
     129      <td class="prompt">JDBC Driver</td>
     130      <td><%=Config.getString("db.driver")%></td>
     131    </tr>
     132    <tr>
     133      <td class="prompt">Browser</td>
     134      <td><%=HTML.encodeTags(request.getHeader("User-Agent"))%></td>
     135    </tr>
     136    <tr>
     137      <td class="prompt">Error message</td>
     138      <td><%=HTML.formatLineBreaks(HTML.encodeTags(ex.getMessage(), ""))%></td>
     139    </tr>
     140    <tr>
     141      <td class="prompt">Stack trace</td>
     142      <td></td>
     143    </tr>
     144    </table>
     145   
    114146    <%
    115147    StackTraceElement[] st = ex.getStackTrace();
     
    151183    <base:button id="goback" onclick="<%="history.go(-1)"%>" title="Go back"/>
    152184    <base:button id="close" onclick="<%="window.close()"%>" title="Close"/>
    153     <base:button id="reportbug" onclick="<%="window.open('"+reportbuglink+"','Reportbug')"%>" title="Report bug"
     185    <base:button id="reportbug" onclick="<%="window.open('"+reportbuglink+"','Reportbug')"%>"
     186      title="Report bug&hellip;"
    154187    visible="<%=HTML.isValidUrl(reportbuglink)%>"/>
    155188  </base:buttongroup>
  • branches/rf1/www/views/experiments/bioassaysets/index.jsp

    r2117 r2128  
    8383final String viewPage = "view_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId;
    8484final String editPage = "edit_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId;
    85 final String newPage = "create_root_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId;
     85
     86final String newPage = "../../../common/plugin/index.jsp?ID="+ID
     87  +"&cmd=SelectPlugin&main_type=INTENSITY&item_type=BIOASSAYSET&context_type=LIST&title=Create+root+bioassay+set";
     88
     89sc.getCurrentContext(Item.EXPERIMENT).setId(experimentId);
    8690
    8791String forward = null;
  • branches/rf1/www/views/experiments/bioassaysets/list_bioassaysets.jsp

    r2117 r2128  
    166166    function newItem()
    167167    {
    168       Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 600, 400);
     168      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 740, 540);
    169169    }
    170170    function editItem(itemId)
     
    210210    function runPlugin(cmd)
    211211    {
    212       Table.submitToPopup(formId, cmd, 540, 460);
     212      Table.submitToPopup(formId, cmd, 740, 540);
    213213    }
    214214    function returnSelected()
     
    455455          title="New root bioassay set&hellip;"
    456456          tooltip="<%=createPermission ? "Create new event" : "You do not have permission to create events"%>"
     457          visible="<%=pluginCount.containsKey(Plugin.MainType.INTENSITY)%>"
    457458        />
    458459        <tbl:button
  • branches/rf1/www/views/formulas/edit_formula.jsp

    r2117 r2128  
    3636  import="net.sf.basedb.core.RawDataType"
    3737  import="net.sf.basedb.core.RawDataTypes"
     38  import="net.sf.basedb.core.RawDataProperty"
    3839  import="net.sf.basedb.core.PermissionDeniedException"
    3940  import="net.sf.basedb.clients.web.Base"
     
    158159      %>
    159160      rawDataTypes['<%=rdt.getId()%>'] = <%=rdt.getChannels()%>;
     161      var a = new Array();
     162      <%
     163      for (RawDataProperty rp : rdt.getProperties())
     164      {
     165        %>
     166        a['<%=rp.getName()%>'] = 1;
     167        <%
     168      }
     169      %>
     170      rawDataTypes['<%=rdt.getId()%>.properties'] = a;
    160171      <%
    161172    }
     
    219230    }
    220231   
     232    function validateOnClick()
     233    {
     234      var frm = document.forms['formula'];
     235      if (frm.expression.value != '')
     236      {
     237        try
     238        {
     239          var result = eval(frm.expression.value);
     240          alert('The expressions seems to be ok.\nNote! This feature is experimental and may not be 100% correct.');
     241        }
     242        catch (er)
     243        {
     244          alert(er + '\nNote! This feature is experimental and may not be 100% correct.');
     245        }
     246      }
     247    }
     248    function raw(property)
     249    {
     250      var frm = document.forms['formula'];
     251      var rdt = frm.rawdatatype[frm.rawdatatype.selectedIndex].value;
     252      if (!property) throw 'Property must be specified for function raw()';
     253      if (rdt == '') throw 'Cannot use function raw(). No raw data type selected';
     254      if (!rawDataTypes[rdt+'.properties'][property]) throw 'Property '+property+' not found for raw data type ' + rdt;
     255      return Math.random() * 100;
     256    }
     257    function mean(property)
     258    {
     259      var frm = document.forms['formula'];
     260      var rdt = frm.rawdatatype[frm.rawdatatype.selectedIndex].value;
     261      if (!property) throw 'Property must be specified for function mean()';
     262      if (rdt == '') throw 'Cannot use function mean(). No raw data type selected';
     263      if (!rawDataTypes[rdt+'.properties'][property]) throw 'Property '+property+' not found for raw data type ' + rdt;
     264      return Math.random() * 100;
     265    }
     266    function ch(channel)
     267    {
     268      var frm = document.forms['formula'];
     269      var type = frm.type[frm.type.selectedIndex].value;
     270      if (type == '<%=Formula.Type.INTENSITY_EXPRESSION.name()%>' || type == '<%=Formula.Type.INTENSITY_TRANSFORMATION.name()%>')
     271      {
     272        // Channel function not available
     273        throw 'Function ch() is not available for ' + frm.type[frm.type.selectedIndex].text;
     274      }
     275
     276      var channels = parseInt(frm.channels.value);
     277      if (!channel || channel <= 0 || channel > channels) throw 'Invalid channel: ' + channel + '; must be between 1 and '+ channels;
     278      return channel;
     279    }
     280    function log(value)
     281    {
     282      return Math.log(value);
     283    }
     284    function log2(value)
     285    {
     286      return Math.log(value);
     287    }
     288    function ln(value)
     289    {
     290      return Math.log(value);
     291    }
     292    function sqrt(value)
     293    {
     294      return Math.sqrt(value);
     295    }
    221296    </script>
    222297  </base:head>
     
    324399            <base:button onclick="addOnClick()" title="Add" />
    325400          </td>
     401          <td>
     402            <base:button onclick="validateOnClick()" title="Validate&hellip;"
     403              tooltip="Validate the selected expression. EXPERIMENTAL!!" />
     404          </td>
    326405          </table>
    327406        </td>
Note: See TracChangeset for help on using the changeset viewer.