modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / BGI / SOAPsnp / sam / sam_view.h
blob0a655061d65d9fb8359e2f57e3ffd6761dc04047
1 #ifndef SAM_VIEW_H
2 #define SAM_VIEW_H
5 static int g_min_mapQ = 0, g_flag_on = 0, g_flag_off = 0;
6 static char *g_library, *g_rg;
7 static int g_sol2sanger_tbl[128];
9 static void sol2sanger(bam1_t *b)
11 int l;
12 uint8_t *qual = bam1_qual(b);
13 if (g_sol2sanger_tbl[30] == 0) {
14 for (l = 0; l != 128; ++l) {
15 g_sol2sanger_tbl[l] = (int)(10.0 * log(1.0 + pow(10.0, (l - 64 + 33) / 10.0)) / log(10.0) + .499);
16 if (g_sol2sanger_tbl[l] >= 93) g_sol2sanger_tbl[l] = 93;
19 for (l = 0; l < b->core.l_qseq; ++l) {
20 int q = qual[l];
21 if (q > 127) q = 127;
22 qual[l] = g_sol2sanger_tbl[q];
26 static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b)
28 if (b->core.qual < g_min_mapQ || ((b->core.flag & g_flag_on) != g_flag_on) || (b->core.flag & g_flag_off))
29 return 1;
30 if (g_rg) {
31 uint8_t *s = bam_aux_get(b, "RG");
32 if (s && strcmp(g_rg, (char*)(s + 1)) == 0) return 0;
34 if (g_library) {
35 const char *p = bam_get_library((bam_header_t*)h, b);
36 return (p && strcmp(p, g_library) == 0)? 0 : 1;
38 return 0;
42 #endif