Commit afaae79d authored by Mikaël Salson's avatar Mikaël Salson
Browse files

affectanalyse: Compute left and right e-values when computing max.

That avoids to recompute them each time the getLeftRightProbabilityAtLeastOrAbove() function is called.
parent bcef539b
...@@ -106,6 +106,7 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before, ...@@ -106,6 +106,7 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before,
maxOverlap = span; maxOverlap = span;
/* Initialize results */ /* Initialize results */
affect_infos results;
results.max_found = false; results.max_found = false;
results.max_value = 0; results.max_value = 0;
results.first_pos_max = results.last_pos_max = -1; results.first_pos_max = results.last_pos_max = -1;
...@@ -156,6 +157,10 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before, ...@@ -156,6 +157,10 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before,
results.nb_before_right++; results.nb_before_right++;
} }
left_evalue = kms.getProbabilityAtLeastOrAbove(results.nb_before_left,
results.first_pos_max + kms.getS());
right_evalue = kms.getProbabilityAtLeastOrAbove(results.nb_after_right, seq.size() - results.last_pos_max);
/* Main test: /* Main test:
1) do we have enough affectations in good positions ('before' at the left and 'after' at the right) ? 1) do we have enough affectations in good positions ('before' at the left and 'after' at the right) ?
We tolerate some of them in bad positions, but there must be 'ratioMin' more in good positions We tolerate some of them in bad positions, but there must be 'ratioMin' more in good positions
...@@ -178,8 +183,7 @@ double KmerAffectAnalyser::getProbabilityAtLeastOrAbove(int at_least) const { ...@@ -178,8 +183,7 @@ double KmerAffectAnalyser::getProbabilityAtLeastOrAbove(int at_least) const {
} }
pair <double, double> KmerAffectAnalyser::getLeftRightProbabilityAtLeastOrAbove() const { pair <double, double> KmerAffectAnalyser::getLeftRightProbabilityAtLeastOrAbove() const {
return make_pair(kms.getProbabilityAtLeastOrAbove(results.nb_before_left, results.first_pos_max + kms.getS()), return make_pair(left_evalue, right_evalue);
kms.getProbabilityAtLeastOrAbove(results.nb_after_right, seq.size() - results.last_pos_max));
} }
const string &KmerAffectAnalyser::getSequence() const{ const string &KmerAffectAnalyser::getSequence() const{
......
...@@ -119,7 +119,7 @@ class KmerAffectAnalyser: public AffectAnalyser { ...@@ -119,7 +119,7 @@ class KmerAffectAnalyser: public AffectAnalyser {
IKmerStore<KmerAffect> &kms; IKmerStore<KmerAffect> &kms;
const string &seq; const string &seq;
vector<KmerAffect> affectations; vector<KmerAffect> affectations;
affect_infos results ; double left_evalue, right_evalue;
public: public:
/** /**
......
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