-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathNewGenomeFile.h
More file actions
69 lines (48 loc) · 2.18 KB
/
NewGenomeFile.h
File metadata and controls
69 lines (48 loc) · 2.18 KB
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
/*****************************************************************************
NewGenomeFile.h
(c) 2009 - Aaron Quinlan
Hall Laboratory
Department of Biochemistry and Molecular Genetics
University of Virginia
aaronquinlan@gmail.com
Licensed under the GNU General Public License 2.0 license.
******************************************************************************/
#ifndef NEW_GENOMEFILE_H
#define NEW_GENOMEFILE_H
#include <algorithm> // for bsearch lower_bound()
#include <stdint.h>
#include "BedtoolsTypes.h"
#include "api/BamReader.h"
#include "api/BamAux.h"
class NewGenomeFile {
public:
NewGenomeFile(const string &genomeFileName);
NewGenomeFile(const BamTools::RefVector &genome);
~NewGenomeFile(void);
// load a GENOME file into a map keyed by chrom. value is a pair<int, int> of id and size.
void loadGenomeFileIntoMap();
bool projectOnGenome(CHRPOS genome_pos, string &chrom, CHRPOS &start);
CHRPOS getGenomeSize(void) const { return _genomeLength; } // return the total size of the genome
CHRPOS getChromSize(const string &chrom); // return the size of a chromosome
CHRPOS getChromSize(const string &chrom) const; // return the size of a chromosome
uint32_t getChromId(const string &chrom); // return chromosome's sort order
const vector<string> &getChromList() const { return _chromList; } // return a list of chrom names
uint32_t getNumberOfChroms() const { return (uint32_t)(_chromList.size() -1); }//the -1 excludes the blank chrom added for unmapped reads
const string &getGenomeFileName() const { return _genomeFileName; }
bool hasChrom(const string &chrom) const { return _chromSizeIds.find(chrom) != _chromSizeIds.end(); }
private:
string _genomeFileName;
istream *_genomeFile;
typedef map<string, pair<CHRPOS, int> > lookupType;
lookupType _chromSizeIds;
vector<string> _chromList;
int _maxId;
// projecting chroms onto a single coordinate system
CHRPOS _genomeLength;
vector<CHRPOS> _startOffsets;
//cache members for quick lookup
string _currChromName;
CHRPOS _currChromSize;
int _currChromId;
};
#endif /* GENOMEFILE_H */