Skip to content

Commit

Permalink
feat: print switch/flip error rates to summary TSV
Browse files Browse the repository at this point in the history
  • Loading branch information
TimD1 committed Nov 11, 2024
1 parent 0fd7543 commit a1a2852
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void phaseblockData::phase()
if (g.verbosity >= 1) INFO(" Phase block NG50: %d", ng50);
if (g.verbosity >= 1) INFO(" (switch) Phase block NGC50: %d", s_ngc50);
if (g.verbosity >= 1) INFO(" (switchflip) Phase block NGC50: %d", sf_ngc50);
this->write_phasing_summary(phase_blocks, switch_errors, flip_errors, ng50, s_ngc50, sf_ngc50);
this->write_phasing_summary(phase_blocks, switch_errors, flip_errors, variants, ng50, s_ngc50, sf_ngc50);
}


Expand Down Expand Up @@ -501,16 +501,18 @@ void phaseblockData::write_switchflips() {


void phaseblockData::write_phasing_summary(int phase_blocks, int switch_errors,
int flip_errors, int ng50, int s_ngc50, int sf_ngc50) {
int flip_errors, int variants, int ng50, int s_ngc50, int sf_ngc50) {
std::string out_phasing_summary_fn = g.out_prefix + "phasing-summary.tsv";
if (g.verbosity >= 1) INFO(" ");
if (g.verbosity >= 1) INFO(" Writing phasing summary to '%s'",
out_phasing_summary_fn.data());
FILE* out_phasing_summary = fopen(out_phasing_summary_fn.data(), "w");
fprintf(out_phasing_summary,
"PHASE_BLOCKS\tSWITCH_ERRORS\tFLIP_ERRORS\tNG_50\tSWITCH_NGC50\tSWITCHFLIP_NGC50\n");
fprintf(out_phasing_summary, "%d\t%d\t%d\t%d\t%d\t%d", phase_blocks,
switch_errors, flip_errors, ng50, s_ngc50, sf_ngc50);
"PHASE_BLOCKS\tSWITCH_ERRORS\tFLIP_ERRORS\tSWITCH_ERROR_RATE\tFLIP_ERROR_RATE\t"
"NG_50\tSWITCH_NGC50\tSWITCHFLIP_NGC50\n");
fprintf(out_phasing_summary, "%d\t%d\t%d\t%.6f%%\t%.6f%%\t%d\t%d\t%d", phase_blocks,
switch_errors, flip_errors, 100*switch_errors/float(variants),
100*flip_errors/float(variants), ng50, s_ngc50, sf_ngc50);
fclose(out_phasing_summary);
}

Expand Down
2 changes: 1 addition & 1 deletion src/phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class phaseblockData {

void write_summary_vcf(std::string vcf_fn);
void write_phasing_summary(int phase_blocks, int switch_errors,
int flip_errors, int ng50, int s_ngc50, int sf_ngc50);
int flip_errors, int variants, int ng50, int s_ngc50, int sf_ngc50);
void write_switchflips();
void phase();
int calculate_ng50(bool break_on_switch = false, bool break_on_flip = false);
Expand Down

0 comments on commit a1a2852

Please sign in to comment.