Skip to content

Commit 051b2bd

Browse files
committed
Tidy up biggest_del / max_deletion.
Similarly for insertion. These aren't exact duplicates, as it's overall and per-sample, but close enough and the doubling up of work was accidental.
1 parent 2420641 commit 051b2bd

1 file changed

Lines changed: 9 additions & 30 deletions

File tree

bam2bcf_indel.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,10 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
12821282
{
12831283
if (ref == 0 || bca == 0) return -1;
12841284

1285-
int i, s, t, n_types, *types, max_rd_len, left, right, max_ins;
1286-
int *score;
1287-
int N, K, l_run, ref_type, n_alt;
1288-
char *inscns = 0, *ref1, *ref2, *query;
1285+
int i, s, t, n_types, *types = NULL, max_rd_len, left, right, max_ins;
1286+
int *score = NULL;
1287+
int N, K, l_run, ref_type, n_alt = -1;
1288+
char *inscns = NULL, *query = NULL;
12891289

12901290
// determine if there is a gap
12911291
for (s = N = 0; s < n; ++s) {
@@ -1301,7 +1301,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
13011301
types = bcf_cgp_find_types(n, n_plp, plp, pos, bca, ref,
13021302
&max_rd_len, &n_types, &ref_type, &N);
13031303
if (!types)
1304-
return -1;
1304+
goto err;
13051305

13061306

13071307
// calculate left and right boundary
@@ -1366,27 +1366,6 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
13661366
if (ir > bca->indelreg)
13671367
bca->indelreg = ir;
13681368

1369-
// Identify max deletion length.
1370-
// Note these are maximum sizes in the aligned data, rather
1371-
// than the maximum sizes in the types[] array (which are
1372-
// already known in biggest_del and biggest_ins).
1373-
int max_deletion = 0;
1374-
int max_insertion = 0;
1375-
for (s = 0; s < n; ++s) {
1376-
for (i = 0; i < n_plp[s]; ++i, ++K) {
1377-
bam_pileup1_t *p = plp[s] + i;
1378-
if (max_deletion < -p->indel)
1379-
max_deletion = -p->indel;
1380-
if (max_insertion < p->indel)
1381-
max_insertion = p->indel;
1382-
}
1383-
}
1384-
1385-
// // FIXME: does this matter? Try just using
1386-
// // biggest_del/biggest_ins
1387-
// max_insertion = biggest_ins; // 8b
1388-
// max_deletion = -biggest_del;
1389-
13901369
// Realignment score, computed via BAQ
13911370
for (s = K = 0; s < n; ++s) {
13921371
char **tcons;
@@ -1530,7 +1509,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
15301509
// We know an estimation of band, plus biggest indel,
15311510
// so we can trim tbeg/tend to a smaller region if we
15321511
// wish here. This speeds up BAQ scoring.
1533-
int wband = band + MAX(max_deletion, max_insertion)*2 + 20;
1512+
int wband = band + MAX(-biggest_del, biggest_ins)*2 + 20;
15341513
int tend1 = left + tcon_len[0] - (left2-left);
15351514
int tend2 = left + tcon_len[1] - (left2-left);
15361515
tend1 = MIN(tend1, old_tend + wband);
@@ -1548,10 +1527,9 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
15481527
r_start, r_end, long_read,
15491528
tbeg, tend1, tend2,
15501529
left2, left + tcon_len[0],
1551-
qbeg, qend, qpos, max_deletion,
1530+
qbeg, qend, qpos, -biggest_del,
15521531
&score[K*n_types + t]) < 0) {
1553-
score[K*n_types + t] = 0xffffff;
1554-
return -1;
1532+
goto err;
15551533
}
15561534
} else {
15571535
// place holder large cost for reads that cover the
@@ -1567,6 +1545,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos,
15671545
n_alt = bcf_cgp_compute_indelQ(n, n_plp, plp, bca, inscns, l_run, max_ins,
15681546
ref_type, types, n_types, score);
15691547

1548+
err:
15701549
// free
15711550
free(query);
15721551
free(score);

0 commit comments

Comments
 (0)