]> git.donarmstrong.com Git - samtools.git/commitdiff
Use int64_t to prevent count overflow in view -c; on behalf of Joshua Randall: Set...
authorPetr Danecek <pd3@sanger.ac.uk>
Thu, 2 Aug 2012 13:33:45 +0000 (14:33 +0100)
committerPetr Danecek <pd3@sanger.ac.uk>
Thu, 2 Aug 2012 13:33:45 +0000 (14:33 +0100)
bam2bcf.c
misc/plot-bamcheck
sam_view.c

index f69684dc8c31acce2636b17a8da95374ecb3231a..a51a406f249c05834b0d8e20f49403d5ed29a3b6 100644 (file)
--- a/bam2bcf.c
+++ b/bam2bcf.c
@@ -87,9 +87,9 @@ int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t
                if (min_dist > p->qpos) min_dist = p->qpos;
                if (min_dist > CAP_DIST) min_dist = CAP_DIST;
                r->anno[1<<2|is_diff<<1|0] += baseQ;
-               r->anno[1<<2|is_diff<<1|1] += baseQ * baseQ;
+               r->anno[1<<2|is_diff<<1|1] += baseQ * baseQ;    // FIXME: signed int is not enough for thousands of samples
                r->anno[2<<2|is_diff<<1|0] += mapQ;
-               r->anno[2<<2|is_diff<<1|1] += mapQ * mapQ;
+               r->anno[2<<2|is_diff<<1|1] += mapQ * mapQ;              // FIXME: signed int is not enough for thousands of samples
                r->anno[3<<2|is_diff<<1|0] += min_dist;
                r->anno[3<<2|is_diff<<1|1] += min_dist * min_dist;
        }
index d5857f15798d25995913f4f517048a88c4d64ef0..e5f5b4aba135ffed6785c600f2a57581f1a2e44f 100755 (executable)
@@ -349,6 +349,7 @@ sub plot_qualities
                 set size 0.4,0.8
                 unset ytics
                 set y2tics mirror
+                               set yrange [0:$yrange]
                 unset ylabel
                 set xlabel "Cycle (rev reads)"
                 set label "$$args{title}" at screen 0.5,0.95 center
index c7a47747b4aba916911534591411ae0721b962a2..528309897bbf7c2a35bb4f2fa4727f522afb889e 100644 (file)
@@ -14,7 +14,7 @@ KHASH_SET_INIT_STR(rg)
 // data passed to the bam_fetch callback is encapsulated in this struct.
 typedef struct {
        bam_header_t *header;
-       int *count;
+       int64_t *count;  // int does overflow for very big BAMs
 } count_func_data_t;
 
 typedef khash_t(rg) *rghash_t;
@@ -128,7 +128,7 @@ int main_samview(int argc, char *argv[])
 {
        int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, compress_level = -1, is_bamout = 0, is_count = 0;
        int of_type = BAM_OFDEC, is_long_help = 0, n_threads = 0;
-       int count = 0;
+       int64_t count = 0;
        samfile_t *in = 0, *out = 0;
        char in_mode[5], out_mode[5], *fn_out = 0, *fn_list = 0, *fn_ref = 0, *fn_rg = 0, *q;
 
@@ -274,7 +274,7 @@ int main_samview(int argc, char *argv[])
 
 view_end:
        if (is_count && ret == 0) {
-               printf("%d\n", count);
+               printf("%ld\n", count); // compilers on some platforms may complain about printing int64_t with %ld
        }
        // close files, free and return
        free(fn_list); free(fn_ref); free(fn_out); free(g_library); free(g_rg); free(fn_rg);