Skip to content

Commit 2e15066

Browse files
y3tsengy3tseng
authored andcommitted
add penalties to ends
1 parent 8cfcba0 commit 2e15066

File tree

10 files changed

+206
-1838
lines changed

10 files changed

+206
-1838
lines changed

src/TALCO-XDrop.cpp

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ void Talco_xdrop::Align_freq (
6868
for (int i= tile_aln.size()-1; i>=0; i--){
6969
if (i == tile_aln.size()-1 && tile>0) continue;
7070
aln.push_back(tile_aln[i]);
71-
// if (num.first == 19 && num.second == 1) std::cout << (tile_aln[i] & 0xFFFF);
7271
}
73-
// if (num.first == 19 && num.second == 1) std::cout << '\n';
7472
tile_aln.clear();
7573
tile++;
7674
}
@@ -185,8 +183,6 @@ void Talco_xdrop::Traceback(
185183
query_idx--;
186184
}
187185
}
188-
189-
190186
}
191187

192188
void Talco_xdrop::Tile (
@@ -231,10 +227,7 @@ void Talco_xdrop::Tile (
231227

232228
float denominator = refNum * qryNum;
233229

234-
float p_gapHead = (param.type % 2 == 0) ? param.gapBoundary : 0;
235-
float p_gapTail = (param.type == 0 || param.type == 3) ? param.gapBoundary : 0;
236-
237-
230+
238231
int32_t L[3], U[3];
239232
int32_t *S[3], *I[2], *D[2];
240233
int32_t *CS[3], *CI[2], *CD[2];
@@ -291,7 +284,7 @@ void Talco_xdrop::Tile (
291284
return;
292285
}
293286
for (int32_t k = 0; k < reference_length + query_length - 1; k++){
294-
// if (num.first == 9777) printf("Tile: %d, k: %d, L: %d, U: %d, (%d, %d)\n", tile, k, L[k%3], U[k%3]+1, reference_length, query_length);
287+
// printf("Tile: %d, k: %d, L: %d, U: %d, (%d, %d)\n", tile, k, L[k%3], U[k%3]+1, reference_length, query_length);
295288
if (L[k%3] >= U[k%3]+1) { // No more cells to compute based on x-drop critieria
296289
last_tile = true;
297290
errorType = 1;
@@ -347,22 +340,6 @@ void Talco_xdrop::Tile (
347340
int32_t offsetDiag = L[k%3]-L[(k+1)%3]+offset-1; // L[0] - L[1] + 0 - 1
348341
int32_t offsetUp = L[k%3]-L[(k+2)%3]+offset;
349342
int32_t offsetLeft = L[k%3]-L[(k+2)%3]+offset-1;
350-
// if (tile == 0) {
351-
// delOp = (j == reference_idx) ? -inf : param.gapOpen;
352-
// insOp = (i == query_idx) ? -inf : param.gapOpen;
353-
// delExt = (j == reference_idx) ? -inf : param.gapOpen + param.gapExtend*(j-reference_idx);
354-
// insExt = (i == query_idx) ? -inf : param.gapOpen + param.gapExtend*(i-query_idx);
355-
// }
356-
// if (tile == 0) {
357-
// if (query_idx == 0 && i == 0) {
358-
// if (j == 0) delOp = 0;
359-
// else delExt = param.gapExtend * j;
360-
// }
361-
// if (reference_idx == 0 && j == 0) {
362-
// if (i == 0) insOp = 0;
363-
// else insExt = param.gapOpen * i;
364-
// }
365-
// }
366343

367344

368345
if ((k==0) ||
@@ -379,44 +356,34 @@ void Talco_xdrop::Tile (
379356
}
380357

381358
similarScore = static_cast<int32_t>(roundeven(numerator/denominator));
382-
if (tile == 0 && (i == 0 || j == 0 )) match = similarScore + p_gapHead * std::max(reference_idx + j, query_idx + i);
359+
if (tile == 0 && (i == 0 || j == 0 )) match = similarScore + param.gapBoundary * std::max(reference_idx + j, query_idx + i);
383360
else if (offsetDiag < 0) match = similarScore;
384361
else match = S[(k+1)%3][offsetDiag] + similarScore;
385362
}
386363

387-
int32_t pos_gapOpen_ref = static_cast<int32_t>(roundeven(gapOp[0][reference_idx+j]));
388-
int32_t pos_gapOpen_qry = static_cast<int32_t>(roundeven(gapOp[1][query_idx+i]));
389-
int32_t pos_gapExtend_ref = static_cast<int32_t>(roundeven(gapEx[0][reference_idx+j]));
390-
int32_t pos_gapExtend_qry = static_cast<int32_t>(roundeven(gapEx[1][query_idx+i]));
391-
364+
int32_t pos_gapOpen_ref = static_cast<int32_t>(std::nearbyint(gapOp[0][reference_idx+j]));
365+
int32_t pos_gapOpen_qry = static_cast<int32_t>(std::nearbyint(gapOp[1][query_idx+i]));
366+
int32_t pos_gapExtend_ref = static_cast<int32_t>(std::nearbyint(gapEx[0][reference_idx+j]));
367+
int32_t pos_gapExtend_qry = static_cast<int32_t>(std::nearbyint(gapEx[1][query_idx+i]));
392368

393369
if (query_idx + i == query.size() - 1) {
394-
pos_gapOpen_ref = p_gapTail;
395-
pos_gapExtend_ref = p_gapTail;
370+
pos_gapOpen_ref = param.gapBoundary;
371+
pos_gapExtend_ref = param.gapBoundary;
396372
}
397373
if (reference_idx + j == reference.size() - 1) {
398-
pos_gapOpen_qry = p_gapTail;
399-
pos_gapExtend_qry = p_gapTail;
374+
pos_gapOpen_qry = param.gapBoundary;
375+
pos_gapExtend_qry = param.gapBoundary;
400376
}
401377

402378
if ((offsetUp >= 0) && (offsetUp <= U[(k+2)%3]-L[(k+2)%3])) {
403-
// delOp = S[(k+2)%3][offsetUp] + gapOpen;
404379
delOp = S[(k+2)%3][offsetUp] + pos_gapOpen_ref;
405-
// delExt = D[(k+1)%2][offsetUp] + gapExtend;
406380
delExt = D[(k+1)%2][offsetUp] + pos_gapExtend_ref;
407381
}
408382

409383
if ((offsetLeft >= 0) && (offsetLeft <= U[(k+2)%3]-L[(k+2)%3])) {
410-
// insOp = S[(k+2)%3][offsetLeft] + gapOpen;
411384
insOp = S[(k+2)%3][offsetLeft] + pos_gapOpen_qry;
412-
// insExt = I[(k+1)%2][offsetLeft] + gapExtend;
413385
insExt = I[(k+1)%2][offsetLeft] + pos_gapExtend_qry;
414386
}
415-
// if (tile == 0 && num.first == 9777) std::cout << reference_length << ':' << query_length << '\n';
416-
// if (tile == 0 && num.first == 9777) {
417-
// printf("%d: (%d, %d), %d/%d, %d/%d, %d\n",k, i, j, delOp, delExt, insOp, insExt, match);
418-
// // printf("%d, %d, %d, %d, %d\n", offset, offsetUp, offsetLeft, offsetDiag, (U[(k+1)%3]-L[(k+1)%3]));
419-
// }
420387

421388
I[k%2][offset] = insOp;
422389
D[k%2][offset] = delOp;
@@ -455,10 +422,6 @@ void Talco_xdrop::Tile (
455422
if (S[k%3][offset] < max_score-param.xdrop) {
456423
S[k%3][offset] = -inf;
457424
}
458-
459-
// if (tile == 0 && num.first == 9777) {
460-
// printf("%d,%d,%d -> %d\n", S[k%3][offset], D[k%2][offset], I[k%2][offset], (ptr&0xFFFF));
461-
// }
462425

463426
score = S[k%3][offset];
464427

@@ -590,7 +553,6 @@ void Talco_xdrop::Tile (
590553
tb_start_ftr = (tb_state == 3) ? ftr_length.size() - 2: ftr_length.size() - 1;
591554
}
592555
}
593-
// if (num.first == 977) printf("%d, %d, %d, %d, %d\n", tile, conv_logic, tb_state, conv_ref_idx, conv_query_idx);
594556

595557
reference_idx += conv_ref_idx;
596558
query_idx += conv_query_idx;
@@ -599,7 +561,6 @@ void Talco_xdrop::Tile (
599561
query_length = query.size() - query_idx;
600562
if ((reference_length < 0) || (query_length < 0)) {
601563
fprintf(stderr, "ERROR: Reference/Query index exceeded limit!\n");
602-
printf("%d, %d, %d, %d, %d\n", tile, conv_logic, tb_state, conv_ref_idx, conv_query_idx);
603564
errorType = 3;
604565
aln.clear();
605566
for (size_t sIndx=0; sIndx<3; sIndx++) {

src/TALCO-XDrop.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ namespace Talco_xdrop {
6161
this->gapOpen = t_param[25];
6262
this->gapExtend = t_param[26];
6363
this->gapBoundary = t_param[27];
64-
this->xdrop = static_cast<int32_t> (1500 * -1 * t_param[26]);
64+
this->xdrop = static_cast<int32_t> (1000 * -1 * t_param[26]);
6565
this->fLen = (1 << 12);
6666
this->marker = (1 << 10); //reduce this value to save memory
6767
}
68-
69-
void setType(int t) {this->type = t;}
7068
};
7169

7270
void Align_freq (

0 commit comments

Comments
 (0)