+static int g_sol2sanger_tbl[128];
+static void *g_bed;
+
+void *bed_read(const char *fn);
+void bed_destroy(void *_h);
+int bed_overlap(const void *_h, const char *chr, int beg, int end);
+
+static void sol2sanger(bam1_t *b)
+{
+ int l;
+ uint8_t *qual = bam1_qual(b);
+ if (g_sol2sanger_tbl[30] == 0) {
+ for (l = 0; l != 128; ++l) {
+ g_sol2sanger_tbl[l] = (int)(10.0 * log(1.0 + pow(10.0, (l - 64 + 33) / 10.0)) / log(10.0) + .499);
+ if (g_sol2sanger_tbl[l] >= 93) g_sol2sanger_tbl[l] = 93;
+ }
+ }
+ for (l = 0; l < b->core.l_qseq; ++l) {
+ int q = qual[l];
+ if (q > 127) q = 127;
+ qual[l] = g_sol2sanger_tbl[q];
+ }
+}