]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed sim4
authorKathryn Iverson <kd.iverson@gmail.com>
Mon, 30 Apr 2012 21:42:39 +0000 (17:42 -0400)
committerKathryn Iverson <kd.iverson@gmail.com>
Mon, 30 Apr 2012 21:42:39 +0000 (17:42 -0400)
cooccurrencecommand.cpp
trialSwap2.cpp
trialswap2.h

index e1d60b7c18553b0d3de4df1e0dd6a87ea60b17af..f0a46aaf9dfc0a729df15549a7d8fecc4c02d52a 100644 (file)
@@ -408,11 +408,11 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
 
         //burn-in for sim9    
         if(matrix == "sim9") {
-            for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, rowtotal, columntotal, ncols, nrows);
+            for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, ncols, nrows);
         }
 
         //populate null matrix from probability matrix, do this a lot.
-        for(int i=0;i<runs;i++){
+        for(int k=0;k<runs;k++){
             nullmatrix.clear();
             //zero-fill the null matrix
             nullmatrix.assign(nrows, vector<int>(ncols, 0));
@@ -450,9 +450,9 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             
             else if(matrix == "sim4") {
                 for(int i=0;i<nrows;i++) {
-                    previous = 0.0;
                     count = 0;
                     while(count < rowtotal[i]) {
+                        previous = 0.0;
                         randnum = rand() / double(RAND_MAX);
                         for(int j=0;j<ncols;j++) {
                             current = probabilityMatrix[ncols * i + j];
@@ -490,7 +490,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
             
             //swap_checkerboards takes the original matrix and swaps checkerboards
             else if(matrix == "sim9") {
-                trial.swap_checkerboards (co_matrix, rowtotal, columntotal, ncols, nrows);
+                trial.swap_checkerboards (co_matrix, ncols, nrows);
             }
             else {
                 m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true;
index c51a5b7c0be1d3048851325da8be9cb26b414949..a0c3210c33dd49c97274b4ad555efe2a75f9fede 100644 (file)
@@ -192,10 +192,10 @@ int TrialSwap2::calc_combo (int nrows, int ncols, vector<vector<int> > &nullmatr
     }
 }
 /**************************************************************************************************/
-int TrialSwap2::swap_checkerboards (vector<vector<int> > &co_matrix,  vector<int> rowtotal, vector<int> columntotal, int ncols, int nrows)
+int TrialSwap2::swap_checkerboards (vector<vector<int> > &co_matrix, int ncols, int nrows)
 {
     try {
-        int ncols = co_matrix[0].size(); int nrows = co_matrix.size();
+        //int ncols = co_matrix[0].size(); int nrows = co_matrix.size();
         int i, j, k, l;
         i = m->getRandomIndex(nrows-1);
         while((j = m->getRandomIndex(nrows-1) ) == i ) {;if (m->control_pressed) { return 0; }}
index 2bd6939482e962ac02332154ce459fac68c644ed..924938b1a16297015a3bdb14d07db0f91fc7b5bc 100644 (file)
@@ -21,7 +21,7 @@ public:
     
     double calc_pvalue_lessthan (vector<double>, double);
     double calc_pvalue_greaterthan (vector<double>, double);
-    void swap_checkerboards (vector<vector<int> > &, vector<int>, vector<int>, int, int);
+    int swap_checkerboards (vector<vector<int> > &, int, int);
     int calc_combo (int, int, vector<vector<int> > &);
     double calc_vratio (int, int, vector<int>, vector<int>);
     int calc_checker (vector<vector<int> > &, vector<int>, int, int);