File: mapq.cpp

package info (click to toggle)
snap-aligner 1.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,988 kB
  • sloc: cpp: 36,500; ansic: 5,239; python: 227; makefile: 85; sh: 28
file content (45 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*++

Module Name:

    mapq.cpp

Abstract:

    Support functions for mapping quality

Authors:

    Bill Bolosky, December, 2012

Environment:

    User mode service.

Revision History:

 
--*/

#include "stdafx.h"
#include "Compat.h"
#include "mapq.h"

const int maxMAPQ = 70;

static double mapqToProbabilityTable[maxMAPQ+1];

void initializeMapqTables()
{
    mapqToProbabilityTable[0] = .1;  // This should technically be 0, but in practice it's a little better than that, so leave some chance here.
    for (int i = 1; i <= maxMAPQ; i++) {
        mapqToProbabilityTable[i] = 1- pow(10.0,((double)i) / -10.0);
    }

}

double mapqToProbability(int mapq)
{
    _ASSERT(mapq >= 0 && mapq <= maxMAPQ);
    return mapqToProbabilityTable[mapq];
}