OpenFlexTyper
ftPropsClass.h
1 #ifndef PROPERTIESCLASS_H
2 #define PROPERTIESCLASS_H
3 
4 #include <climits>
5 #include <set>
6 #include <bitset>
7 #include <iostream>
8 #include <fstream>
9 #include <chrono>
10 #include <map>
11 #include <experimental/filesystem>
12 #include <QSettings>
13 #include <LogClass.h>
14 
15 
16 namespace ft {
17 
18 namespace fs = std::experimental::filesystem;
19 
21 enum Orientation {FWD = 1, REV};
22 
25 typedef std::string SearchType;
26 const std::string CENTERED = "CENTERED";
27 const std::string SLIDING = "SLIDING";
28 
34 enum QueryType {REF = 1, ALT, CRO};
35 const std::string QUERYTYPE_REF = "REF";
36 const std::string QUERYTYPE_ALT = "ALT";
37 const std::string QUERYTYPE_CRO = "CRO";
39 
42 typedef std::pair<int, QueryType> QIdT; // int is the query ID
43 
48 typedef std::pair<int, int> ReadID; // pair (id, pair 1 or pair 2)
49 
52 typedef std::tuple<uint, std::string, std::string, std::string> Query;
53 
56 enum FlagType { ABK = 0x0001, OCK = 0x0002, NUK = 0x0003, MUL = 0x0004};
57 
62 class FTProp
63 {
64 public:
66  FTProp();
67 
69  virtual ~FTProp();
70 
72  struct CmdLineArg {
73  std::string outputFile;
74  std::string iniFile;
75  uint kmerSize;
76  uint stride;
77  uint maxOccurences;
78  bool unique;
79  bool verbose = false;
80  };
81 
114  void init(const fs::path& pathToQueryFile ,
115  uint kmerSize ,
116  uint readLength ,
117  const fs::path& indexPropsFile ,
118  const fs::path& outputFolder ,
119  const fs::path& outputFile ,
120  bool refOnly ,
121  bool revCompSearch ,
122  SearchType searchType ,
123  bool multithread = false ,
124  uint overlap = 0 ,
125  bool returnMatchesOnly = false ,
126  uint stride = 10 ,
127  uint maxOccurences = 200 ,
128  uint numOfThreads = 1 ,
129  bool outputNonUniqueKmers = false ,
130  bool outputOverCountedKmers = false ,
131  bool ignoreNonUniqueKmers = true ,
132  bool ignoreOverCountedKmers = true ,
133  bool countAsPairs = false ,
134  bool crossover = false ,
135  bool uniqueReads = false ,
136  uint maxKmers = UINT_MAX,
137  uint totalKmers = UINT_MAX,
138  bool printInputs = false,
139  bool matchingReads = false);
140 
141  void initFromQSettings(FTProp::CmdLineArg& arg);
143 
144  void setVerbose(bool verbose);
145  void printToStdOut(const std::string outputString) const;
146 
151  void loadIndexProps(const fs::path& _indexPropsFile, bool printInputs);
152  void initIndexProps( const bool pairedReads,
153  const bool revComp,
154  fs::path buildDir,
155  fs::path indexDir,
156  std::string indexFileName,
157  std::string readSetName,
158  fs::path inputFastQ,
159  uint numOfReads,
160  uint numOfIndexes,
161  bool printInputs = false);
163 
164 
166  std::map<fs::path, uint> _indexSet;
167 
172  SearchType getSearchType() const;
173 
174  std::string getReadSetName()const ;
175  std::string getIndexFileName()const ;
176 
177  uint getKmerSize() const;
178  uint getOverlap() const;
179  uint getStride() const;
180  uint getReadLength() const;
181  uint getMaxOcc() const;
182  uint getMaxThreads() const;
183  uint getMaxKmersPerQuery() const;
184  uint getMaxTotalKmers() const;
185  uint getNumOfIndexes() const;
186  uint getNumOfReads() const;
188 
193  const std::bitset<8>& getFlagsToOutput() const;
194  const std::bitset<8>& getFlagsToNotCount() const;
195  bool countFlag(ft::FlagType flag) const;
196  bool outputFlag(ft::FlagType flag) const;
197  void setFlagToOutput(ft::FlagType flag);
198  void setFlagToNotCount(ft::FlagType flag);
199  void resetFlagToOutput(ft::FlagType flag);
200  void resetFlagToNotCount(ft::FlagType flag);
202 
207  bool getMultithreadFlag() const;
208  bool getRefOnlyFlag() const;
209  bool getMatchesOnlyFlag() const;
210  bool getCrossoverFlag() const;
211  bool getPairedReadFlag() const;
212  bool getCountAsPairsFlag() const;
213  bool getRevCompSearchFlag() const;
214  bool getIndexRevCompFlag() const;
215  bool getMatchingReadsFlag() const;
216  bool getUniqueReadsFlag() const;
218  bool isVerbose() const;
219 
224  const fs::path& getPathToQueryFile() const;
225  const fs::path& getIndexDir() const;
226  const fs::path& getOutputFolder() const;
227  const fs::path& getMatchingReadFQ() const;
228  const fs::path& getInputFastQ() const;
229  const fs::path& getOutputFile() const;
230  const std::map<fs::path, uint>& getIndexSet() const;
231  const fs::path& getBuildDir() const;
232  const fs::path& getR1() const;
233  const fs::path& getR2() const;
235 
236  void addToIndexSet(const fs::path& index, u_int offset);
237 
238  void setTestProps(const uint numOfReads, const uint readLength, bool _revComp, bool countAsPairs = false);
239  void setOutputFolder(const fs::path& outputFolder);
240 
241 private:
247  SearchType _searchType;
248  std::string _readSetName;
249  std::string _indexFileName;
250 
251  uint _numOfReads;
252  uint _numOfIndexes;
253 
254  fs::path _pathToQueryFile;
255 
256  fs::path _buildDir;
257  fs::path _indexDir;
258 
259  fs::path _R1;
260  fs::path _R2;
261  fs::path _inputFastQ;
262 
263  fs::path _outputFolder;
264  fs::path _outputFile;
265 
266  uint _kmerSize;
267  uint _overlap;
268  uint _stride;
269  uint _readLength;
270  uint _maxOccurences ;
271  uint _maxThreads;
272  uint _maxKmersPerQuery;
273  uint _maxTotalKmers;
274 
275  std::bitset<8> _flagsToOutput;
276  std::bitset<8> _flagsToNotCount;
277 
279  bool _refOnly;
280  bool _matchesOnly; //?< only output positive hits
281  bool _crossover; //search for crossover counts
287  bool _verbose;
289 
291 };
292 
293 }
294 
295 #endif // PROPERTIESCLASS_H
ft::FTProp::_numOfReads
uint _numOfReads
total individual reads, note: if countAsPairs, then equal to the number of Pairs of reads.
Definition: ftPropsClass.h:251
ft::Query
std::tuple< uint, std::string, std::string, std::string > Query
A tuple of QueryID, Ref string, Alt string, Cro String.
Definition: ftPropsClass.h:52
ft::CENTERED
const std::string CENTERED
search type centered approach
Definition: ftPropsClass.h:26
ft::FTProp::_pairedReads
bool _pairedReads
paired reads
Definition: ftPropsClass.h:282
ft::SearchType
std::string SearchType
SearchType declaration.
Definition: ftPropsClass.h:25
ft::FTProp::_multithread
bool _multithread
run search in parallel
Definition: ftPropsClass.h:278
ft::QIdT
std::pair< int, QueryType > QIdT
Pair to create a unique ID: (Query Number, Query Type)
Definition: ftPropsClass.h:42
ft::SLIDING
const std::string SLIDING
search type sliding approach
Definition: ftPropsClass.h:27
ft
This namespace contains all the functions to interact with the search.
Definition: directSearch.h:16
ft::FTProp::_indexRevComp
bool _indexRevComp
do the index files contain the reverse complement
Definition: ftPropsClass.h:285
ft::FlagType
FlagType
Definition: ftPropsClass.h:56
ft::FTProp::FTProp
FTProp()
Constructor.
Definition: ftPropsClass.cpp:12
ft::FTProp
A class that contains all the properties for a FlexTyper instance.
Definition: ftPropsClass.h:63
ft::FTProp::_matchingReads
bool _matchingReads
create files that contain reads that match to each query
Definition: ftPropsClass.h:286
ft::ReadID
std::pair< int, int > ReadID
Pair to create a unique Read ID: (Read Number, Read Pair)
Definition: ftPropsClass.h:48
ft::QueryType
QueryType
Definition: ftPropsClass.h:34
ft::FTProp::_revCompSearch
bool _revCompSearch
generate and search for _qkRCMap
Definition: ftPropsClass.h:284
ft::FTProp::_indexSet
std::map< fs::path, uint > _indexSet
Malliable map containing the paths of indexes to be processed.
Definition: ftPropsClass.h:166
ft::FTProp::~FTProp
virtual ~FTProp()
Destructor.
Definition: ftPropsClass.cpp:464
ft::FTProp::_refOnly
bool _refOnly
single sequence for each query
Definition: ftPropsClass.h:279
ft::FTProp::_uniqueReads
bool _uniqueReads
Enforce a unique match between Reads and Queries (i.e. no multi-hits)
Definition: ftPropsClass.h:288
ft::FTProp::_verbose
bool _verbose
print to std::cout
Definition: ftPropsClass.h:287
ft::FTProp::_countAsPairs
bool _countAsPairs
only count one hit per read pair
Definition: ftPropsClass.h:283