Commit 4a35537d authored by Mathieu Giraud's avatar Mathieu Giraud

core/segment.cpp: extract method checkLeftRightEvaluesThreshold(threshold, strand)

This could be used by the FineSegmenter as well.
parent d10ee62d
......@@ -79,6 +79,25 @@ bool Segmenter::isDSegmented() const {
return dSegmented;
}
// E-values
void Segmenter::checkLeftRightEvaluesThreshold(double threshold, int strand)
{
if (threshold == NO_LIMIT_VALUE)
return ;
if (evalue_left >= threshold && evalue_right >= threshold)
because = UNSEG_TOO_FEW_ZERO ;
else if ((strand == 1 ? evalue_left : evalue_right) >= threshold)
because = UNSEG_TOO_FEW_V ;
else if ((strand == 1 ? evalue_right : evalue_left) >= threshold)
because = UNSEG_TOO_FEW_J ;
else if (evalue >= threshold) // left and right are <= threshold, but their sum is > threshold
because = UNSEG_TOO_FEW_ZERO ;
}
// Chevauchement
string Segmenter::removeChevauchement()
......@@ -427,26 +446,16 @@ void KmerSegmenter::computeSegmentation(int strand, KmerAffect before, KmerAffec
}
// E-values
pair <double, double> pvalues = kaa->getLeftRightProbabilityAtLeastOrAbove();
evalue_left = pvalues.first * multiplier ;
evalue_right = pvalues.second * multiplier ;
evalue = evalue_left + evalue_right ;
// E-value threshold
if (threshold > NO_LIMIT_VALUE && evalue >= threshold) {
// Detail the unsegmentation cause
if (evalue_left >= threshold && evalue_right >= threshold)
because = UNSEG_TOO_FEW_ZERO ;
else if ((strand == 1 ? evalue_left : evalue_right) >= threshold)
because = UNSEG_TOO_FEW_V ;
else if ((strand == 1 ? evalue_right : evalue_left) >= threshold)
because = UNSEG_TOO_FEW_J ;
else // left and right are <= threshold, but their sum is > threshold
because = UNSEG_TOO_FEW_ZERO ;
checkLeftRightEvaluesThreshold(threshold, strand);
if (because != NOT_PROCESSED)
return ;
}
// There was a good segmentation point
......@@ -458,8 +467,6 @@ void KmerSegmenter::computeSegmentation(int strand, KmerAffect before, KmerAffec
Jstart = tmp;
}
assert(because == NOT_PROCESSED);
// Yes, it is segmented
segmented = true;
reversed = (strand == -1);
......
......@@ -67,6 +67,12 @@ protected:
bool reversed, segmented, dSegmented;
int because;
/**
* Compares evalue_left, evalue_right and evalue against the provided threshold
* @post some evalue is above the threshold ==> because is set to UNSEG_TOO_FEW_ZERO, UNSEG_TOO_FEW_V or UNSEG_TOO_FEW_J
*/
void checkLeftRightEvaluesThreshold(double threshold, int strand);
string removeChevauchement();
bool finishSegmentation();
bool finishSegmentationD();
......
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