OpenFlexTyper
directSearch.h
1 #ifndef DIRECTSEARCH_H
2 #define DIRECTSEARCH_H
3 #include <climits>
4 #include <set>
5 #include <bitset>
6 #include <iostream>
7 #include <fstream>
8 #include <chrono>
9 #include <map>
10 #include <experimental/filesystem>
11 #include <QSettings>
12 
13 #include <fmindex.h>
14 
15 
16 namespace ft {
17 namespace fs = std::experimental::filesystem;
19 struct KSCmdLineArg {
20  fs::path kmerFile;
21  std::map<fs::path, uint> indexFiles;
22 
23  std::string indexSetName;
24  std::string kmerSetName;
25  std::string outputFileName;
26  uint numOfReads;
27  uint columnNum = 0;
28  uint maxOccurences = 100000;
29  uint maxThreads = 1;
30  uint readLength = 100;
31  bool pairedReads = false;
32  bool indexRevComp = false;
33  bool countAsPairs = false;
34  bool revCompSearch = false;
35  bool iniFile = false;
36  bool verbose = false;
37 };
38 
39 
44 class KSearch
45 {
46 public:
48  KSearch();
49 
51  virtual ~KSearch();
52 
53  void init(const KSCmdLineArg& KSProps);
54 
55  void loadKmers(const fs::path& kmerFile);
56  void addResultsFutures(std::map<std::string, ft::KmerClass> & indexResults, ft::KmerClass &tmpResult, uint offset);
57  void parallelSearch(const fs::path &indexPath, long long offset);
58  void processIndexResults(const std::map<std::string, ft::KmerClass>& indexResult);
59  void processResults();
60  void writeOutput();
61 
66  bool checkForKmer(const std::string& testKmer) const;
67 
68  const ft::KmerClass& getKmer(const std::string& kmer) const;
69  void addKmer(const std::string &kmer);
70 
71  void addKmerResults(const ft::KmerClass& kmerResult);
72  int calculateKmerCount(const KmerClass& kmer);
76 
77 
78  private:
79  fs::path _outputFile;
80 
81  fs::path _kmerFile;
82 
83  uint _numOfReads;
84  uint _readLength;
85  uint _maxOcc;
86  uint _maxThreads;
87  uint _columnNum;
88  bool _verbose;
89  bool _pairedReads;
90  bool _indexRevComp;
91  bool _countAsPairs;
92  bool _revCompSearch;
93  std::map<fs::path, uint> _indexSet;
94  std::unordered_map<std::string, ft::KmerClass> _kmerSet;
95  std::vector<std::map<std::string, ft::KmerClass>> _searchResults;
96 
97  void createKmer(const std::string& kmer);
98  ft::KmerClass* findKmer(const std::string& kmer);
99 
100 
101 
102 };
103 
104 }
105 #endif // DIRECTSEARCH_H
ft::KmerClass
A class that contains information for a single Kmer.
Definition: kmerClass.h:17
ft::KSearch::KSearch
KSearch()
Constructor.
Definition: directSearch.cpp:11
ft
This namespace contains all the functions to interact with the search.
Definition: directSearch.h:16
ft::KSearch
A class that contains all the properties to directly count kmers.
Definition: directSearch.h:45
ft::KSearch::~KSearch
virtual ~KSearch()
Destructor.
Definition: directSearch.cpp:343