42 std::string file_name = report;
44 const size_t offset = file_name.find(
".html");
45 file_name.replace( offset+1, file_name.length() - offset - 1, name );
46 file_name.append(
".html" );
58 void add_param(FILE* html_output,
const char* name,
const float val,
bool alt)
65 void add_param(FILE* html_output,
const char* name,
const char* val,
bool alt)
79 uint32 best_bin_val[2] = {0};
80 for (
int32 i = first_row; i <= last_row; ++i)
82 if (best_bin_val[0] < table[i])
84 best_bin_val[1] = best_bin_val[0];
85 best_bin[1] = best_bin[0];
86 best_bin_val[0] = table[i];
89 else if (best_bin_val[1] < table[i])
91 best_bin_val[1] = table[i];
104 int32 first_row = last_row;
105 for (
int32 i = last_row; i > -X; --i)
107 if (100.0f *
float(table[i])/
float(total) > 0.01f)
120 int32 last_row = first_row;
121 for (
int32 i = first_row; i < X; ++i)
123 if (100.0f *
float(table[i])/
float(total) > 0.01f)
142 sprintf(buffer,
"<span><statnum>%5.2f %%%%</statnum> <statbar style=\"width:%.1f%%%%\">\'</statbar></span>", v, 2.0f + range * v/100.0f);
154 const uint32 n_mapped_both)
164 sprintf( buffer1,
"%s-summary-stats", name );
165 sprintf( buffer2,
"%s [%s] summary stats", name, stat_by );
213 sprintf( buffer1,
"%s-stats", name );
214 sprintf( buffer2,
"%s [%s] stats", name, stat_by );
229 int32 best_bin[2] = {0};
230 find_gt2( 0, X-1, table, best_bin );
238 cum_pos[X-1] = 100.0f * float(table[X-1])/float(n_mapped_both);
239 for (
int32 i = X-2; i >= 0; --i)
240 cum_pos[i] = 100.0f *
float(table[i])/float(n_mapped_both) + cum_pos[i+1];
241 cum_neg[0] = cum_pos[0];
242 for (
int32 i = 1; i < X; ++i)
243 cum_neg[i] = 100.0f *
float(table_neg[i])/float(n_mapped_both) + cum_neg[i-1];
245 const float max_perc = 48.0f;
247 char span_string[1024];
248 for (
int32 i = last_row_neg; i > 0; --i)
250 html::tr_object tr( html_output,
"class", i % 2 ?
"none" :
"alt", NULL );
252 stats_string( span_string, 100.0f *
float(table_neg[i]) /
float(total), max_perc );
254 stats_string( span_string, 100.0f *
float(table_neg[i]) /
float(n_mapped_both), max_perc );
256 stats_string( span_string, stats_r.
count ? 100.0f *
float(table_neg[i]) /
float(stats_r.
count) : 0.0f, max_perc );
260 stats_string( span_string, 100.0f - cum_neg[i] + 100.0f *
float(table_neg[i])/
float(n_mapped_both), max_perc );
263 for (
int32 i = 0; i <= last_row; ++i)
265 html::tr_object tr( html_output,
"class", i % 2 ?
"none" :
"alt", NULL );
267 const char* cls = i == best_bin[0] ?
"yellow" : i == best_bin[1] ?
"orange" :
"none";
268 stats_string( span_string, 100.0f *
float(table_neg[i]) /
float(total), max_perc );
270 stats_string( span_string, 100.0f *
float(table[i]) /
float(n_mapped_both), max_perc );
272 stats_string( span_string, stats_l.
count ? 100.0f *
float(table[i]) /
float(stats_l.
count) : 0.0f, max_perc );
276 stats_string( span_string, 100.0f - cum_pos[i] + 100.0f *
float(table[i])/
float(n_mapped_both), max_perc );
303 int32 best_bin[2] = { 0, 1 };
305 find_gt2( row_range.x, row_range.y, stats, best_bin );
311 sprintf( buffer1,
"%s-stats", name );
312 sprintf( buffer2,
"%s [%s] stats", name, stat_by );
320 char span_string[1024];
321 const float max_perc = 70.0f;
322 for (
int32 i = row_range.x; i <= row_range.y; ++i)
324 html::tr_object tr( html_output,
"class", i % 2 ?
"none" :
"alt", NULL );
328 const char* cls = (i == best_bin[0]) ?
"yellow" :
329 (i == best_bin[1]) ?
"orange" :
333 stats_string( span_string, total ? 100.0f *
float(table[i]) /
float(total) : 0.0f, max_perc );
356 const int2 row_range = make_int2(
nvbio::min( row_range_l.x, row_range_r.x ),
360 int32 best_bin[2] = { 0, 1 };
361 int32 worst_bin[2] = { 0, 1 };
363 find_gt2( row_range.x, row_range.y, stats_l, best_bin );
364 find_gt2( row_range.x, row_range.y, stats_r, worst_bin );
370 sprintf( buffer1,
"%s-stats", name );
371 sprintf( buffer2,
"%s [%s] stats", name, stat_by );
380 char span_string[1024];
381 const float max_perc = 70.0f;
382 for (
int32 i = row_range.x; i <= row_range.y; ++i)
384 html::tr_object tr( html_output,
"class", i % 2 ?
"none" :
"alt", NULL );
388 const char* cls_l = (i == best_bin[0]) ?
"yellow" :
389 (i == best_bin[1]) ?
"orange" :
391 const char* cls_r = (i == worst_bin[0]) ?
"red" :
392 (i == worst_bin[1]) ?
"orange" :
396 stats_string( span_string, l_count ? 100.0f *
float(stats_l[i]) /
float(l_count) : 0.0f, max_perc );
398 stats_string( span_string, r_count ? 100.0f *
float(stats_r[i]) /
float(r_count) : 0.0f, max_perc );
404 template <u
int32 XX, u
int32 YY>
411 const char* bin_name,
412 const std::vector<std::string>& X_bins,
413 const std::vector<std::string>& Y_bins,
415 const uint32 n_mapped_both,
416 const bool diff_table)
427 sprintf( buffer1,
"%s-stats-%s", name, bin_name );
428 sprintf( buffer2,
"%s [%s] stats by %s", name, stat_by, bin_name );
440 for (
int32 i = -X+1; i < X; ++i)
442 for (
int32 j = 0; j > -Y; --j)
444 if (stats_l(i,j) > 0 ||
448 for (
int32 j = 0; j < Y; ++j)
450 if (stats_l(i,j) > 0 ||
459 for (
int32 i = 0; i > -X; --i)
461 for (
int32 j = last_col; j >= first_col; --j)
463 if (stats_l(i,j) > 0 ||
469 for (
int32 i = 0; i < X; ++i)
471 for (
int32 j = last_col; j >= first_col; --j)
473 if (stats_l(i,j) > 0 ||
480 int2 best_bin[2] = { make_int2(0,0) };
481 uint32 best_bin_val[2] = { 0 };
483 for (
int32 i = first_row; i <= last_row; ++i)
485 for (
int32 j = first_col; j <= last_col; ++j)
487 if (best_bin_val[0] < stats_l(i,j))
489 best_bin_val[1] = best_bin_val[0];
490 best_bin[1] = best_bin[0];
491 best_bin_val[0] = stats_l(i,j);
492 best_bin[0] = make_int2(i,j);
494 else if (best_bin_val[1] < stats_l(i,j))
496 best_bin_val[1] = stats_l(i,j);
497 best_bin[1] = make_int2(i,j);
503 int2 worst_bin[2] = { make_int2(0,0) };
504 uint32 worst_bin_val[2] = { 0 };
506 for (
int32 i = first_row; i <= last_row; ++i)
508 for (
int32 j = (diff_table ? 1 : first_col); j <= last_col; ++j)
510 if (worst_bin_val[0] < stats_r(i,j))
512 worst_bin_val[1] = worst_bin_val[0];
513 worst_bin[1] = worst_bin[0];
514 worst_bin_val[0] = stats_r(i,j);
515 worst_bin[0] = make_int2(i,j);
517 else if (worst_bin_val[1] < stats_l(i,j))
519 worst_bin_val[1] = stats_r(i,j);
520 worst_bin[1] = make_int2(i,j);
529 for (
int32 j = last_col; j >= (diff_table ? 1 : first_col); --j)
532 for (
int32 j = first_col; j <= last_col; ++j)
538 for (
int32 i = first_row; i <= last_row; ++i)
540 html::tr_object tr( html_output,
"class", i % 2 ?
"none" :
"alt", NULL );
543 for (
int32 j = last_col; j >= (diff_table ? 1 : first_col); --j)
545 const float sval = 100.0f * float(stats_r(i,j))/float(n_mapped_both);
548 const char* cls = (i == worst_bin[0].x && j == worst_bin[0].y) ?
"red" :
549 (i == worst_bin[1].x && j == worst_bin[1].y) ?
"orange" :
553 else if (sval >= 0.01f)
557 const char* cls = sval == 0.0f ?
"gray" :
"pink";
561 for (
int32 j = first_col; j <= last_col; ++j)
563 const float sval = 100.0f * float(stats_l(i,j))/float(n_mapped_both);
566 const char* cls = (i == best_bin[0].x && j == best_bin[0].y) ?
"yellow" :
567 (i == best_bin[1].x && j == best_bin[1].y) ?
"orange" :
571 else if (sval >= 0.01f)
575 const char* cls = sval == 0.0f ?
"gray" :
"none";
584 for (
int32 i = last_col; i >= (diff_table ? 1 : first_col); --i)
586 for (
int32 i = first_col; i <= last_col; ++i)
597 const char* diff_name,
602 const uint32 n_mapped_both,
603 const bool absolute_values =
true)
605 FILE* html_output = fopen( file_name,
"w" );
606 if (html_output == NULL)
608 log_warning( stderr,
"unable to write HTML report \"%s\"\n", file_name );
612 std::vector<std::string> read_bins;
613 read_bins.push_back(
"0" );
614 for (
uint32 x = 0; x < 12; ++x)
618 read_bins.push_back( buffer );
621 std::vector<std::string> log_bins;
622 for (
uint32 y = 0; y < 32; ++y)
625 log_bins.push_back(
"0" );
627 log_bins.push_back(
"1" );
629 log_bins.push_back(
"2" );
633 sprintf(buffer,
"2^%u", y-1);
634 log_bins.push_back( buffer );
641 const char* meta_list =
"<meta http-equiv=\"refresh\" content=\"5\" />";
742 fclose( html_output );