Commit 6d3b37c0 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

core/segment.{cpp,h}: extract MultiSegmenter::getProba() from KmerMultiSegmenter::getNbExpected()

parent 7e4aa2e0
......@@ -351,13 +351,22 @@ KmerMultiSegmenter::KmerMultiSegmenter(Sequence seq, MultiGermline *multigermlin
the_kseg->setSegmentationStatus(UNSEG_NOISY);
}
double KmerMultiSegmenter::getNbExpected() const {
int max = the_kseg->score;
double KmerSegmenter::getProbabilityAtLeastOrAbove(int at_least) const {
// n: number of kmers in the sequence
int n = getSequence().sequence.size() - getKmerAffectAnalyser()->getIndex().getS();
float index_load = getKmerAffectAnalyser()->getIndex().getIndexLoad() ;
double proba = 0;
int n = the_kseg->getSequence().sequence.size() - the_kseg->getKmerAffectAnalyser()->getIndex().getS();
for (int i = max; i< n; i++) {
proba += nChoosek(n, i) * pow(the_kseg->getKmerAffectAnalyser()->getIndex().getIndexLoad(), i);
for (int i=at_least; i<n; i++) {
proba += nChoosek(n, i) * pow(index_load, i);
}
return proba;
}
double KmerMultiSegmenter::getNbExpected() const {
double proba = the_kseg->getProbabilityAtLeastOrAbove(the_kseg->score);
return multi_germline->germlines.size() * proba;
}
......
......@@ -177,6 +177,11 @@ class KmerSegmenter : public Segmenter
~KmerSegmenter();
/**
* @return probability that the score of the segmenter is 'at_least' or more
*/
double getProbabilityAtLeastOrAbove(int at_least) const;
/**
* @return the KmerAffectAnalyser of the current sequence.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment