StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes
StochHMM::transitionFuncParam Class Reference

#include <externalFuncs.h>

List of all members.

Public Member Functions

 transitionFuncParam ()
bool parse (stringList &, tracks &, weights *, StateFuncs *)
 Parse the stringList from model import.
void setTransFunc (std::string &, transitionFunc *, weight *)
void setTransTB (tracebackIdentifier, std::string &, combineIdentifier, std::string &)
bool isTracebackDefined ()
tracebackIdentifier getTracebackType ()
std::string & getTracebackName ()
std::string & getCombineName ()
combineIdentifier getCombineType ()
std::string & getTrackName ()
trackgetTrack ()
double evaluate (const std::string *, size_t, const std::string *, size_t)
void print ()
 Print the externalFuncts to stdout.
std::string stringify ()
 prints the string representation of the externFuncs to stdout

Private Attributes

transitionFunctransFunc
 Return string representation of the externFuncs definition in the model.
std::string trackName
tracktransFuncTrack
 What track to pass to the function.
std::string transFuncName
 Pointer to track function uses.
weighttransFuncScaling
 < Name of the external function as used in the model
bool transFuncTraceback
 < weighting information for values
tracebackIdentifier transFuncTracebackIdentifier
 defines whether a traceback in necessary for the function
std::string transFuncTracebackString
combineIdentifier transFuncCombineIdentifier
 Contains name of traceback.
std::string transFuncCombineString
 < Contains information on how to combine the traceback information

Detailed Description

Definition at line 61 of file externalFuncs.h.


Constructor & Destructor Documentation

StochHMM::transitionFuncParam::transitionFuncParam ( )

Create transFuncParam from a stringList parsed from model for given track and applying a weight as defined in the model

Parameters:
lststringList from parsing the line in the function
trckstracks defined in the model
wtspointer to weights as defined in the model
funcspointer to the state functions defined by user and referenced in the model

Definition at line 39 of file externalFuncs.cpp.

References transFunc.

{
transFunc=NULL;
}

Member Function Documentation

double StochHMM::transitionFuncParam::evaluate ( const std::string *  fullSequence,
size_t  pos,
const std::string *  partialSequence,
size_t  length 
)

Definition at line 225 of file externalFuncs.cpp.

References transFunc.

Referenced by StochHMM::trellis::transitionFuncTraceback().

{
return (*transFunc)(fullSequence, pos, partialSequence,length);
}
std::string& StochHMM::transitionFuncParam::getCombineName ( )
inline

Return what is suppose to be combined (State/Label/GFF)

Returns:
std::string

Definition at line 93 of file externalFuncs.h.

References transFuncCombineString.

Referenced by StochHMM::state::checkLabels(), and StochHMM::trellis::transitionFuncTraceback().

combineIdentifier StochHMM::transitionFuncParam::getCombineType ( )
inline

Get the Combine type to apply to the traceback *How the traceback is to be combined (editing of traceback)

Returns:
combineIdentifier
See also:
enum combineIdentifier

Definition at line 99 of file externalFuncs.h.

References transFuncCombineIdentifier.

Referenced by StochHMM::state::checkLabels(), and StochHMM::trellis::transitionFuncTraceback().

std::string& StochHMM::transitionFuncParam::getTracebackName ( )
inline

Return where the traceback is to go back to before stopping

Returns:
std::string State/Label/GFF tag to traceback to

Definition at line 89 of file externalFuncs.h.

References transFuncTracebackString.

Referenced by StochHMM::state::checkLabels(), and StochHMM::trellis::transitionFuncTraceback().

tracebackIdentifier StochHMM::transitionFuncParam::getTracebackType ( )
inline

Returns what how extensive of a a traceback is required

Returns:
tracbackIdentifier Type of traceback required
See also:
enum tracebackIdentifier

Definition at line 85 of file externalFuncs.h.

References transFuncTracebackIdentifier.

Referenced by StochHMM::state::checkLabels(), and StochHMM::trellis::transitionFuncTraceback().

track* StochHMM::transitionFuncParam::getTrack ( )
inline

Definition at line 105 of file externalFuncs.h.

References transFuncTrack.

Referenced by StochHMM::trellis::transitionFuncTraceback().

{return transFuncTrack;};
std::string& StochHMM::transitionFuncParam::getTrackName ( )
inline

Get track name to pass to the function (as defined in the model)

Returns:
std::string Track Name as defined in the model to be passed to the function

Definition at line 103 of file externalFuncs.h.

References trackName.

Referenced by StochHMM::transition::_processTags().

{return trackName;};
bool StochHMM::transitionFuncParam::isTracebackDefined ( )
inline

Check to see if a traceback is defined as necessary

Returns:
true if a traceback is necessary
false if a traceback is not required

Definition at line 80 of file externalFuncs.h.

References transFuncTraceback.

bool StochHMM::transitionFuncParam::parse ( stringList lst,
tracks trcks,
weights wts,
StateFuncs funcs 
)

Parse the stringList from model import.

Definition at line 50 of file externalFuncs.cpp.

References StochHMM::stringList::contains(), StochHMM::weights::count(), StochHMM::DIFF_STATE, StochHMM::FULL, StochHMM::tracks::getTrack(), StochHMM::StateFuncs::getTransitionFunction(), StochHMM::stringList::indexOf(), StochHMM::isNumeric(), StochHMM::weight::setAbsolute(), StochHMM::START_INIT, StochHMM::STATE_GFF, StochHMM::STATE_LABEL, StochHMM::STATE_NAME, StochHMM::STATEGFF, StochHMM::STATELABEL, StochHMM::STATENAME, StochHMM::stringToDouble(), trackName, transFunc, transFuncCombineIdentifier, transFuncCombineString, transFuncName, transFuncScaling, transFuncTraceback, transFuncTracebackIdentifier, transFuncTracebackString, and transFuncTrack.

Referenced by StochHMM::transition::_processTags().

{
size_t idx;
//FUNCTION NAME (REQUIRED)
if (lst.contains("FUNCTION")){
idx=lst.indexOf("FUNCTION");
idx++;
transFuncName = lst[idx];
if (funcs!=NULL){
transFunc = funcs->getTransitionFunction(transFuncName);
}
}
else{
std::cerr << "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n" << std::endl;
return false;
//errorInfo(sCantParseLine, "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n");
}
//Implement Which track to pass to function
if (lst.contains("TRACK")){
idx=lst.indexOf("TRACK");
idx++;
trackName=lst[idx];
transFuncTrack = trcks.getTrack(trackName);
}
else{
std::cerr << "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n" << std::endl;
return false;
//errorInfo(sCantParseLine, "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n");
}
if (lst.contains("SCALE")){
idx=lst.indexOf("SCALE");
idx++;
if (isNumeric(lst[idx])){
transFuncScaling = new(std::nothrow) weight;
if (transFuncScaling==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
double tempValue;
if (!stringToDouble(lst[idx], tempValue)){
std::cerr << "Ambiguous Value couldn't be parsed: "<< lst[idx] << std::endl;
return false;
}
}
else{
std::string weightName=lst[idx];
if (wts->count(weightName)){
transFuncScaling = (*wts)[weightName];
}
}
}
//Process Traceback Commands
//Parse the TO Traceback Labels in the function tag
const std::string tbLabels[]= {"TO_LABEL","TB->LABEL","TO_GFF","TB->GFF","TO_STATE","TB->STATE","TO_START","TB->START","DIFF_STATE"};
for(int i=0;i<9;i++){
if (lst.contains(tbLabels[i])){
idx=lst.indexOf(tbLabels[i]);
if (typs[i]!=START_INIT || typs[i]!=DIFF_STATE){
}
}
}
// Parse the Combine tags
//Process Traceback Combining Commands
std::string combineLabels[] = {"COMBINE_LABEL","COMBINE_GFF","COMBINE_STATE", "NO_COMBINE"};
bool combineTypeProvided=false;
for(int i=0;i<4;i++){
if (lst.contains(combineLabels[i])){
idx=lst.indexOf(combineLabels[i]);
combineTypeProvided=true;
}
}
if (!combineTypeProvided){
std::cerr << "Transition Function tag with a traceback was called, but no CombineType was provided. If no traceback is needed then please remove traceback command. \n" << std::endl;
return false;
//errorInfo(sTagIncorrect, "Transition Function tag with a traceback was called, but no CombineType was provided. If no traceback is needed then please remove traceback command. \n");
}
}
return true;
}
void StochHMM::transitionFuncParam::print ( )

Print the externalFuncts to stdout.

Definition at line 164 of file externalFuncs.cpp.

References stringify().

{
std::cout<<stringify()<<std::endl;
}
void StochHMM::transitionFuncParam::setTransFunc ( std::string &  funcName,
transitionFunc function,
weight scaling 
)

Add function to externFunc

Parameters:
funcNamestd::string name given to function (as referenced in model)
functionPointer to pt2StateFunc*, function to use
scalingPointer to weight, how to weight the functions results before applying to emission/transition

Definition at line 204 of file externalFuncs.cpp.

References transFunc, transFuncName, and transFuncScaling.

{
transFunc=function;
transFuncName=funcName;
}
void StochHMM::transitionFuncParam::setTransTB ( tracebackIdentifier  tbIdent,
std::string &  tbString,
combineIdentifier  cbIdent,
std::string &  cbString 
)

Set all the traceback and combine types for the traceback before calling the function

Parameters:
tbIdenttracebackIdentifier
tbStringTraceback string to use (State/GFF/Label)
cbIdentcombineIdentifier
cbStringCombine string to use when editing traceback (State/GFF/Label)

Definition at line 215 of file externalFuncs.cpp.

References transFuncCombineIdentifier, transFuncCombineString, transFuncTraceback, transFuncTracebackIdentifier, and transFuncTracebackString.

std::string StochHMM::transitionFuncParam::stringify ( )

prints the string representation of the externFuncs to stdout

Get string representation of the externalFuncs

Returns:
std::string Representation of externalFuncs

Definition at line 170 of file externalFuncs.cpp.

References StochHMM::double_to_string(), StochHMM::weight::getAbsolute(), StochHMM::weight::getName(), StochHMM::weight::isAbsolute(), StochHMM::START_INIT, StochHMM::STATE_GFF, StochHMM::STATE_LABEL, StochHMM::STATE_NAME, StochHMM::STATEGFF, StochHMM::STATELABEL, StochHMM::STATENAME, trackName, transFuncCombineIdentifier, transFuncCombineString, transFuncName, transFuncScaling, transFuncTraceback, transFuncTracebackIdentifier, and transFuncTracebackString.

Referenced by print(), and StochHMM::transition::stringify().

{
std::string exFuncString;
exFuncString+="[ FUNCTION:\t" + transFuncName + "\t";
exFuncString+="TRACK:\t" + trackName + "\t";
exFuncString+= (transFuncTracebackIdentifier == STATE_NAME) ? "TO_STATE:\t" + transFuncTracebackString + "\t":
(transFuncTracebackIdentifier == START_INIT) ? "TO_START:\t": "DIFF_STATE:\t" ;
exFuncString+= (transFuncCombineIdentifier == STATENAME) ? "COMBINE_STATE:\t" + transFuncCombineString + "\t":
(transFuncCombineIdentifier == STATELABEL) ? "COMBINE_LABEL:\t" + transFuncCombineString + "\t":
(transFuncCombineIdentifier == STATEGFF) ? "COMBINE_GFF:\t" + transFuncCombineString :"NO_COMBINE:\t";
}
if (transFuncScaling!=NULL){
exFuncString+="SCALE:\t" + double_to_string(transFuncScaling->getAbsolute());
}
else{
exFuncString+="SCALE:\t" + transFuncScaling->getName();
}
}
exFuncString += " ]";
return exFuncString;
}

Member Data Documentation

std::string StochHMM::transitionFuncParam::trackName
private

Definition at line 114 of file externalFuncs.h.

Referenced by getTrackName(), parse(), and stringify().

transitionFunc* StochHMM::transitionFuncParam::transFunc
private

Return string representation of the externFuncs definition in the model.

Definition at line 113 of file externalFuncs.h.

Referenced by evaluate(), parse(), setTransFunc(), and transitionFuncParam().

combineIdentifier StochHMM::transitionFuncParam::transFuncCombineIdentifier
private

Contains name of traceback.

Definition at line 127 of file externalFuncs.h.

Referenced by getCombineType(), parse(), setTransTB(), and stringify().

std::string StochHMM::transitionFuncParam::transFuncCombineString
private

< Contains information on how to combine the traceback information

Definition at line 128 of file externalFuncs.h.

Referenced by getCombineName(), parse(), setTransTB(), and stringify().

std::string StochHMM::transitionFuncParam::transFuncName
private

Pointer to track function uses.

Definition at line 117 of file externalFuncs.h.

Referenced by parse(), setTransFunc(), and stringify().

weight* StochHMM::transitionFuncParam::transFuncScaling
private

< Name of the external function as used in the model

Definition at line 119 of file externalFuncs.h.

Referenced by parse(), setTransFunc(), and stringify().

bool StochHMM::transitionFuncParam::transFuncTraceback
private

< weighting information for values

Definition at line 122 of file externalFuncs.h.

Referenced by isTracebackDefined(), parse(), setTransTB(), and stringify().

tracebackIdentifier StochHMM::transitionFuncParam::transFuncTracebackIdentifier
private

defines whether a traceback in necessary for the function

What to traceback until

Definition at line 124 of file externalFuncs.h.

Referenced by getTracebackType(), parse(), setTransTB(), and stringify().

std::string StochHMM::transitionFuncParam::transFuncTracebackString
private

Definition at line 125 of file externalFuncs.h.

Referenced by getTracebackName(), parse(), setTransTB(), and stringify().

track* StochHMM::transitionFuncParam::transFuncTrack
private

What track to pass to the function.

Definition at line 115 of file externalFuncs.h.

Referenced by getTrack(), and parse().


The documentation for this class was generated from the following files: