[go: up one dir, main page]

File: Ewens.h

package info (click to toggle)
freebayes 1.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,984 kB
  • sloc: cpp: 125,778; ansic: 4,581; sh: 1,084; python: 672; asm: 271; javascript: 94; lisp: 85; makefile: 37; perl: 27
file content (30 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (4)
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
#ifndef FREEBAYES_EWENS_H
#define FREEBAYES_EWENS_H

#include <map>
#include <cmath>
#include "Utility.h"

using namespace std;

// genotype priors

long double alleleFrequencyProbability(const map<int, int>& alleleFrequencyCounts, long double theta);
long double alleleFrequencyProbabilityln(const map<int, int>& alleleFrequencyCounts, long double theta);
long double impl_alleleFrequencyProbabilityln(const map<int, int>& alleleFrequencyCounts, long double theta);

class AlleleFrequencyProbabilityCache : public map<map<int, int>, long double> {
public:
    long double alleleFrequencyProbabilityln(const map<int, int>& counts, long double theta) {
        map<map<int, int>, long double>::iterator p = find(counts);
        if (p == end()) {
            long double pln = impl_alleleFrequencyProbabilityln(counts, theta);
            insert(make_pair(counts, pln));
            return pln;
        } else {
            return p->second;
        }
    }
};

#endif