Commit d130b9d5 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

core/windowExtractor.{h,cpp}: windowExtractor use Stats

parent 1d870139
......@@ -16,19 +16,17 @@ WindowsStorage *WindowExtractor::extract(OnlineFasta *reads, MultiGermline *mult
nb_reads++;
KmerSegmenter seg(reads->getSequence(), multigermline);
int read_length = seg.getSequence().sequence.length();
stats_segmented[seg.getSegmentationStatus()]++;
stats_length[seg.getSegmentationStatus()] += seg.getSequence().sequence.length();
stats[seg.getSegmentationStatus()].insert(read_length);
if (seg.isSegmented()) {
junction junc = seg.getJunction(w);
if (junc.size()) {
stats_segmented[TOTAL_SEG_AND_WINDOW]++ ;
stats_length[TOTAL_SEG_AND_WINDOW] += seg.getSequence().sequence.length() ;
stats[TOTAL_SEG_AND_WINDOW].insert(read_length) ;
windowsStorage->add(junc, reads->getSequence(), seg.getSegmentationStatus(), seg.segmented_germline);
} else {
stats_segmented[TOTAL_SEG_BUT_TOO_SHORT_FOR_THE_WINDOW]++ ;
stats_length[TOTAL_SEG_BUT_TOO_SHORT_FOR_THE_WINDOW] += seg.getSequence().sequence.length() ;
stats[TOTAL_SEG_BUT_TOO_SHORT_FOR_THE_WINDOW].insert(read_length) ;
}
if (out_segmented) {
......@@ -50,7 +48,7 @@ WindowsStorage *WindowExtractor::extract(OnlineFasta *reads, MultiGermline *mult
}
float WindowExtractor::getAverageSegmentationLength(SEGMENTED seg) {
return stats_length[seg]*1./getNbSegmented(seg);
return stats[seg].getAverageLength();
}
size_t WindowExtractor::getNbReads() {
......@@ -58,7 +56,7 @@ size_t WindowExtractor::getNbReads() {
}
size_t WindowExtractor::getNbSegmented(SEGMENTED seg) {
return stats_segmented[seg];
return stats[seg].nb;
}
void WindowExtractor::setSegmentedOutput(ostream *out) {
......@@ -71,8 +69,17 @@ void WindowExtractor::setUnsegmentedOutput(ostream *out) {
void WindowExtractor::init_stats() {
for (int i = 0; i < STATS_SIZE; i++) {
stats_segmented[i] = 0;
stats_length[i] = 0;
stats[i].label = segmented_mesg[i];
}
nb_reads = 0;
}
void WindowExtractor::out_stats(ostream &out)
{
for (int i=0; i<STATS_SIZE; i++)
{
if (i == TOTAL_SEG_AND_WINDOW)
out << endl;
out << stats[i] ;
}
}
......@@ -16,13 +16,13 @@ using namespace std;
*/
class WindowExtractor {
private:
size_t stats_segmented[STATS_SIZE];
size_t stats_length[STATS_SIZE];
size_t nb_reads;
ostream *out_segmented;
ostream *out_unsegmented;
Stats stats[STATS_SIZE];
public:
WindowExtractor();
......@@ -77,6 +77,12 @@ class WindowExtractor {
*/
void setUnsegmentedOutput(ostream *out);
/**
* Output the segmentation stats
* @param out: The output stream
*/
void out_stats(ostream &out);
private:
/**
* Initialize the statistics (put 0 everywhere).
......
......@@ -855,18 +855,8 @@ int main (int argc, char **argv)
stream_segmentation_info << " # av. length" << endl ;
multigermline->out_stats(stream_segmentation_info);
for (int i=0; i<STATS_SIZE; i++)
{
stream_segmentation_info << " " << left << setw(20) << segmented_mesg[i]
<< " ->" << right << setw(9) << we.getNbSegmented(static_cast<SEGMENTED>(i)) ;
if (we.getAverageSegmentationLength(static_cast<SEGMENTED>(i)))
stream_segmentation_info << " " << setw(5) << fixed << setprecision(1)
<< we.getAverageSegmentationLength(static_cast<SEGMENTED>(i));
stream_segmentation_info << endl ;
}
stream_segmentation_info << endl;
we.out_stats(stream_segmentation_info);
cout << stream_segmentation_info.str();
map <junction, JsonList> json_data_segment ;
......
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