MCPcopy Create free account
hub / github.com/Boyle-Lab/Blacklist / SequenceData

Class SequenceData

blacklist.cpp:24–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24class SequenceData {
25 public:
26 std::vector<int> binsInput;
27 std::vector<int> binsSpikes;
28 std::vector<int> binsMultimapping;
29 std::vector<int> binsTemp;
30 int totalReads;
31 int zeroMulti = 0;
32
33 SequenceData(std::string bamFile, std::string bamIndexFile) {
34 this->bamFile = bamFile;
35 this->bamIndexFile = bamIndexFile;
36 }
37
38 SequenceData() {
39 }
40
41 void setBamFile(std::string bamFile) {
42 this->bamFile = bamFile;
43 }
44
45 std::string getBamFile() {
46 return bamFile;
47 }
48
49 void setBamIndexFile(std::string bamIndexFile) {
50 this->bamIndexFile = bamIndexFile;
51 }
52
53 void getInputBins(std::vector<uint8_t>& mappability, int binSize, int binOverlap, std::string refName)
54 {
55 this->binsInput.clear();
56 this->binsSpikes.clear();
57 this->binsMultimapping.clear();
58 this->binsTemp.clear();
59
60 BamTools::BamReader reader;
61 BamTools::BamAlignment al;
62 std::vector<int> tempCounts (mappability.size(), 0);
63 std::vector<int> multiCounts (mappability.size(), 0);
64 totalReads = 0;
65 int testCntr = 0;
66 int zmultiCntr = 0;
67
68 reader.Open(this->bamFile);
69 reader.OpenIndex(this->bamIndexFile); // Significant speedup here
70
71 // This restricts output to a specific chromosome
72 if(reader.GetReferenceID(refName) == -1) {
73 //cout << "No Reads to load!\n"; //DEBUG
74 } else {
75 reader.SetRegion(reader.GetReferenceID(refName), 0, reader.GetReferenceID(refName), mappability.size());
76
77 // Keep vector of locations and counts of reads
78 // filter on mappability based on each read length
79 while(reader.GetNextAlignmentCore(al)) {
80 if(mappability[al.Position] > 0 && mappability[al.Position] <= al.Length) { // Filter mappability
81 tempCounts[al.Position] = tempCounts[al.Position] + 1; // Count reads at each position that are uniquely mappable

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected