StochHMM
v0.34
Flexible Hidden Markov Model C++ Library and Application
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
externDefinitions.h
Go to the documentation of this file.
1
//
2
// externDefinitions.h
3
//Copyright (c) 2007-2012 Paul C Lott
4
//University of California, Davis
5
//Genome and Biomedical Sciences Facility
6
//UC Davis Genome Center
7
//Ian Korf Lab
8
//Website: www.korflab.ucdavis.edu
9
//Email: lottpaul@gmail.com
10
//
11
//Permission is hereby granted, free of charge, to any person obtaining a copy of
12
//this software and associated documentation files (the "Software"), to deal in
13
//the Software without restriction, including without limitation the rights to
14
//use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15
//the Software, and to permit persons to whom the Software is furnished to do so,
16
//subject to the following conditions:
17
//
18
//The above copyright notice and this permission notice shall be included in all
19
//copies or substantial portions of the Software.
20
//
21
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
23
//FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
24
//COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25
//IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26
//CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28
#ifndef StochHMM_externDefinitions_cpp
29
#define StochHMM_externDefinitions_cpp
30
31
#include <vector>
32
#include <string>
33
#include <iostream>
34
#include <math.h>
35
#include <map>
36
#include <set>
37
#include "
text.h
"
38
#include <stdlib.h>
39
#include "
stateInfo.h
"
40
#include "
sparseArray.h
"
41
42
namespace
StochHMM{
43
44
45
46
class
ExDef;
47
class
weightDef;
48
49
//! \class ExDefSequence
50
//! Contains external definitions for the sequence
51
//! An external definition is how a particular position of the sequence is either
52
//! weighted toward a state or in some cases is absolutely produced by a given state
53
//! Each position can contain an external definition either absolute or
54
//! states weighted by some value;
55
class
ExDefSequence
{
56
public
:
57
//Constructor
58
ExDefSequence
(){};
59
60
//!Creates an ExDefSequence
61
//! \param size amount of ExDef in the sequence
62
ExDefSequence
(
size_t
size):
defs
(size){};
63
64
//Copy Constructor
65
//ExDefSequence(const ExDefSequence&);
66
67
//Destructor
68
//~ExDefSequence();
69
70
//Copy Operator
71
//ExDefSequence& operator=(const ExDefSequence&);
72
73
friend
class
sequences
;
74
75
bool
parse
(std::ifstream&,
stateInfo
&);
76
77
//bool getExDef(std::ifstream&,model*);
78
79
//ACCESSOR
80
bool
defined
(
size_t
);
// Is ExDef defined at position
81
82
bool
isAbsolute
(
size_t
);
// Is ExDef Absolute at position
83
size_t
getAbsState
(
size_t
);
// Absolute State at position
84
85
bool
isWeighted
(
size_t
);
// Is position weighted
86
bool
isWeighted
(
size_t
,
size_t
);
// Is position and state weighted
87
88
double
getWeight
(
size_t
,
size_t
);
// Get Weighted Value for position and state
89
90
void
print
();
// print ExDefSequence to stdout
91
std::string
stringify
();
// Get string representation of ExDefSequence
92
93
private
:
94
sparseArray<ExDef*>
defs
;
95
//std::vector<ExDef*> defs;
96
97
//bool enabled;
98
bool
_parseAbsDef
(
stringList
& ln,
stateInfo
&);
99
bool
_parseWeightDef
(
stringList
& ln,
stateInfo
&);
100
};
101
102
103
//! ExDef defines absolute external definition for model.
104
//! The model must pass through this state
105
class
ExDef
{
106
public
:
107
108
//Constructor
109
ExDef
();
110
111
virtual
~ExDef
(){};
112
113
friend
class
ExDefSequence
;
114
115
inline
size_t
getState
(){
return
weightedState
;};
116
inline
bool
isAbsolute
(){
return
absolute
;};
117
118
inline
void
setState
(
size_t
stIter){
absolute
=
true
;
weightedState
=stIter;};
119
virtual
inline
void
assignWeight
(
size_t
stateIter,
double
val){
weightedState
=stateIter;
absolute
=
true
;};
120
virtual
inline
double
getWeight
(
size_t
stateIter){
if
( stateIter ==
weightedState
){
return
0;}
else
{
return
-INFINITY;}};
121
virtual
std::string
stringify
();
122
123
protected
:
124
bool
absolute
;
//is it absolute
125
//state* st;
126
size_t
weightedState
;
//index iterator to state
127
};
128
129
130
//! weightDef defines weighted external definitions.
131
//! Model weights the states at the position with a value
132
class
weightDef
:
public
ExDef
{
133
public
:
134
weightDef
(
size_t
);
135
136
~weightDef
(){};
137
138
friend
class
ExDefSequence
;
139
140
inline
double
getWeight
(
size_t
stateIter){
141
if
(
weights
.defined(stateIter)){
142
return
weights
[stateIter];
143
}
144
return
0;
145
};
146
147
void
assignWeight
(
size_t
,
double
);
148
std::string
stringify
();
149
private
:
150
sparseArray<double>
weights
;
151
//std::vector<double> weights;
152
};
153
154
}
155
#endif
Generated on Tue Jul 30 2013 13:23:11 for StochHMM by
1.8.1