Skip to content

Instantly share code, notes, and snippets.

@genomewalker
Created December 9, 2018 11:13
Show Gist options
  • Save genomewalker/a3f03846cf7e5ad63be63a9c8c153301 to your computer and use it in GitHub Desktop.
Save genomewalker/a3f03846cf7e5ad63be63a9c8c153301 to your computer and use it in GitHub Desktop.
--- pvec.h 2018-12-09 12:08:14.727171805 +0100
+++ pvec_mod.h 2018-12-09 12:09:36.186071505 +0100
@@ -539,22 +539,26 @@
static inline double gap_posterior( double v1, double v2 ) {
- assert( pgap_model.is_valid_ptr() );
- //return v1 / (v1 + v2);
+ assert( pgap_model.is_valid_ptr() );
+ //return v1 / (v1 + v2);
- v1 *= 1 - pgap_model->gap_freq();
- // throw std::runtime_error( "i think there is an error in this function. why v1 in the next line?");
- v2 *= pgap_model->gap_freq();
-
- float v = float(v1 / (v1 + v2));
-
- if( v != v ) {
- std::cerr << "meeeeep: " << v1 << " " << v2 << "\n";
-
- throw std::runtime_error("bailing out.");
- }
-
- return v;
+ v1 *= 1 - pgap_model->gap_freq();
+ // throw std::runtime_error( "i think there is an error in this function. why v1 in the next line?");
+ v2 *= pgap_model->gap_freq();
+
+ float v;
+
+ if (v1 != 0) {
+ v = float(v1 / (v1 + v2));
+ if( v != v ) {
+ std::cerr << "meeeeep: " << v1 << " " << v2 << "\n";
+
+ throw std::runtime_error("bailing out.");
+ }
+ } else {
+ v = v1;
+ }
+ return v;
}
static inline double gap_ancestral_probability( double v1, double v2 ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment