-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgenomes.h
80 lines (70 loc) · 1.7 KB
/
genomes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef GENOMES_H
#define GENOMES_H
// includes
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include "common.h"
#include "fastareader.h"
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include "options.h"
using namespace std;
class MapResult{
public:
MapResult(){
mapped = false;
start = 0;
len = 0;
ed = 0x7FFFFFFF; // initialized with a very large ED
}
public:
bool mapped;
uint32 start;
uint32 len;
uint32 ed; // edit distance
};
#pragma pack(2)
// if contig is -1, means this is a dupe entry, and position will be the position in the dupList
struct ContigPos{
ContigPos(uint16 ctg, uint32 pos) {
contig = ctg;
position = pos;
}
uint16 contig;
uint32 position;
};
#pragma pack()
class Genomes
{
public:
Genomes(string fastaFile, Options* opt);
~Genomes();
void run();
void output();
private:
void buildKmerTable(bool reversed);
void addKmer(uint64 key, int id, bool reversed);
void makeUniqueKMER();
string outputKmer(int id, string& path, string& filename, int& count);
void outputGenome(int id, string& path, string& filename);
string alignToDigits(int val, int digits);
void filterReferenceGenome();
private:
int mGenomeNum;
FastaReader* mFastaReader;
vector<string> mSequences;
vector<string> mNames;
vector<set<string>> mUniqueKmers;
vector<vector<uint64>> mUniqueKeys;
vector<vector<uint64>> mFilteredUniqueKeys;
// KMER: value
// If value is negative, means more than one contig hit this KMER
unordered_map<uint64, int> mKmerTable;
Options* mOptions;
};
#endif