StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
externalFuncs.h
Go to the documentation of this file.
1 //
2 // externalFuncs.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_externalFuncs_cpp
29 #define StochHMM_externalFuncs_cpp
30 
31 #include <iostream>
32 #include <map>
33 #include <string>
34 #include <vector>
35 #include "weight.h"
36 #include "userFunctions.h"
37 #include "stochTypes.h"
38 #include "track.h"
39 #include "text.h"
40 #include "sequences.h"
41 #include <stdlib.h>
42 
43 namespace StochHMM{
44 
45  /*! \file externalFuncs.h
46  \brief Define additional function information for call to user function when calculating the emission or transition value
47  At a state the function may be called and passed information. The function may need traceback data or other sequence data. Such options are defined by the externalFuncs class
48 
49  User-provided weight can be passed to externalFuncs to weight the score when passing to
50  emission or transition
51 
52  Functions must be defined before model import, then will be passed to the externaFuncs class, when created.
53 
54  Defined in the model definition files
55 
56  \sa userFunctions.h and userFunctions.cpp
57  */
58 
59 
60 
62  public:
63  //MUTATORS
65 
66  //transitionFuncParam(stringList&, tracks&, weights*, StateFuncs*);
68 
69 
70 
71  //External Function
72  void setTransFunc(std::string&, transitionFunc*, weight*);
73  void setTransTB(tracebackIdentifier, std::string&, combineIdentifier, std::string&);
74 
75  //ACCESSORS
76 
77  //!Check to see if a traceback is defined as necessary
78  //! \return true if a traceback is necessary
79  //! \return false if a traceback is not required
80  inline bool isTracebackDefined(){return transFuncTraceback;};
81 
82  //!Returns what how extensive of a a traceback is required
83  //! \return tracbackIdentifier Type of traceback required
84  //! \sa enum tracebackIdentifier
86 
87  //!Return where the traceback is to go back to before stopping
88  //! \return std::string State/Label/GFF tag to traceback to
89  inline std::string& getTracebackName(){return transFuncTracebackString;};
90 
91  //!Return what is suppose to be combined (State/Label/GFF)
92  //! \return std::string
93  inline std::string& getCombineName(){return transFuncCombineString;};
94 
95  //!Get the Combine type to apply to the traceback
96  //!How the traceback is to be combined (editing of traceback)
97  //! \return combineIdentifier
98  //! \sa enum combineIdentifier
100 
101  //!Get track name to pass to the function (as defined in the model)
102  //! \return std::string Track Name as defined in the model to be passed to the function
103  inline std::string& getTrackName(){return trackName;};
104 
105  inline track* getTrack(){return transFuncTrack;};
106 
107  double evaluate(const std::string*,size_t, const std::string*, size_t);
108 
109  void print(); //! prints the string representation of the externFuncs to stdout
110  std::string stringify(); //! Return string representation of the externFuncs definition in the model
111 
112  private:
114  std::string trackName; //! What track to pass to the function
115  track* transFuncTrack; //! Pointer to track function uses
116 
117  std::string transFuncName; //! < Name of the external function as used in the model
118 
119  weight* transFuncScaling; //! < weighting information for values
120 
121  //Traceback Information
122  bool transFuncTraceback; //! defines whether a traceback in necessary for the function
123 
124  tracebackIdentifier transFuncTracebackIdentifier; //!< What to traceback until
125  std::string transFuncTracebackString; //! Contains name of traceback
126 
127  combineIdentifier transFuncCombineIdentifier; //! < Contains information on how to combine the traceback information
128  std::string transFuncCombineString; //! Contains what name of what to combine
129 
130  };
131 
132 
133 
134 
136  public:
137  //MUTATORS
138 
139  emissionFuncParam(std::string&, StateFuncs*,track*);
141 
143 
144 
145 
146  //External Function
147  void setEmissionFunc(std::string&, emissionFunc*, weight*);
148 
149  //ACCESSORS
150 
151  //!Get track name to pass to the function (as defined in the model)
152  //! \return std::string Track Name as defined in the model to be passed to the function
153  inline std::string& getTrackName(){return trackName;};
154 
155  inline std::string& getName(){return emissionFuncName;}
156 
157  inline track* getTrack(){return emissionFuncTrack;};
158 
159  double evaluate(const std::string*,size_t);
160  double evaluate(sequences&, size_t);
161  double evaluate(sequence&, size_t);
162 
163  void print(); //! prints the string representation of the externFuncs to stdout
164  std::string stringify(); //! Return string representation of the externFuncs definition in the model
165 
166  private:
168  std::string trackName; //! What track to pass to the function
169  size_t trackNumber;
170  track* emissionFuncTrack; //! Pointer to track function uses
171 
172  std::string emissionFuncName; //! < Name of the external function as used in the model
173 
174  weight* emissionFuncScaling; //! < weighting information for values
175 
176  };
177 
178 
179 
180 }
181 #endif