From a3e570dffa9ccc939a170e5cff1285d5b266b4cc Mon Sep 17 00:00:00 2001 From: Kathryn Iverson Date: Mon, 30 Apr 2012 13:00:40 -0400 Subject: [PATCH] removed initmatrix and replaced it with co_matrix. With the re-written command there shouldn't be a need to keep the initial matrix, it's just taking up memory. --- cooccurrencecommand.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp index f1f849a..f9db5be 100644 --- a/cooccurrencecommand.cpp +++ b/cooccurrencecommand.cpp @@ -272,10 +272,8 @@ int CooccurrenceCommand::execute(){ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp, ofstream& out){ try { int numOTUS = thisLookUp[0]->getNumBins(); - vector< vector > initmatrix; initmatrix.resize(thisLookUp.size()); vector< vector > co_matrix; co_matrix.resize(thisLookUp[0]->getNumBins()); for (int i = 0; i < thisLookUp[0]->getNumBins(); i++) { co_matrix[i].resize((thisLookUp.size()), 0); } - for (int i = 0; i < thisLookUp.size(); i++) { initmatrix[i].resize((thisLookUp[i]->getNumBins()), 0); } vector columntotal; columntotal.resize(thisLookUp.size(), 0); vector rowtotal; rowtotal.resize(numOTUS, 0); @@ -285,7 +283,6 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp int abund = thisLookUp[i]->getAbundance(j); if(abund > 0) { - initmatrix[i][j] = 1; co_matrix[j][i] = 1; rowtotal[j]++; columntotal[i]++; @@ -396,11 +393,11 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp } - - if (metric == "cscore") { initscore = trial.calc_c_score(initmatrix, rowtotal, ncols, nrows); } - else if (metric == "checker") { initscore = trial.calc_checker(initmatrix, rowtotal, ncols, nrows); } + //co_matrix is the transposed shared file, initmatrix is the original shared file + if (metric == "cscore") { initscore = trial.calc_c_score(co_matrix, rowtotal, ncols, nrows); } + else if (metric == "checker") { initscore = trial.calc_checker(co_matrix, rowtotal, ncols, nrows); } else if (metric == "vratio") { initscore = trial.calc_vratio(nrows, ncols, rowtotal, columntotal); } - else if (metric == "combo") { initscore = trial.calc_combo(nrows, ncols, initmatrix); } + else if (metric == "combo") { initscore = trial.calc_combo(nrows, ncols, co_matrix); } else { m->mothurOut("[ERROR]: No metric selected!\n"); m->control_pressed = true; return 1; } m->mothurOut("Initial c score: " + toString(initscore)); m->mothurOutEndLine(); @@ -550,7 +547,7 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp //swap_checkerboards takes the original matrix and swaps checkerboards else if(matrix == "sim9") { - trial.swap_checkerboards (initmatrix, rowtotal, columntotal, ncols, nrows); + trial.swap_checkerboards (co_matrix, rowtotal, columntotal, ncols, nrows); } else { m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true; -- 2.39.5