Permalink
Browse files

Rename Stats.h/Stats.cpp to avoid OSX clash

  • Loading branch information...
1 parent 086d968 commit 930671f5a2c859193690a2fe0e918d5d1c6465b4 @jts committed Mar 21, 2013
Showing with 47 additions and 42 deletions.
  1. +7 −11 src/SGA/haplotype-filter.cpp
  2. +1 −1 src/Util/Makefile.am
  3. +34 −0 src/Util/SGAStats.cpp
  4. +5 −5 src/Util/{Stats.h → SGAStats.h}
  5. +0 −25 src/Util/Stats.cpp
View
18 src/SGA/haplotype-filter.cpp
@@ -19,7 +19,7 @@
#include "Timer.h"
#include "SequenceProcessFramework.h"
#include "HapgenUtil.h"
-#include "Stats.h"
+#include "SGAStats.h"
#include "HashMap.h"
// Functions
@@ -248,7 +248,6 @@ int haplotypeFilterMain(int argc, char** argv)
lmss << ";LM=" << LM << ";";
lmss << "O=" << total_coverage << ";";
fields[7] = lmss.str();
-
std::copy(fields.begin(), fields.end(), std::ostream_iterator<std::string>(outFile, "\t"));
outFile << "\n";
}
@@ -381,7 +380,6 @@ double LMHaploid(double d, const std::vector<size_t>& sample_count)
}
else
{
- //sum += (log(M/N) + Stats::logPoisson(oi, q) - Stats::logPoisson(oi, p));
sum += log(M/N) + oi * log(q) - oi * log(p) + p - q;
}
}
@@ -489,10 +487,8 @@ double _haploidNonUniform(const std::vector<double>& depths, const std::vector<s
}
else
{
- //sum += (log(M/N) + Stats::logPoisson(oi, q) - Stats::logPoisson(oi, p));
- //sum += log(M/N) + oi * log(q) - oi * log(p) + p - q;
- L_NULL = Stats::logPoisson(oi, p);
- L_ALT = (log(M/N) + Stats::logPoisson(oi, q));
+ L_NULL = SGAStats::logPoisson(oi, p);
+ L_ALT = (log(M/N) + SGAStats::logPoisson(oi, q));
sum += L_ALT - L_NULL;
}
@@ -543,9 +539,9 @@ double LMDiploid(double d, const std::vector<size_t>& sample_count)
}
else
{
- double log_null = Stats::logPoisson(oi, p);
+ double log_null = SGAStats::logPoisson(oi, p);
double t1 = 2 * f * (1 - f) * pow(q, oi) * exp(-q) + pow(f, 2) * pow(2 * q, oi) * exp(-2 * q);
- double t2 = Stats::logFactorial(oi);
+ double t2 = SGAStats::logFactorial(oi);
double t3 = log(t1) - t2;
sum += t3 - log_null;
}
@@ -670,9 +666,9 @@ double _diploidNonUniform(const std::vector<double>& depths, const std::vector<s
}
else
{
- double log_null = Stats::logPoisson(oi, p);
+ double log_null = SGAStats::logPoisson(oi, p);
double t1 = het_prop * pow(q, oi) * exp(-q) + hom_alt_prop * pow(2 * q, oi) * exp(-2 * q);
- double t2 = Stats::logFactorial(oi);
+ double t2 = SGAStats::logFactorial(oi);
double t3 = log(t1) - t2;
sum += t3 - log_null;
L_NULL = log_null;
View
2 src/Util/Makefile.am
@@ -19,7 +19,7 @@ libutil_a_SOURCES = \
SeqCoord.h SeqCoord.cpp \
MultiOverlap.h MultiOverlap.cpp \
QualityVector.h QualityVector.cpp \
- Stats.h Stats.cpp \
+ SGAStats.h SGAStats.cpp \
Quality.h Quality.cpp \
PrimerScreen.h PrimerScreen.cpp \
BitVector.h BitVector.cpp \
View
34 src/Util/SGAStats.cpp
@@ -0,0 +1,34 @@
+//-----------------------------------------------
+// Copyright 2009-2013 Wellcome Trust Sanger Institute
+// Written by Jared Simpson (js18@sanger.ac.uk)
+// Released under the GPL
+//-----------------------------------------------
+//
+// SGAStats - Common statistics functions used
+// throughout the program
+//
+#include "SGAStats.h"
+#include <math.h>
+#include <iostream>
+
+//
+// Poisson in log space
+//
+double SGAStats::logPoisson(unsigned int k, double m)
+{
+ double f_k = logFactorial(k);
+ double p = (double)k * log(m) - m - f_k;
+ //std::cout << "k: " << k << " f: " << f_k << " m: " << m << " p: " << p << std::endl;
+ return p;
+}
+
+//
+// Factorial in log space
+//
+double SGAStats::logFactorial(unsigned int k)
+{
+ double result = 0;
+ while(k > 0)
+ result += log(k--); //slow
+ return result;
+}
View
10 src/Util/Stats.h → src/Util/SGAStats.h
@@ -1,23 +1,23 @@
//-----------------------------------------------
-// Copyright 2009 Wellcome Trust Sanger Institute
+// Copyright 2009-2013 Wellcome Trust Sanger Institute
// Written by Jared Simpson (js18@sanger.ac.uk)
// Released under the GPL
//-----------------------------------------------
//
-// Stats - Common statistics functions used
+// SGAStats - Common statistics functions used
// throughout the program
//
-#ifndef STATS_H
+#ifndef SGASTATS_H
#define STATS_H
-namespace Stats
+namespace SGAStats
{
//
// Probability
//
double logPoisson(unsigned int k, double m);
double logFactorial(unsigned int k);
-};
+}
#endif
View
25 src/Util/Stats.cpp
@@ -1,25 +0,0 @@
-#include "Stats.h"
-#include <math.h>
-#include <iostream>
-
-//
-// Poisson in log space
-//
-double Stats::logPoisson(unsigned int k, double m)
-{
- double f_k = logFactorial(k);
- double p = (double)k * log(m) - m - f_k;
- //std::cout << "k: " << k << " f: " << f_k << " m: " << m << " p: " << p << std::endl;
- return p;
-}
-
-//
-// Factorial in log space
-//
-double Stats::logFactorial(unsigned int k)
-{
- double result = 0;
- while(k > 0)
- result += log(k--); //slow
- return result;
-}

0 comments on commit 930671f

Please sign in to comment.