Prevent Clang warnings on abs() and fabs() calls
In the bwa.c and bwase.c calls, rlen is an int64_t returned from bns_get_seq() and is the number of reference bases covered by the alignment; l_query/len is an int and the query length of the alignment; and the result is an int given to an int parameter of ksw_global[2](). As even the result is int and as rlen is effectively bounded by the maximum length of a reference sequence, we maintain the status quo in this code and simply cast rlen to int to silence Clang's "use llabs()" (llabs() would not be a great answer given an int64_t anyway). The bwtsw2_pair.c call needs to remain fabs() so both divisions are done in floating point; cast to double to prevent Clang suggesting changing the call to integer abs().
This commit is contained in:
parent
6a5caf764f
commit
ab3a92bc73
4
bwa.c
4
bwa.c
|
|
@ -144,9 +144,9 @@ uint32_t *bwa_gen_cigar2(const int8_t mat[25], int o_del, int e_del, int o_ins,
|
|||
max_del = (int)((double)(((l_query+1)>>1) * mat[0] - o_del) / e_del + 1.);
|
||||
max_gap = max_ins > max_del? max_ins : max_del;
|
||||
max_gap = max_gap > 1? max_gap : 1;
|
||||
w = (max_gap + abs(rlen - l_query) + 1) >> 1;
|
||||
w = (max_gap + abs((int)rlen - l_query) + 1) >> 1;
|
||||
w = w < w_? w : w_;
|
||||
min_w = abs(rlen - l_query) + 3;
|
||||
min_w = abs((int)rlen - l_query) + 3;
|
||||
w = w > min_w? w : min_w;
|
||||
// NW alignment
|
||||
if (bwa_verbose >= 4) {
|
||||
|
|
|
|||
4
bwase.c
4
bwase.c
|
|
@ -173,13 +173,15 @@ bwa_cigar_t *bwa_refine_gapped_core(bwtint_t l_pac, const ubyte_t *pacseq, int l
|
|||
ubyte_t *rseq;
|
||||
int64_t k, rb, re, rlen;
|
||||
int8_t mat[25];
|
||||
int w;
|
||||
|
||||
bwa_fill_scmat(1, 3, mat);
|
||||
rb = *_rb; re = rb + len + ref_shift;
|
||||
assert(re <= l_pac);
|
||||
rseq = bns_get_seq(l_pac, pacseq, rb, re, &rlen);
|
||||
assert(re - rb == rlen);
|
||||
ksw_global(len, seq, rlen, rseq, 5, mat, 5, 1, SW_BW > abs(rlen - len) * 1.5? SW_BW : abs(rlen - len) * 1.5, n_cigar, &cigar32);
|
||||
w = abs((int)rlen - len) * 1.5;
|
||||
ksw_global(len, seq, rlen, rseq, 5, mat, 5, 1, SW_BW > w? SW_BW : w, n_cigar, &cigar32);
|
||||
assert(*n_cigar > 0);
|
||||
if ((cigar32[*n_cigar - 1]&0xf) == 1) cigar32[*n_cigar - 1] = (cigar32[*n_cigar - 1]>>4<<4) | 3; // change endding ins to soft clipping
|
||||
if ((cigar32[0]&0xf) == 1) cigar32[0] = (cigar32[0]>>4<<4) | 3; // change beginning ins to soft clipping
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ void bsw2_pair(const bsw2opt_t *opt, int64_t l_pac, const uint8_t *pac, int n, b
|
|||
double diff;
|
||||
G[0] = hits[i]->hits[0].G + a[1].G;
|
||||
G[1] = hits[i+1]->hits[0].G + a[0].G;
|
||||
diff = fabs(G[0] - G[1]) / (opt->a + opt->b) / ((hits[i]->hits[0].len + a[1].len + hits[i+1]->hits[0].len + a[0].len) / 2.);
|
||||
diff = fabs((double)(G[0] - G[1])) / (opt->a + opt->b) / ((hits[i]->hits[0].len + a[1].len + hits[i+1]->hits[0].len + a[0].len) / 2.);
|
||||
if (diff > 0.05) a[G[0] > G[1]? 0 : 1].G = 0;
|
||||
}
|
||||
if (a[0].G == 0 || a[1].G == 0) { // one proper pair only
|
||||
|
|
|
|||
Loading…
Reference in New Issue