Package net.sf.basedb.util.jep
Class ChannelFunction
java.lang.Object
net.sf.basedb.util.jep.ChannelFunction
- All Implemented Interfaces:
JepExpressionFunction
,JepFunction
,org.nfunk.jep.function.PostfixMathCommandI
A JEP function class that adds a
ch(int)
function to a
JEP expression parser. The function will look up the intensity value for the
given channel. For example: ch(1) / ch(2)
Note! If the current bioassay set has stored transformed intensity values,
the values are un-transformed before returned by the this function.
Use RawChannelFunction
if you need the raw values exactly
as they are stored in the database.
To be able to use this function it must be registered with the JEP
parser and, before the expression is evaluated, a SqlResult
object must be set.
For example we can evaluate an expression for every position in a bioassay:
DbControl dc = ... BioAssay assay = ... String expression = "ch(1) / ch(2)"; ChannelFunction ch = new ChannelFunction({3, 4}); JEP jep = JepUtil.newJep(expression, ch); DynamicResultIterator result = assay.getSpotData().iterate(dc); while (result.hasNext()) { ch.setSqlResult(result.next()); double value = jep.getValue(); // Do something with the value } result.close();
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate int[]
private int
private SqlResult
private IntensityTransform
-
Constructor Summary
ConstructorDescriptionCreate a new instance of this function.ChannelFunction
(int[] channelToIndex, IntensityTransform transform) Create a new instance of this function which can be used to dynamically evaluate expressions. -
Method Summary
Modifier and TypeMethodDescriptionchannel
(int channel) Get the value of the specified channel of the current sql result.boolean
checkNumberOfParameters
(int n) Get the name of this function.int
void
void
setCurNumberOfParameters
(int n) void
setSqlResult
(SqlResult result) Set a newSqlResult
object that will be used the next time the JEP expression is evaluated.toExpression
(Node node) Use theDynamic.column(VirtualColumn)
method to create an expression referencing a channel intensity.
-
Field Details
-
channelToIndex
private int[] channelToIndex -
transform
-
result
-
numParameters
private int numParameters
-
-
Constructor Details
-
ChannelFunction
public ChannelFunction()Create a new instance of this function. The new instance cannot be used to dynamically evaluate expressions. It should only be used for converting JEP formulas toExpression
:s. -
ChannelFunction
Create a new instance of this function which can be used to dynamically evaluate expressions.- Parameters:
channelToIndex
- An array that maps channel numbers to column indexes in the SqlResult, array position 0 maps the index of channel number 1, etc.- See Also:
-
-
Method Details
-
getFunctionName
Description copied from interface:JepFunction
Get the name of this function. It is used when registering the function with aJEP
parser.- Specified by:
getFunctionName
in interfaceJepFunction
- Returns:
- The string "ch"
- See Also:
-
toExpression
Use theDynamic.column(VirtualColumn)
method to create an expression referencing a channel intensity.- Specified by:
toExpression
in interfaceJepExpressionFunction
- Parameters:
node
- The node representing this function- Returns:
- An
Expression
object
-
getNumberOfParameters
public int getNumberOfParameters()- Specified by:
getNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
- Returns:
- Always 1
-
setCurNumberOfParameters
public void setCurNumberOfParameters(int n) - Specified by:
setCurNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n) - Specified by:
checkNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
run
- Specified by:
run
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
- Throws:
ParseException
-
setSqlResult
Set a newSqlResult
object that will be used the next time the JEP expression is evaluated.- Parameters:
result
- The result object
-
channel
Get the value of the specified channel of the current sql result.- Parameters:
channel
- The channel number- Throws:
ParseException
- Either if it's an invalid channel number or if no result object has been specified.
-