StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
modelTemplate.h
Go to the documentation of this file.
1 //
2 // stateTemplate.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_stateTemplate_cpp
29 #define StochHMM_stateTemplate_cpp
30 
31 
32 #include <vector>
33 #include <string>
34 #include <iostream>
35 #include <map>
36 #include <algorithm>
37 #include <set>
38 #include "text.h"
39 #include <stdlib.h>
40 namespace StochHMM{
41 
42  //!class stencil: contains individial model template and keeps track of coordinates for replacement
43  class stencil{
44  public:
45  stencil();
46  stencil(std::string&); //! Construct stencil from string
47 
48  //MUTATORS
49  bool parse(std::string&);
50 
51  //ACCESSOR
52  std::string getTemplate(std::string&, std::string&, std::map<std::string,std::string>&); //!Returns the template with all user and identifiers filled out
53  std::string CheckParameter(std::string&);
54 
55  inline void print(){std::cout << stringify() <<std::endl;};//!Prints template string
56  inline std::string stringify(){return states;}; //!Returns template string
57 
58  private:
59  std::string states; //!Template string
60  std::set<std::string> UserParameterKeys; //!All UserDefinedVariables in Model Template
61  };
62 
63 
64  //!class templates: contains a map of all templates
65  /*!class templates: contains a map of all templates, each should have a different identifier. */
66  class templates{
67  public:
68  templates();
69  templates(std::string&); //!Create templates from file
70  ~templates();
71 
72  //MUTATOR
73  bool parse(std::string&); //!hand it a string with multiple stencles and have it parse out each one to be added to the templates
74 
75  void addTemplate(std::string&);
76 
77  //ACCESSOR
78  inline void print(){std::cout << stringify() <<std::endl;};
79  std::string& stringify();
80 
81 
82  //!returns string representation of states with all parameters filled out
83  std::string getTemplate(std::string&, std::string&, std::map<std::string,std::string>&);
84  //std::string returnAllFilledTemplates(std::string&,std::map<std::string,std::string>& UserVals);
85  //!returns all filled out templates for ID give
86 
87  private:
88  std::map<std::string,stencil*> temps; //!Map of all stencils
89  };
90 }
91 #endif