forked from BioinformaticsArchive/blasr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KBandMatcher.cpp
122 lines (103 loc) · 3.28 KB
/
KBandMatcher.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <assert.h>
#include <string>
#include <iostream>
#include <vector>
#include "../common/FASTAReader.h"
#include "../common/FASTASequence.h"
#include "../common/algorithms/alignment.h"
#include "../common/algorithms/alignment/AffineKBandAlign.h"
#include "../common/algorithms/alignment/DistanceMatrixScoreFunction.h"
#include "../common/datastructures/alignment/AlignmentCandidate.h"
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 3) {
cout << "usage: sdpMatcher query target [-k k] [-ins i] [-del d]" << endl;
exit(1);
}
string queryName, targetName;
queryName = argv[1];
targetName = argv[2];
int argi = 3;
int k;
int ins = 3;
int del = 3;
bool targetfixed = false;
while (argi < argc ) {
if (strcmp(argv[argi], "-k") == 0) {
k = atoi(argv[++argi]);
}
else if (strcmp(argv[argi], "-del") == 0) {
del = atoi(argv[++argi]);
}
else if (strcmp(argv[argi], "-ins") == 0) {
ins = atoi(argv[++argi]);
}
else if (strcmp(argv[argi], "-targetfixed") == 0) {
targetfixed = true;
}
else {
cout << "ERROR: bad option: " << argv[argi] << endl;
exit(1);
}
++argi;
}
FASTASequence query, target;
FASTAReader queryReader, targetReader;
queryReader.Init(queryName);
targetReader.Init(targetName);
//
// Prepare the target database;
//
//
// Prepare the query match set.
//
int seqIndex = 0;
int numNoFragments = 0;
vector<int> scoreMat;
vector<Arrow> pathMat;
int alignScore;
int computedAlignScore;
DistanceMatrixScoreFunction<FASTASequence, FASTASequence> scoreFn;
scoreFn.InitializeScoreMatrix(SMRTDistanceMatrix);
if (targetfixed) {
targetReader.GetNext(target);
}
while (queryReader.GetNext(query) and (targetfixed or targetReader.GetNext(target))) {
cout << "got " << query.title << endl;
AlignmentCandidate<FASTASequence, FASTASequence> alignment, aalignment;
alignment.blocks.clear();
alignment.qPos = 0;
alignment.tPos = 0;
if (query.length == 0 or target.length == 0)
continue;
vector<int> kscoremat, ascoremat;
vector<Arrow> kpathmat, apathmat;
vector<int> hpInsScoreMat, insScoreMat;
vector<Arrow> hpInsPathMat, insPathMat;
alignScore = AffineKBandAlign(query, target, SMRTDistanceMatrix,
ins, ins - 2, // homopolymer affine penalty
ins, ins - 1, // regular affine
del, k,
ascoremat, apathmat,
hpInsScoreMat, hpInsPathMat,
insScoreMat, insPathMat,
aalignment, Local);
cout << "done aligning " << endl;
// cout << query.length << " " << target.length << " " << alignScore << endl;
/*
ComputeAlignmentStats(alignment, query.seq, target.seq, SMRTDistanceMatrix, ins, del);
PrintAlignmentStats(alignment, cout);
cout << "affine version: " << endl;
*/
aalignment.qPos = 0;
aalignment.tPos = 0;
// ComputeAlignmentStats(aalignment, query.seq, target.seq, SMRTDistanceMatrix, ins, del);
PrintCompareSequencesAlignment(aalignment, query.seq, target.seq, cout, false);
PrintAlignmentStats(aalignment, cout);
/* StickPrintAlignment(aalignment, query, target, cout);
assert(aalignment.blocks[aalignment.blocks.size()-1].qPos +
aalignment.blocks[aalignment.blocks.size()-1].length <= query.length);*/
++seqIndex;
}
return 0;
}