Skip to content

Commit

Permalink
Use NDEBUG to enable debugging output
Browse files Browse the repository at this point in the history
* This is a standard C/C++ macro and is also disabled when
  --enable-debug is passed to the configure script.
  • Loading branch information
SoapZA authored and ozagordi committed May 22, 2017
1 parent 03ba96c commit f65568d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/shorah/data_structures.hpp
Expand Up @@ -274,7 +274,7 @@ void print_stats(std::ofstream& out_file, const cnode* cn, unsigned int J){
if(p == NULL)
out_file << "# no reads in this component\n";
#ifdef DEBUG
#ifndef NDEBUG
if(p != NULL)
out_file << "# reads in the list:\t";
#endif
Expand Down
38 changes: 19 additions & 19 deletions src/shorah/dpm_sampler.cpp
Expand Up @@ -298,7 +298,7 @@ int main(int argc, char** argv)
temp = new int[J / 10 + 1];

for (k = 0; k <= iter; k++) {
#ifdef DEBUG
#ifndef NDEBUG
printf("-----------------------------------------------\n");
printf("-----------> sampling the %ith time <-----------\n", k);
printf("-----------------------------------------------\n");
Expand Down Expand Up @@ -396,7 +396,7 @@ int main(int argc, char** argv)
if (theta <= 0.0) theta = 0.0001;
// sample_ref(); // sampling the reference every step gives strange behaviour...

#ifdef DEBUG
#ifndef NDEBUG
std::cerr << "dt=" << dt << "\ttheta=" << theta << "\tgamma=" << gam << std::endl;
#endif
// out_file("iteration\t%i\t%i\t%i\t%f\t%f\n", k+1, count_classes(mxt), tot_untouch,
Expand Down Expand Up @@ -767,7 +767,7 @@ void build_assignment(std::ofstream& out_file)
// there is at least the first cluster...
cn = mxt;

#ifdef DEBUG
#ifndef NDEBUG
printf("cluster %d has size %d\n", cn->ci, cn->size);
#endif

Expand Down Expand Up @@ -804,12 +804,12 @@ void build_assignment(std::ofstream& out_file)
cn->next->rd0 = (unsigned short int*)malloc(q * sizeof(unsigned short int));
cn->next->rd1 = (unsigned short int*)malloc(q * sizeof(unsigned short int));

#ifdef DEBUG
#ifndef NDEBUG
printf("cluster %d has size %d\n", cn->next->ci, cn->next->size);
#endif

if (cn->next->size == 0) {
#ifdef DEBUG
#ifndef NDEBUG
printf("removing some node... p=%p\n", cn->next);
#endif
remove_comp(&cn->next);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void sample_hap(cnode* cn)
int max_cbase;
unsigned int base_id;

#ifdef DEBUG
#ifndef NDEBUG
printf("Haplotype %i is\n", cn->ci);
#endif

Expand Down Expand Up @@ -1117,12 +1117,12 @@ void sample_hap(cnode* cn)
gsl_ran_discrete_free(g);
}
*/
#ifdef DEBUG
#ifndef NDEBUG
printf("%i ", cn->h[j]);
#endif
}

#ifdef DEBUG
#ifndef NDEBUG
printf("\n");
#endif

Expand Down Expand Up @@ -1283,7 +1283,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
unsigned int tw;
std::pair<int, int> p;
// int local_ci;
#ifdef DEBUG
#ifndef NDEBUG
unsigned int j;
#endif
double b1, b2; //, pow1, pow2;
Expand All @@ -1298,7 +1298,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
// int read_came_from_current;
int* temp;
temp = new int[J / 10 + 1];
#ifdef DEBUG
#ifndef NDEBUG
for (removed = 0; removed < q; removed++)
printf("c_ptr[%d]=%p\n", removed, c_ptr[removed]);
removed = 0;
Expand All @@ -1325,7 +1325,7 @@ ssret* sample_class(unsigned int i, unsigned int step)

remove_comp(&mxt);
removed = 1;
#ifdef DEBUG
#ifndef NDEBUG
printf("----------- REMOVED SIZE 1 NODE ----------\n");
#endif
}
Expand All @@ -1345,7 +1345,7 @@ ssret* sample_class(unsigned int i, unsigned int step)

remove_comp(&(c_ptr[i]->next));
removed = 1;
#ifdef DEBUG
#ifndef NDEBUG
printf("----------- REMOVED SIZE 1 NODE ----------\n");
#endif
}
Expand Down Expand Up @@ -1494,7 +1494,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
} // else P[i] = 0, from above
}

#ifdef DEBUG
#ifndef NDEBUG
for (j = 0; j <= st; j++)
printf("with P[%i] = %e to class %p\n", j, P[j], cl_ptr[j]);
#endif
Expand All @@ -1503,7 +1503,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
this_class = gsl_ran_discrete(rg, g);
gsl_ran_discrete_free(g);

#ifdef DEBUG
#ifndef NDEBUG
printf("extracted class is = %lu\n", this_class);
#endif

Expand All @@ -1517,7 +1517,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
if (removed == 0) {

if (from_class == to_class) {
#ifdef DEBUG
#ifndef NDEBUG
printf("from %p to itself\n", from_class);
#endif

Expand All @@ -1531,7 +1531,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
}

else if (to_class != NULL) {
#ifdef DEBUG
#ifndef NDEBUG
printf("moving the read from %p to %p\n", from_class, to_class);
#endif

Expand All @@ -1553,7 +1553,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
}

else if (to_class == NULL) {
#ifdef DEBUG
#ifndef NDEBUG
printf("moving %i to a new class from %p\n", i, from_class);
#endif

Expand Down Expand Up @@ -1610,7 +1610,7 @@ ssret* sample_class(unsigned int i, unsigned int step)
}

else if (removed == 1) {
#ifdef DEBUG
#ifndef NDEBUG
printf("moving having removed\n");
#endif
if (to_class != NULL) {
Expand Down Expand Up @@ -2129,7 +2129,7 @@ void print_stats(std::ofstream& out_file, const cnode* cn, unsigned int J)

if (p == NULL) out_file << "# no reads in this component\n";

#ifdef DEBUG
#ifndef NDEBUG
if (p != NULL) out_file << "# reads in the list:\t";
#endif

Expand Down
13 changes: 6 additions & 7 deletions src/shorah/freqEst.cpp
Expand Up @@ -49,7 +49,6 @@ typedef struct comp_class

bool comp_func(com_pair* pi, com_pair* pj) { return (pi->freq > pj->freq); }

//#define DEBUG
//#define SEEPROB

int CORRECTPARAM = 1; // which definition of pr(r | h) do we use
Expand Down Expand Up @@ -160,7 +159,7 @@ void getHaplotypes(std::istream& in, std::vector<std::string>& genotypesFinal)
if ((*g)[pos] == '.') {
tmpCount++;
(*g)[pos] = cons[pos];
#ifdef DEBUG
#ifndef NDEBUG
std::cout << "correcting . to " << cons[pos] << " in sequence " << *g << std::endl;
#endif
}
Expand All @@ -180,7 +179,7 @@ void getHaplotypes(std::istream& in, std::vector<std::string>& genotypesFinal)
uniq[*g]++;
}
for (std::map<std::string, int>::iterator x = uniq.begin(); x != uniq.end(); ++x) {
#ifdef DEBUG
#ifndef NDEBUG
std::cout << "Haplotype was repeated " << x->second << " times\n";
#endif
genotypesFinal.push_back(x->first);
Expand Down Expand Up @@ -229,7 +228,7 @@ std::vector<int> countReads(std::vector<Read>& origReads, std::vector<Read>& rea
}
}
}
#ifdef DEBUG
#ifndef NDEBUG
std::cout << "Started with " << origReads.size() << " reads.\n";
std::cout << reads.size() << " are unique\n";
std::cout << "Counts:\n";
Expand All @@ -248,7 +247,7 @@ void Estep(std::vector<double> const& p, std::vector<std::vector<double> >& U,
int i, j;
double ProbY;

#ifdef DEBUG
#ifndef NDEBUG
std::cout << "Estep input: " << std::endl;
for (i = 0; i < N; ++i) {
std::cout << p[i] << " ";
Expand Down Expand Up @@ -298,7 +297,7 @@ void Mstep(std::vector<double>& p, std::vector<std::vector<double> > const& U)
p[j] = v[j] / m;
}

#ifdef DEBUG
#ifndef NDEBUG
for (j = 0; j < N; ++j) {
std::cout << p[j] << " ";
}
Expand Down Expand Up @@ -351,7 +350,7 @@ double EM(std::vector<double>& newP, std::vector<std::vector<double> > const& Z,
p[j] = p[j] / sum;
}

#ifdef DEBUG
#ifndef NDEBUG
for (j = 0; j < N; ++j) {
std::cout << p[j] << " ";
}
Expand Down

0 comments on commit f65568d

Please sign in to comment.