-
Notifications
You must be signed in to change notification settings - Fork 44
State Functions
#State Functions State functions are user-defined functions that are called within a state to get a probability to apply to the scoring. The functions can be called at either evaluation of an emission or transition.
The function passed to assigned in a StateFunc class object and passed to the model import function. Only a single StateFunc can be passed to the model import. If multiple functions need to be passed to the model, the functions need to be assigned to a single StateFunc object.
###Creating and Assigning StateFunc
StateFunc stFunc;
#Assigning a transition function
stFunc.assignTransitionFunction( const char* <Name of Function>, <pointer to transition function>);
#Assigning a emission function
stFunc.assignTransitionFucntion( const char* <Name of Function>, <pointer to emission function>);
#Assigning a univariate probability density function
stFunc.assignPDFFucntion( const char* <Name of Function>, <pointer to probability density function>);
#Assigning a multivariate probability density function
stFunc.assignMultivariatePdfFunction( const char* <Name of Function>, <pointer to multivariate probability density function>);
##Emission Functions Emission functions can be defined and called on any State emission. The return value of this function will be applied to the standard emission probability as a natural logarithmic value. This allows the user to either use a function to calculate the emission probability or use a function to weight the emissions based on some other criteria.
###Definition Emission functions need to return a double and take the parameters (const std::string*, size_t). The std::string the function will receive is the sequence for the defined track. The size_t will be the position within the string being evaluated by the emission.
Any function of the form double myFunctionName (const std::string*, const size_t)
can be used for an emission function.
###Assigning Function to StateFunc object
StateFunc stFunc;
#Assigning a emission function
stFunc.assignTransitionFucntion( "MyFunction", &myFunctionName);
###Calling within the Model Within the model the function will be called at any emission where Emission Tag is placed.
####Example
EMISSION: SEQ: P(X) [FUNCTION: MyFunction TRACK: SEQ SCALE: 0]
ORDER: 0
@A C G T
0.1 0.1 0.1 0.1
When evaluating this emission, the function "MyFunction" will be called and passed the track labeled "SEQ". The returned score will be scaled by a value 0 or any be the corresponding SCALING Function that was defined in the model.
Note: The SCALE
is optional in Emission TAG. If SCALE
is left out the value will be passed, directly to the model and not scaled by any value, which is equivalent to SCALE: 0