Changeset 4912


Ignore:
Timestamp:
Apr 29, 2009, 1:49:20 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #1120: The dynamic part of BASE should keep track whether intensity data is in log space or not

Deprecated VirtualColumn?.channel(). Added functionality in the core to make it possible to convert transformed intensities back to regular intensities. Added RawChannelFunction? for cases where the stored intensity values are needed without conversion. What remains now is to check plug-ins and tools to make sure that the work correctly with both transformed and non-transformed data.

Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/BioAssaySet.java

    r4910 r4912  
    11581158      WHERE spt.cube = <cube_no> AND spt.layer = <layer_no> [ AND flt.filter = <filter_no> ]
    11591159    */
    1160     DynamicSpotQuery query = new DynamicSpotQuery(this.getDataCube());
     1160    DynamicSpotQuery query = new DynamicSpotQuery(this.getDataCube(), this.getIntensityTransform());
    11611161    query.restrictPermanent(
    11621162      new DynamicRestriction(VirtualColumn.LAYER, getDataCubeLayerNo())
  • trunk/src/core/net/sf/basedb/core/DataCube.java

    r4889 r4912  
    715715    private RawMappingQuery(DataCube dataCube)
    716716    {
    717       super(dataCube, VirtualTable.RAWPARENTS);
     717      super(dataCube, VirtualTable.RAWPARENTS, null);
    718718    }
    719719   
  • trunk/src/core/net/sf/basedb/core/DynamicExtraValueQuery.java

    r4889 r4912  
    5454  DynamicExtraValueQuery(DataCube cube, VirtualTable rootTable, VirtualColumn... defaultSelects)
    5555  {
    56     super(cube, rootTable);
     56    super(cube, rootTable, null);
    5757    this.defaultSelects = new Select[defaultSelects.length];
    5858    for (int i = 0; i < defaultSelects.length; ++i)
  • trunk/src/core/net/sf/basedb/core/DynamicPositionQuery.java

    r4889 r4912  
    5656  DynamicPositionQuery(DataCube cube)
    5757  {
    58     super(cube, VirtualTable.POSITION);
     58    super(cube, VirtualTable.POSITION, null);
    5959  }
    6060 
  • trunk/src/core/net/sf/basedb/core/DynamicQuery.java

    r4889 r4912  
    5151  private final VirtualDb virtualDb;
    5252  private final VirtualTable rootTable;
     53  private final IntensityTransform transform;
    5354
    5455  /**
     
    5758    @param rootTable The root table of the query
    5859  */
    59   DynamicQuery(DataCube cube, VirtualTable rootTable)
     60  DynamicQuery(DataCube cube, VirtualTable rootTable, IntensityTransform transform)
    6061  {
    6162    super(rootTable.getQualifiedTableName(cube.getVirtualDb()));
     
    6364    this.virtualDb = cube.getVirtualDb();
    6465    this.rootTable = rootTable;
     66    this.transform = transform;
    6567    restrictPermanent(
    6668      new DynamicRestriction(VirtualColumn.CUBE, cube.getCubeNo())
     
    9597    return rootTable;
    9698  }
     99 
     100  /**
     101    Get the intensity transform that was used to store spot intensities
     102    for the root bioassay set in this query.
     103    @since 2.12
     104  */
     105  public IntensityTransform getIntensityTransform()
     106  {
     107    return transform;
     108  }
     109 
    97110}
  • trunk/src/core/net/sf/basedb/core/DynamicSpotQuery.java

    r4889 r4912  
    5959    @param cube The cube to query against
    6060  */
    61   DynamicSpotQuery(DataCube cube)
    62   {
    63     super(cube, VirtualTable.SPOT);
     61  DynamicSpotQuery(DataCube cube, IntensityTransform transform)
     62  {
     63    super(cube, VirtualTable.SPOT, transform);
    6464    joinedItems = new HashSet<Object>();
    6565    setAutoJoinType(JoinType.LEFT);
  • trunk/src/core/net/sf/basedb/core/IntensityTransform.java

    r4910 r4912  
    2424import java.util.HashMap;
    2525import java.util.Map;
     26
     27import net.sf.basedb.core.query.Expression;
     28import net.sf.basedb.core.query.Expressions;
    2629
    2730
     
    3841    No transformation has been applied to the spot intensities.
    3942  */
    40   NONE(0, "None", false),
     43  NONE(0, "None", false)
     44  {
     45    /**
     46      @return The same expression
     47     */
     48    @Override
     49    public Expression unTransform(Expression transformed)
     50    {
     51      return transformed;
     52    }
     53    /**
     54      @return The same value
     55    */
     56    @Override
     57    public double unTransform(double transformed)
     58    {
     59      return transformed;
     60    }
     61  },
    4162
    4263  /**
    4364    Spot intensities are stored as base-2 logged values
    4465  */
    45   LOG2(1, "Logarithmic (base-2)", true),
     66  LOG2(1, "Logarithmic (base-2)", true)
     67  {
     68    /**
     69      @return A new expression: 2 ^ transformed
     70     */
     71    @Override
     72    public Expression unTransform(Expression transformed)
     73    {
     74      return Expressions.power(Expressions.integer(2), transformed);
     75    }
     76    /**
     77      @return 2 raised to the given value
     78    */
     79    @Override
     80    public double unTransform(double transformed)
     81    {
     82      return Math.pow(2.0, transformed);
     83    }
     84  },
    4685 
    4786  /**
    4887    Spot intensities are stored as base-10 logged values
    4988  */
    50   LOG10(2, "Logarithmic (base-10)", true);
     89  LOG10(2, "Logarithmic (base-10)", true)
     90  {
     91    /**
     92      @return A new expression: 10 ^ transformed
     93     */
     94    @Override
     95    public Expression unTransform(Expression transformed)
     96    {
     97      return Expressions.power(Expressions.integer(10), transformed);
     98    }
     99    /**
     100      @return 10 raised to the given value
     101    */
     102    @Override
     103    public double unTransform(double transformed)
     104    {
     105      return Math.pow(10.0, transformed);
     106    }
     107  };
    51108
    52109  /**
     
    127184    return isTransformed;
    128185  }
    129 
     186 
     187  /**
     188    Un-transform an expression representing a transformed intensity
     189    value so that it represents a raw intensity value. This method
     190    may return the same expression if no transformation is needed.
     191    @param transformed The transformed expression
     192  */
     193  public abstract Expression unTransform(Expression transformed);
     194
     195  /**
     196    Un-transform a transformed intensity value back to a
     197    regular intensity value.
     198    @param transformed The transformed value
     199  */
     200  public abstract double unTransform(double transformed);
    130201}
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r4889 r4912  
    4242import net.sf.basedb.util.jep.Jep;
    4343import net.sf.basedb.util.jep.JepFunction;
     44import net.sf.basedb.util.jep.RawChannelFunction;
    4445import net.sf.basedb.util.jep.RawFunction;
    4546import net.sf.basedb.util.jep.ReporterFunction;
     
    158159  // For parsing JEP expressions
    159160  private static final JepFunction ch = new ChannelFunction();
     161  private static final JepFunction rawCh = new RawChannelFunction();
    160162  private static final JepFunction raw = new RawFunction(true);
    161163  private static final JepFunction rep = new ReporterFunction();
     
    12881290      // propertyDef is %channel_number
    12891291      int channel = Integer.parseInt(propertyDef.substring(1));
    1290       e = Dynamic.column(VirtualColumn.channel(channel));
     1292      e = Dynamic.column(VirtualColumn.channelRaw(channel));
    12911293    }
    12921294    else if (propertyDef.startsWith("$"))
     
    13151317    {
    13161318      // propertyDef is JEP expression
    1317       e = Jep.formulaToExpression(propertyDef.substring(1), ch, raw, rep);
     1319      e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep);
    13181320    }
    13191321    else
     
    13521354      // propertyDef is $channel_number
    13531355      int channel = Integer.parseInt(propertyDef.substring(1));
    1354       s = Dynamic.select(VirtualColumn.channel(channel));
     1356      s = Dynamic.select(VirtualColumn.channelRaw(channel));
    13551357    }
    13561358    else if (propertyDef.startsWith("$"))
     
    13791381    {
    13801382      // propertyDef is JEP expression
    1381       Expression e = Jep.formulaToExpression(propertyDef.substring(1), ch, raw, rep);
     1383      Expression e = Jep.formulaToExpression(propertyDef.substring(1), ch, rawCh, raw, rep);
    13821384      s = Selects.expression(e, "jep" + System.identityHashCode(e));
    13831385    }
  • trunk/src/core/net/sf/basedb/core/VirtualColumn.java

    r4889 r4912  
    6767  public static final VirtualColumn CUBE =
    6868    new VirtualColumn("cube", "cube", Hibernate.SHORT, 0,
    69       !INDEXED, !NULLABLE, PRIMARY_KEY);
     69      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    7070   
    7171  /**
     
    7575  public static final VirtualColumn LAYER =
    7676    new VirtualColumn("layer", "layer", Hibernate.SHORT, 0,
    77       !INDEXED, !NULLABLE, PRIMARY_KEY);
     77      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    7878
    7979  /**
     
    8383  public static final VirtualColumn COLUMN =
    8484    new VirtualColumn("column", "column", Hibernate.SHORT, 0,
    85       !INDEXED, !NULLABLE, PRIMARY_KEY);
     85      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    8686 
    8787  /**
     
    9090  public static final VirtualColumn POSITION =
    9191    new VirtualColumn("position", "position", Hibernate.INTEGER, 0,
    92       !INDEXED, !NULLABLE, PRIMARY_KEY);
     92      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    9393
    9494  /**
     
    9898  public static final VirtualColumn FILTER =
    9999    new VirtualColumn("filter", "filter", Hibernate.SHORT, 0,
    100       !INDEXED, !NULLABLE, PRIMARY_KEY);
     100      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    101101
    102102  /**
     
    106106  public static final VirtualColumn EXTRA =
    107107    new VirtualColumn("extra", "extra", Hibernate.SHORT, 0,
    108       !INDEXED, !NULLABLE, PRIMARY_KEY);
     108      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    109109
    110110  /**
     
    115115  public static final VirtualColumn REPORTER_ID =
    116116    new VirtualColumn("reporterId", "reporter_id", Hibernate.INTEGER, 0,
    117       !INDEXED, NULLABLE, !PRIMARY_KEY);
     117      !INDEXED, NULLABLE, !PRIMARY_KEY, false);
    118118
    119119  /**
     
    124124  public static final VirtualColumn RAWDATA_ID =
    125125    new VirtualColumn("rawDataId", "rawdata_id", Hibernate.INTEGER, 0,
    126       !INDEXED, !NULLABLE, PRIMARY_KEY);
     126      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    127127 
    128128  /**
     
    133133  public static final VirtualColumn RAWBIOASSAY_ID =
    134134    new VirtualColumn("rawBioAssayId", "rawbioassay_id", Hibernate.INTEGER, 0,
    135       !INDEXED, !NULLABLE, PRIMARY_KEY);
     135      !INDEXED, !NULLABLE, PRIMARY_KEY, false);
    136136
    137137  /**
     
    140140  public static final VirtualColumn EXTRA_INT =
    141141    new VirtualColumn("extraInt", "value", Hibernate.INTEGER, 0,
    142       !INDEXED, NULLABLE, !PRIMARY_KEY);
     142      !INDEXED, NULLABLE, !PRIMARY_KEY, false);
    143143
    144144  /**
     
    147147  public static final VirtualColumn EXTRA_FLOAT =
    148148    new VirtualColumn("extraFloat", "value", Hibernate.FLOAT, 0,
    149       !INDEXED, NULLABLE, !PRIMARY_KEY);
     149      !INDEXED, NULLABLE, !PRIMARY_KEY, false);
    150150
    151151  /**
     
    154154  public static final VirtualColumn EXTRA_STRING =
    155155    new VirtualColumn("extraString", "value", Hibernate.STRING, 255,
    156       !INDEXED, NULLABLE, !PRIMARY_KEY);
    157 
    158   /**
    159     A cache of virtual column objects for channels.
    160   */
    161   private static final Map<Integer, VirtualColumn> channels =
    162     new HashMap<Integer, VirtualColumn>();
    163  
     156      !INDEXED, NULLABLE, !PRIMARY_KEY, false);
     157
    164158  /**
    165159    A cache of virtual column objects for extra value types.
     
    177171 
    178172  /**
    179     Get a column that stores the calculated intensity for a channel. Only
    180     one <code>VirtualColumn</code> object per channel exists.
    181173    @param channel The channel for which the intensity is calculated. 
     174    @return a VirtualColumn object
     175    @deprecated In 2.12. Use {@link #channelIntensity(int)} or
     176      {@link #channelRaw(int)} instead. This method is forwarded
     177      to {@link #channelIntensity(int)} for maximum backwards
     178      compatibility.
     179  */
     180  public static VirtualColumn channel(int channel)
     181  {
     182    return channelIntensity(channel);
     183  }
     184
     185  /**
     186    Get a column that stores the raw spot value for a channel. This
     187    may be an intensity value or a transformed value as given by the
     188    {@link BioAssaySet#getIntensityTransform()} for the current
     189    bioassay set.
     190    @param channel The channel number
    182191    @return a VirtualColumn object.
    183   */
    184   public static VirtualColumn channel(int channel)
    185   {
    186     VirtualColumn ch = channels.get(channel);
    187     if (ch == null)
    188     {
    189       ch = new VirtualColumn("ch"+channel, "ch"+channel, Hibernate.FLOAT, 0,
    190           !INDEXED, NULLABLE, !PRIMARY_KEY);
    191       synchronized (channels)
    192       {
    193         channels.put(channel, ch);
    194       }
    195     }
    196     return ch;
    197   }
    198 
     192    @since 2.12
     193    @see #channelIntensity(int)
     194  */
     195  public static VirtualColumn channelRaw(int channel)
     196  {
     197    return new VirtualColumn("ch"+channel, "ch"+channel, Hibernate.FLOAT, 0,
     198          !INDEXED, NULLABLE, !PRIMARY_KEY, false);
     199  }
     200 
     201  /**
     202    Get a column that returns the intensity values for a channel.
     203    Transformed intensity values (as given by the {@link
     204    BioAssaySet#getIntensityTransform()} setting for
     205    the current bioassay set), are untransformed automatically.
     206    @param channel The channel number
     207    @return a VirtualColumn object
     208    @since 2.12
     209    @see #channelRaw(int)
     210  */
     211  public static VirtualColumn channelIntensity(int channel)
     212  {
     213    return new VirtualColumn("ch"+channel, "ch"+channel, Hibernate.FLOAT, 0,
     214          !INDEXED, NULLABLE, !PRIMARY_KEY, true);
     215  }
     216 
    199217  /**
    200218    Get a column that stores the calculated extra values for a value type. Only
     
    245263  private final boolean primaryKey;
    246264 
     265  private final boolean untransformIntensities;
     266 
    247267  /**
    248268    Create a new virtual column.
    249269  */
    250270  private VirtualColumn(String name, String column, NullableType type, int size,
    251     boolean indexed, boolean nullable, boolean primaryKey)
     271    boolean indexed, boolean nullable, boolean primaryKey, boolean untransformIntensities)
    252272  {
    253273    this.name = name;
     
    258278    this.nullable = nullable;
    259279    this.primaryKey = primaryKey;
     280    this.untransformIntensities = untransformIntensities;
    260281  }
    261282 
     
    325346  }
    326347
     348  /**
     349    A flag indicating if transformed intensity valus belonging
     350    to a bioassay set should be untransformed as part of a query.
     351    @since 2.12
     352    @see #channelIntensity(int)
     353  */
     354  public boolean untransformIntensities()
     355  {
     356    return untransformIntensities;
     357  }
    327358}
  • trunk/src/core/net/sf/basedb/core/dbengine/AbstractDbEngine.java

    r4557 r4912  
    135135  }
    136136  /**
     137    Return <code>POWER(&lt;base&gt;, &lt;exponent&gt;)</code>.
     138  */
     139  public String power(String base, String exponent)
     140  {
     141    return "POWER("+ base + "," + exponent + ")";
     142  }
     143  /**
    137144    Return <code>&lt;value&gt; = &lt;regexp&gt;</code>
    138145    @since 2.8
  • trunk/src/core/net/sf/basedb/core/dbengine/DbEngine.java

    r4557 r4912  
    257257
    258258  /**
     259    Get the function call that calculates <code>base</code>
     260    raised to the power of <code>exponent</code>
     261    For example: <code>POW(base, value)</code>
     262    @param base The base in the expression
     263    @param exponent The exponent in the expression
     264    @return The function call that calculates the power
     265    @throws UnsupportedOperationException If the database doesn't support
     266      this function
     267  */
     268  public String power(String base, String exponent);
     269 
     270  /**
    259271    Get a function/expression that matches the left value against
    260272    the right value which should be a regular expression. If the
  • trunk/src/core/net/sf/basedb/core/query/ExpExpression.java

    r4516 r4912  
    3434  @author Nicklas
    3535  @version 2.0
    36   @see Expressions#abs(Expression)
     36  @see Expressions#exp(Expression)
    3737  @base.modified $Date$
    3838*/
  • trunk/src/core/net/sf/basedb/core/query/Expressions.java

    r4889 r4912  
    300300    if (e == null) throw new InvalidUseOfNullException("e");
    301301    return new ExpExpression(e);
     302  }
     303 
     304  /**
     305    Calculate the first expression raised to the power
     306    of the second expression: new expression = e1 ^ e2
     307    @param e1 The base expression
     308    @param e2 The exponent expression
     309    @return The new expression
     310    @since 2.12
     311    @throws InvalidDataException If some of the arguments are null
     312  */
     313  public static Expression power(Expression e1, Expression e2)
     314  {
     315    if (e1 == null) throw new InvalidUseOfNullException("e1");
     316    if (e2 == null) throw new InvalidUseOfNullException("e2");
     317    return new PowerExpression(e1, e2);   
    302318  }
    303319 
  • trunk/src/core/net/sf/basedb/core/query/VirtualColumnExpression.java

    r4889 r4912  
    2525import java.util.Collection;
    2626
     27import net.sf.basedb.core.DynamicQuery;
     28import net.sf.basedb.core.IntensityTransform;
    2729import net.sf.basedb.core.VirtualTable;
    2830import net.sf.basedb.core.VirtualColumn;
     
    5961    if (query.getQueryType() == QueryType.SQL)
    6062    {
    61       return (table == null ? query.getRootAlias() : HibernateUtil.quote(table.getAlias())) + "." + HibernateUtil.quote(column.getColumn());
     63      String expression = (table == null ? query.getRootAlias() : HibernateUtil.quote(table.getAlias())) + "." + HibernateUtil.quote(column.getColumn());
     64      if (column.untransformIntensities() && query instanceof DynamicQuery)
     65      {
     66        DynamicQuery dq = (DynamicQuery)query;
     67        IntensityTransform transform = dq.getIntensityTransform();
     68        expression = transform.unTransform(new WrappedExpression(expression)).toQl(query, dc);
     69      }
     70      return expression;
    6271    }
    6372    else
     
    8392  }
    8493  // -------------------------------------------
     94 
     95  static class WrappedExpression
     96    implements Expression
     97  {
     98
     99    private final String expression;
     100    WrappedExpression(String expression)
     101    {
     102      this.expression = expression;
     103    }
     104   
     105    @Override
     106    public Collection<? extends QueryElement> getChildren()
     107    {
     108      return null;
     109    }
     110    @Override
     111    public String toQl(Query query, DbControl dc)
     112      throws BaseException
     113    {
     114      return expression;
     115    }
     116  }
     117 
    85118}
  • trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java

    r4515 r4912  
    4242import net.sf.basedb.util.jep.NotInReporterListFunction;
    4343import net.sf.basedb.util.jep.PositionFunction;
     44import net.sf.basedb.util.jep.RawChannelFunction;
    4445import net.sf.basedb.util.jep.RawFunction;
    4546import net.sf.basedb.util.jep.ReporterFunction;
     
    168169      allowRawIfMultipleMappings);
    169170    ChannelFunction ch = new ChannelFunction();
     171    RawChannelFunction rawCh = new RawChannelFunction();
    170172    ReporterFunction reporter = new ReporterFunction();
    171173    ScoreFunction score = new ScoreFunction(dc);
     
    173175    InReporterListFunction inList = new InReporterListFunction(dc);
    174176    NotInReporterListFunction notInList = new NotInReporterListFunction(dc);
    175     return Jep.formulaToRestriction(formula, raw, ch, reporter, score, xtra, inList, notInList);
     177    return Jep.formulaToRestriction(formula, raw, ch, rawCh, reporter, score, xtra, inList, notInList);
    176178  }
    177179
     
    187189    <li>rep(property): The value of the specified reporter property
    188190    <li>pos: The position of a spot. Note that this is not the same as raw(position)
    189     <li>ch(n): The intensity in channel n
     191    <li>ch(n): The intensity in channel n (un-transformed)
     192    <li>rawCh(n): The possibly transformed intensity in channel n
    190193    <li>score(list): The score of the {@link net.sf.basedb.core.data.ReporterData} in the
    191194      specified {@link net.sf.basedb.core.ReporterList} (numeric or external ID)
     
    211214      allowRawIfMultipleMappings);
    212215    ChannelFunction ch = new ChannelFunction();
     216    RawChannelFunction rawCh = new RawChannelFunction();
    213217    PositionFunction pos = new PositionFunction();
    214218    ReporterFunction reporter = new ReporterFunction();
    215219    ScoreFunction score = new ScoreFunction(dc);
    216220    ExtraValueFunction xtra = new ExtraValueFunction(dc, bioAssaySet);
    217     return Jep.formulaToExpression(formula, raw, ch, pos, reporter, score, xtra);
     221    return Jep.formulaToExpression(formula, raw, ch, rawCh, pos, reporter, score, xtra);
    218222  }
    219223 
  • trunk/src/core/net/sf/basedb/util/jep/ChannelFunction.java

    r4889 r4912  
    2525import net.sf.basedb.core.BioAssaySet;
    2626import net.sf.basedb.core.DbControl;
     27import net.sf.basedb.core.IntensityTransform;
    2728import net.sf.basedb.core.VirtualColumn;
    2829import net.sf.basedb.core.query.Dynamic;
     
    4041  A JEP function class that adds a <code>ch(int)</code> function to a
    4142  JEP expression parser. The function will look up the intensity value for the
    42   given channel. For example:
    43   <code>ch(1) / ch(2)</code>
     43  given channel. For example: <code>ch(1) / ch(2)</code>
     44  <p>
     45  Note! If the current bioassay set has stored transformed intensity values,
     46  the values are un-transformed before returned by the this function.
     47  Use {@link RawChannelFunction} if you need the raw values exactly
     48  as they are stored in the database.
    4449  <p>
    4550  To be able to use this function it must be registered with the JEP
     
    7580
    7681  private int[] channelToIndex;
     82  private IntensityTransform transform;
    7783  private SqlResult result;
    7884  private int numParameters;
     
    8692  public ChannelFunction()
    8793  {}
     94 
     95  /**
     96    @deprecated In 2.12. Use {@link ChannelFunction#ChannelFunction(int[], IntensityTransform)}
     97      instead. Using this constructor will disable the untransformation
     98      of transformed values when JEP dynamic evalution is used.
     99  */
     100  public ChannelFunction(int[] channelToIndex)
     101  {
     102    this.channelToIndex = channelToIndex;
     103  }
    88104 
    89105  /**
     
    94110    @see #setSqlResult(SqlResult)
    95111  */
    96   public ChannelFunction(int[] channelToIndex)
     112  public ChannelFunction(int[] channelToIndex, IntensityTransform transform)
    97113  {
    98114    this.channelToIndex = channelToIndex;
     115    this.transform = transform;
    99116  }
    100117 
     
    126143      throw new BaseException("Invalid number of expressions for 'ch' function: " + numChildren);
    127144    }
    128     return Dynamic.column(VirtualColumn.channel(Jep.nodeToInt(node.jjtGetChild(0))));
     145    return Dynamic.column(VirtualColumn.channelIntensity(Jep.nodeToInt(node.jjtGetChild(0))));
    129146  }
    130147  // -------------------------------------------
     
    196213    try
    197214    {
    198       return result.getObject(channelToIndex[channel-1]);
     215      Number n = (Number)result.getObject(channelToIndex[channel-1]);
     216      if (transform != null) n = transform.unTransform(n.doubleValue());
     217      return n;
    199218    }
    200219    catch (SQLException ex)
  • trunk/src/core/net/sf/basedb/util/jep/Jep.java

    r4889 r4912  
    190190raw    {@link Dynamic#rawData(String)} *
    191191ch     {@link Dynamic#column(VirtualColumn)} *
     192rawCh  {@link Dynamic#column(VirtualColumn)} *
    192193<i>number</i> {@link Expressions#integer(int)} or
    193194       {@link Expressions#aFloat(float)}
  • trunk/www/common/expression_builder.jsp

    r4605 r4912  
    252252    function ch(channel)
    253253    {
     254      checkChannel('ch()', channel);
     255      return channel;
     256    }
     257    function rawCh(channel)
     258    {
     259      checkChannel('rawCh()', channel);
     260      return channel;
     261    }
     262    function checkChannel(name, channel)
     263    {
    254264      var type = '<%=formulaType.name()%>';
    255265      if (type == '<%=Formula.Type.INTENSITY_EXPRESSION.name()%>')
    256266      {
    257267        // Channel function not available
    258         throw 'Function ch() is not available for ' + type;
    259       }
    260  
     268        throw 'Function ' + name + ' is not available for ' + type;
     269      }
    261270      var channels = <%=channels%>;
    262       if (!channel || channel <= 0 || channel > channels) throw 'Invalid channel: ' + channel + '; must be between 1 and '+ channels;
    263       return channel;
    264     }
     271      if (!channel || channel <= 0 || channel > channels)
     272      {
     273        throw 'Invalid channel: ' + channel + '; must be between 1 and '+ channels;
     274      }
     275    }
     276
     277
     278   
    265279    function pos()
    266280    {
Note: See TracChangeset for help on using the changeset viewer.