-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBamParser.cpp
71 lines (58 loc) · 1.58 KB
/
BamParser.cpp
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
/*
* parser.cpp
*
* Created on: Apr 17, 2012
* Author: fritz
*/
#include "BamParser.h"
BamParser::BamParser(string file){
vector<string > tmps;
tmps.push_back(file);
if(!reader.Open(tmps)){
cerr<<"BAM Parser: could not open file: "<<file<<endl;
exit(EXIT_FAILURE);
}
}
bool BamParser::setRegion(const int &leftRefID, const int &leftPosition,
const int &rightRefID, const int &rightPosition){
return reader.SetRegion(leftRefID, leftPosition, rightRefID, rightPosition);
}
bool BamParser::Jump (int refID, int position){
return reader.Jump(refID, position);
}
bool BamParser::Rewind() {
return reader.Rewind();
}
Alignment* BamParser::parseRead(uint16_t mappingQv){
Alignment *align = new Alignment();
BamAlignment* al = new BamAlignment();
while(reader.GetNextAlignmentCore(al[0])){
if( al->IsMapped() && al->MapQuality > mappingQv){
al->BuildCharData();
align->setAlignment(al);
return align;
}
}
return align;
}
void BamParser::parseReadFast(uint16_t mappingQv,Alignment*& align){
// Alignment *align = new Alignment();
BamAlignment* al = align->getAlignment();
// getSequence().first
// align->initSequence();
align->getQueryBases().clear();
align->clear_QueryBases();
while(reader.GetNextAlignmentCore(al[0])){
if( al->IsMapped() && al->MapQuality > mappingQv){
al->BuildCharData();
align->setAlignment(al);
return;
}
}
}
RefVector BamParser::get_refInfo(){
return reader.GetReferenceData();
}
string BamParser::get_header(){
return reader.GetHeaderText();
}