Commit 36b477cc authored by HERBERT Ryan's avatar HERBERT Ryan
parents d4cc747b 9d8e033e
......@@ -109,7 +109,7 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before,
affect_infos results;
results.max_found = false;
results.max_value = 0;
results.first_pos_max = results.last_pos_max = -1;
results.first_pos_max = results.last_pos_max = 0;
results.nb_before_left = results.nb_before_right = results.nb_after_right = results.nb_after_left = 0;
currentValue = 0;
......@@ -172,19 +172,14 @@ affect_infos KmerAffectAnalyser::getMaximum(const KmerAffect &before,
results.nb_after_right,
seq.size() - 1 - results.first_pos_max);
/* Main test:
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
2) there should be at least one 'before' and one 'after' (? CHECK ?)
*/
if ((results.nb_after_right >= results.nb_before_right*ratioMin)
&& (results.nb_after_right >= results.nb_after_left*ratioMin)
&& (results.nb_before_left >= results.nb_after_left*ratioMin)
&& (results.nb_before_left >= results.nb_before_right*ratioMin)
&& (results.nb_after_right > 0 || results.nb_before_right == 0)
&& currentValue < results.max_value
&& results.max_value > 0) {
/* 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 more than 'ratioMin' more in good positions.
As the comparison is strict, passing this test implies that there is at least one 'before' kmer at the left
and one 'after' kmer at the right.
*/
if ((results.nb_after_right > results.nb_after_left*ratioMin)
&& (results.nb_before_left > results.nb_before_right*ratioMin)) {
results.max_found = true;
}
......
......@@ -163,18 +163,18 @@ class KmerAffectAnalyser: public AffectAnalyser {
* maximise the number of affectations before, minus the number of
* affectations after the returned positions.
*
* The maximum reached must be above max(0, total number of <before>)
* and such that the numbers of <before>/<after> in "good" positions
* The maximum reached must be
* such that the numbers of <before>/<after> in "good" positions
* (at the left of the leftmost max position for <before>,
* and at the right of the rightmost max position for <after>)
* are at least <ratioMin> times than the numbers of <before>/<after>
* are more than <ratioMin> times than the numbers of <before>/<after>
* in "bad" positions. If no so much maximum is found,
* the boolean <max_found> is set to false in the structure.
*
* @complexity time: linear in count(), space: constant
*/
affect_infos getMaximum(const KmerAffect &before, const KmerAffect &after,
float ratioMin=2.,
float ratioMin=1.9,
int maxOverlap=1);
......
......@@ -211,7 +211,7 @@ void testGetMaximum() {
"(" << results.first_pos_max
<< ", " << results.last_pos_max << ")");
results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 1., 0);
results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 0.9, 0);
TAP_TEST(results.max_found ,
TEST_AA_GET_MAXIMUM_MAX_FOUND, "(" << results.first_pos_max
<< ", " << results.last_pos_max << ")");
......@@ -221,7 +221,7 @@ void testGetMaximum() {
TAP_TEST(results.max_value == 2, TEST_AA_GET_MAXIMUM_VALUE,
"max = " << results.max_value);
results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 1., k);
results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 0.9, k);
TAP_TEST(results.max_found,
TEST_AA_GET_MAXIMUM_MAX_FOUND, "(" << results.first_pos_max
<< ", " << results.last_pos_max << ")");
......@@ -230,7 +230,7 @@ void testGetMaximum() {
<< ", " << results.last_pos_max << ")");
TAP_TEST(results.max_value == 2, TEST_AA_GET_MAXIMUM_VALUE, "");
affect_infos results2 = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 1., k+5);
affect_infos results2 = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 0.9, k+5);
TAP_TEST(results == results2, TEST_AA_GET_MAXIMUM_VALUE, "");
KmerAffect a2[] = {AFFECT_V, AFFECT_V, AFFECT_V, AFFECT_V, AFFECT_V,
......
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