OpenMS  2.5.0
List of all members
HiddenMarkovModel Class Reference

Hidden Markov Model implementation of PILIS. More...

#include <OpenMS/ANALYSIS/ID/HiddenMarkovModel.h>

Constructors and destructors

Map< HMMState *, Map< HMMState *, double > > trans_
 
Map< HMMState *, Map< HMMState *, double > > count_trans_
 
Map< HMMState *, Map< HMMState *, std::vector< double > > > count_trans_all_
 
Map< HMMState *, Map< HMMState *, std::vector< double > > > train_count_trans_all_
 
Map< HMMState *, Map< HMMState *, Size > > training_steps_count_
 
Map< HMMState *, doubleforward_
 
Map< HMMState *, doublebackward_
 
Map< String, HMMState * > name_to_state_
 
Map< HMMState *, doubletrain_emission_prob_
 
Map< HMMState *, doubleinit_prob_
 
std::set< HMMState * > states_
 
std::set< std::pair< HMMState *, HMMState * > > trained_trans_
 
Map< String, Map< String, std::pair< String, String > > > synonym_trans_names_
 
Map< HMMState *, Map< HMMState *, std::pair< HMMState *, HMMState * > > > synonym_trans_
 
Map< HMMState *, std::set< HMMState * > > enabled_trans_
 
double pseudo_counts_
 
StringList var_modifications_
 
 HiddenMarkovModel ()
 default constructor More...
 
 HiddenMarkovModel (const HiddenMarkovModel &hmm_new)
 copy constructor More...
 
virtual ~HiddenMarkovModel ()
 destructor More...
 
HiddenMarkovModeloperator= (const HiddenMarkovModel &)
 assignment operator More...
 
void writeGraphMLFile (const String &filename)
 writes the HMM into a file in GraphML format More...
 
void write (std::ostream &out) const
 writes the HMM into an outstream More...
 
double getTransitionProbability (const String &s1, const String &s2) const
 returns the transition probability of the given state names More...
 
void setTransitionProbability (const String &s1, const String &s2, double prob)
 sets the transition probability of the given state names to prob More...
 
Size getNumberOfStates () const
 return the number of states More...
 
void addNewState (HMMState *state)
 registers a new state to the HMM More...
 
void addNewState (const String &name)
 registers a new state to the HMM More...
 
void addSynonymTransition (const String &name1, const String &name2, const String &synonym1, const String &synonym2)
 add a new synonym transition to the given state names More...
 
void evaluate ()
 evaluate the HMM, estimates the transition probabilities from the training More...
 
void train ()
 trains the HMM; initial probabilities and emission probabilities of the emitting states should be set More...
 
void setInitialTransitionProbability (const String &state, double prob)
 sets the initial transition probability of the given state to prob More...
 
void clearInitialTransitionProbabilities ()
 clears the initial probabilities More...
 
void setTrainingEmissionProbability (const String &state, double prob)
 sets the emission probability of the given state to prob More...
 
void clearTrainingEmissionProbabilities ()
 clear the emission probabilities More...
 
void enableTransition (const String &s1, const String &s2)
 enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1 More...
 
void disableTransition (const String &s1, const String &s2)
 disables the transition; deletes the nodes from the predecessor/successor list respectively More...
 
void disableTransitions ()
 disables all transitions More...
 
void calculateEmissionProbabilities (Map< HMMState *, double > &emission_probs)
 calculates the emission probabilities of the HMM (of course only of the non-hidden states) More...
 
void dump ()
 writes some stats to cerr More...
 
void forwardDump ()
 writes some info of the forward "matrix" to cerr More...
 
void estimateUntrainedTransitions ()
 builds a synonyms structure, needed when synonyms are used More...
 
HMMStategetState (const String &name)
 returns the state with the given name More...
 
const HMMStategetState (const String &name) const
 returns the state with the given name More...
 
void clear ()
 clears all data More...
 
void setPseudoCounts (double pseudo_counts)
 sets the pseudo count that are added instead of zero More...
 
double getPseudoCounts () const
 returns the pseudo counts More...
 
void setVariableModifications (const StringList &modifications)
 
void disableTransition_ (HMMState *s1, HMMState *s2)
 disables the transition; deletes the nodes from the predecessor/successor list respectively More...
 
void enableTransition_ (HMMState *s1, HMMState *s2)
 enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1 More...
 
void setTrainingEmissionProbability_ (HMMState *state, double prob)
 sets the emission probability of the given state to prob More...
 
void setTransitionProbability_ (HMMState *s1, HMMState *s2, double prob)
 sets the transition probability of the given states to prob More...
 
double getTransitionProbability_ (HMMState *s1, HMMState *s2) const
 returns the transition probability of the given states More...
 
void calculateForwardPart_ ()
 performs the forward algorithm More...
 
void calculateBackwardPart_ ()
 performs the backward algorithm More...
 
double getForwardVariable_ (HMMState *)
 returns the forward variable More...
 
double getBackwardVariable_ (HMMState *)
 returns the backward variable More...
 
void copy_ (const HiddenMarkovModel &source)
 

Detailed Description

Hidden Markov Model implementation of PILIS.

Hidden Markov Model implementation suitable for forward connected HMMs. The HMM is mostly used within PILIS. For further details have a look at the docs of PILIS.

Constructor & Destructor Documentation

◆ HiddenMarkovModel() [1/2]

default constructor

◆ HiddenMarkovModel() [2/2]

HiddenMarkovModel ( const HiddenMarkovModel hmm_new)

copy constructor

◆ ~HiddenMarkovModel()

virtual ~HiddenMarkovModel ( )
virtual

destructor

Member Function Documentation

◆ addNewState() [1/2]

void addNewState ( const String name)

registers a new state to the HMM

◆ addNewState() [2/2]

void addNewState ( HMMState state)

registers a new state to the HMM

◆ addSynonymTransition()

void addSynonymTransition ( const String name1,
const String name2,
const String synonym1,
const String synonym2 
)

add a new synonym transition to the given state names

◆ calculateBackwardPart_()

void calculateBackwardPart_ ( )
protected

performs the backward algorithm

◆ calculateEmissionProbabilities()

void calculateEmissionProbabilities ( Map< HMMState *, double > &  emission_probs)

calculates the emission probabilities of the HMM (of course only of the non-hidden states)

◆ calculateForwardPart_()

void calculateForwardPart_ ( )
protected

performs the forward algorithm

◆ clear()

void clear ( )

clears all data

◆ clearInitialTransitionProbabilities()

void clearInitialTransitionProbabilities ( )

clears the initial probabilities

◆ clearTrainingEmissionProbabilities()

void clearTrainingEmissionProbabilities ( )

clear the emission probabilities

◆ copy_()

void copy_ ( const HiddenMarkovModel source)
private

◆ disableTransition()

void disableTransition ( const String s1,
const String s2 
)

disables the transition; deletes the nodes from the predecessor/successor list respectively

◆ disableTransition_()

void disableTransition_ ( HMMState s1,
HMMState s2 
)
protected

disables the transition; deletes the nodes from the predecessor/successor list respectively

◆ disableTransitions()

void disableTransitions ( )

disables all transitions

◆ dump()

void dump ( )

writes some stats to cerr

◆ enableTransition()

void enableTransition ( const String s1,
const String s2 
)

enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1

◆ enableTransition_()

void enableTransition_ ( HMMState s1,
HMMState s2 
)
protected

enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1

◆ estimateUntrainedTransitions()

void estimateUntrainedTransitions ( )

builds a synonyms structure, needed when synonyms are used

estimates the transition probabilities of not trained transitions by averages similar trained ones

◆ evaluate()

void evaluate ( )

evaluate the HMM, estimates the transition probabilities from the training

◆ forwardDump()

void forwardDump ( )

writes some info of the forward "matrix" to cerr

◆ getBackwardVariable_()

double getBackwardVariable_ ( HMMState )
protected

returns the backward variable

◆ getForwardVariable_()

double getForwardVariable_ ( HMMState )
protected

returns the forward variable

◆ getNumberOfStates()

Size getNumberOfStates ( ) const

return the number of states

◆ getPseudoCounts()

double getPseudoCounts ( ) const

returns the pseudo counts

◆ getState() [1/2]

HMMState* getState ( const String name)

returns the state with the given name

◆ getState() [2/2]

const HMMState* getState ( const String name) const

returns the state with the given name

◆ getTransitionProbability()

double getTransitionProbability ( const String s1,
const String s2 
) const

returns the transition probability of the given state names

◆ getTransitionProbability_()

double getTransitionProbability_ ( HMMState s1,
HMMState s2 
) const
protected

returns the transition probability of the given states

◆ operator=()

HiddenMarkovModel& operator= ( const HiddenMarkovModel )

assignment operator

◆ setInitialTransitionProbability()

void setInitialTransitionProbability ( const String state,
double  prob 
)

sets the initial transition probability of the given state to prob

◆ setPseudoCounts()

void setPseudoCounts ( double  pseudo_counts)

sets the pseudo count that are added instead of zero

◆ setTrainingEmissionProbability()

void setTrainingEmissionProbability ( const String state,
double  prob 
)

sets the emission probability of the given state to prob

◆ setTrainingEmissionProbability_()

void setTrainingEmissionProbability_ ( HMMState state,
double  prob 
)
protected

sets the emission probability of the given state to prob

◆ setTransitionProbability()

void setTransitionProbability ( const String s1,
const String s2,
double  prob 
)

sets the transition probability of the given state names to prob

◆ setTransitionProbability_()

void setTransitionProbability_ ( HMMState s1,
HMMState s2,
double  prob 
)
protected

sets the transition probability of the given states to prob

◆ setVariableModifications()

void setVariableModifications ( const StringList modifications)

◆ train()

void train ( )

trains the HMM; initial probabilities and emission probabilities of the emitting states should be set

◆ write()

void write ( std::ostream &  out) const

writes the HMM into an outstream

◆ writeGraphMLFile()

void writeGraphMLFile ( const String filename)

writes the HMM into a file in GraphML format

Accessors A detailed description of the GraphML format can be found under http://graphml.graphdrawing.org/

Member Data Documentation

◆ backward_

Map<HMMState *, double> backward_
private

◆ count_trans_

Map<HMMState *, Map<HMMState *, double> > count_trans_
private

◆ count_trans_all_

Map<HMMState *, Map<HMMState *, std::vector<double> > > count_trans_all_
private

◆ enabled_trans_

Map<HMMState *, std::set<HMMState *> > enabled_trans_
private

◆ forward_

Map<HMMState *, double> forward_
private

◆ init_prob_

Map<HMMState *, double> init_prob_
private

◆ name_to_state_

Map<String, HMMState *> name_to_state_
private

◆ pseudo_counts_

double pseudo_counts_
private

◆ states_

std::set<HMMState *> states_
private

◆ synonym_trans_

Map<HMMState *, Map<HMMState *, std::pair<HMMState *, HMMState *> > > synonym_trans_
private

◆ synonym_trans_names_

Map<String, Map<String, std::pair<String, String> > > synonym_trans_names_
private

◆ train_count_trans_all_

Map<HMMState *, Map<HMMState *, std::vector<double> > > train_count_trans_all_
private

◆ train_emission_prob_

Map<HMMState *, double> train_emission_prob_
private

◆ trained_trans_

std::set<std::pair<HMMState *, HMMState *> > trained_trans_
private

◆ training_steps_count_

Map<HMMState *, Map<HMMState *, Size> > training_steps_count_
private

◆ trans_

Map<HMMState *, Map<HMMState *, double> > trans_
private

◆ var_modifications_

StringList var_modifications_
private