-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathReference.h
74 lines (58 loc) · 1.49 KB
/
Reference.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
#ifndef Reference_H
#define Reference_H
#include <map>
#include <string>
#include <vector>
#include <unordered_map>
#include <stdio.h>
#include <string.h>
#include "Common.h"
#include "FileIO.h"
#include "Fields/SAMComment.h"
class Stats;
class Reference {
friend class Stats;
public:
struct Chromosome {
std::string chr;
std::string md5;
std::string filename;
size_t len;
size_t loc;
};
private:
shared_ptr<File> input;
std::string directory, filename;
std::string currentChr;
std::unordered_map<std::string, Chromosome>
chromosomes;
std::string currentWebFile;
private:
std::string buffer;
size_t bufferStart, bufferEnd, currentPos;
char c;
public:
Reference (const std::string &filename);
~Reference (void);
public:
std::string getChromosomeName(void) const;
std::string scanChromosome(const std::string &s, const SAMComment &samComment);
//void load(char *arr, size_t s, size_t e);
size_t getChromosomeLength(const std::string &s) const;
Chromosome getChromosomeInfo (const std::string &chr) {
return chromosomes[chr];
}
void loadIntoBuffer(size_t end);
char operator[](size_t pos) const;
std::string copy(size_t start, size_t end);
void trim(size_t from);
size_t currentMemoryUsage() {
size_t sz =
sizeInMemory(directory) + sizeInMemory(filename) + sizeInMemory(currentWebFile) +
sizeInMemory(currentChr) + sizeof(size_t) * 3 + sizeInMemory(buffer);
return sz; // Ignore chromosome size
}
private:
void loadFromFASTA (const std::string &fn);
};
#endif