Commit 1f1f16e2 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

core/segment.cpp: KmerMultiSegmenter keeps the 'best unsegmented' kseg when...

core/segment.cpp: KmerMultiSegmenter keeps the 'best unsegmented' kseg when the sequence is not segmented

This allows to report a more meaningful unsegmentation cause than just picking the last one.
Let say that the first point of the current CHANGELOG already included this feature.
parent 801c5f8c
......@@ -277,6 +277,7 @@ KmerSegmenter::~KmerSegmenter() {
KmerMultiSegmenter::KmerMultiSegmenter(Sequence seq, MultiGermline *multigermline, ostream *out_unsegmented)
{
int best_score = 0 ;
int best_score_unseg = 0 ; // Best score, unsegmented sequences
the_kseg = NULL;
// Iterate over the germlines
......@@ -302,18 +303,32 @@ KmerMultiSegmenter::KmerMultiSegmenter(Sequence seq, MultiGermline *multigermlin
*out_unsegmented << endl ;
}
if (!best_score)
// Always remember the first kseg
if (the_kseg == NULL)
keep_seg = true;
if (kseg->isSegmented())
{
// Yes, it is segmented
// Should we keep the kseg ?
if (kseg->score > best_score)
{
keep_seg = true;
best_score = kseg->score ;
}
}
else
{
// It is not segmented
// Should we keep the kseg (with the unsegmentation cause) ?
if (kseg->score > best_score_unseg)
{
best_score_unseg = kseg->score ;
if (!best_score_seg)
keep_seg = true;
}
}
if (keep_seg) {
the_kseg = kseg;
} else {
......
......@@ -56,7 +56,7 @@ WindowsStorage *WindowExtractor::extract(OnlineFasta *reads, MultiGermline *mult
nb_reads_germline[seg->system]++;
} else if (out_unsegmented) {
*out_unsegmented << "#>" << reads->getSequence().label << " not segmented " << segmented_mesg[seg->getSegmentationStatus()] << endl << endl;
*out_unsegmented << "#>" << reads->getSequence().label << " not segmented " << segmented_mesg[seg->getSegmentationStatus()] << " (" << seg->segmented_germline->code << ")" << endl << endl;
}
}
return windowsStorage;
......
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