StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
trainingSeq.h
Go to the documentation of this file.
1 //
2 // trainingSeq.h
3 // StochHMM
4 //
5 // Created by Paul Lott on 3/5/12.
6 // Copyright (c) 2012 University of California, Davis. All rights reserved.
7 //
8 
9 #ifndef StochHMM_trainingSeq_cpp
10 #define StochHMM_trainingSeq_cpp
11 
12 #include <string>
13 #include <iostream>
14 #include <stdint.h>
15 #include <queue>
16 #include <vector>
17 #include <map>
18 #include <fstream>
19 #include <algorithm>
20 #include <stdio.h>
21 #include <set>
22 #include <stdlib.h>
23 #include "text.h"
24 
25 using namespace StochHMM;
26 
27 #define MAX_BUFFER 1000000;
28 #define MIN_BUFFER 100;
29 
30 class stateInfo;
31 class trainingEmission;
32 
34 public:
35  sequence(string&);
36  bool next();
37  void reverseComplement();
38  int operator[](int pos){return seq[pos];};
39  bool importMask();
40  int getMask(int i){return mask[i];};
41  inline size_t size(){return seq.size();};
42  inline string& getDNA(){return DNA;};
43  inline string& getHeader(){return header;};
44  inline vector<int8_t>& getSequence(){return seq;};
45  inline void setMasked(){masked=true;};
46  inline bool isMasked(){return masked;};
47 private:
48  std::string header;
49  queue<int> seq;
50 };
51 
52 
54 public:
55  inline int fileCount(){return seqFiles.size();};
56  inline bool eof(size_t iter){return seqFiles[iter]->eof();}
57  inline bool good(size_t iter){return seqFiles[iter]->good();}
58  inline bool is_open(size_t iter){return seqFiles[iter]->is_open();}
59 
60 
61  inline int queueSize(size_t iter){return seqs.size();}
62  bool openFiles(std::string&);
63  bool openFiles(char**);
64 
65  bool importMask(std::string&);
66  bool importMask(char**);
67 
68  void determineAlphabet(size_t iter);
69  void setAlphabet(size_t, stringList&);
70 
71 private:
72  vector<std::ifstream*> seqFiles;
73  std::ifstream* maskFile;
74 
75  bool masked;
76  queue<int> stateMask;
77 
78  std::vector<std::map<std::string, int> > alphaIndex;
79  std::vector<std::vector<std::string> > indexAlpha;
80 
81  std::vector<stateInfo> stateEmm;
82  std::map<int,map<int,int> > transitions //from state <toState,count>
83 
84  //State definitions of emission/order/joint emission
85 
86  std::vector<trainingSeq> seqs;
87 };
88 
89 class stateInfo{
90 public:
91 
92 private:
93  std::vector<trainingEmission> *emissions;
94 };
95 
97 public:
98 
99 private:
100  std::set<std::pair<int,int> > seqTracks; //Track and order information
101  //if more than one track then it is a joint
102 }
103 
104 
105 
106 #endif