From 4418e128575c1d667720090d7b45d9b48de81a3a Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Tue, 1 May 2012 08:17:42 -0400 Subject: [PATCH] fixed bug in rarefaction.single creating the groups file. working on cooccurrence command --- cooccurrencecommand.cpp | 10 +++++++--- rarefactcommand.cpp | 18 ++++++++++-------- trialswap2.h | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp index b4965f5..45bc0f5 100644 --- a/cooccurrencecommand.cpp +++ b/cooccurrencecommand.cpp @@ -318,7 +318,7 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp } } //don't need a prob matrix because we just shuffle the rows, may use this in the future -// else if (matrix == "sim2") { + else if (matrix == "sim2") { } // for(int i=0;i& thisLookUp } //populate null matrix from probability matrix, do this a lot. - for(int i=0;i(ncols, 0)); @@ -420,6 +420,7 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp if(matrix == "sim1" || matrix == "sim6" || matrix == "sim8" || matrix == "sim7") { count = 0; while(count < n) { + if (m->control_pressed) { return 0; } nextnum2: previous = 0.0; randnum = rand() / double(RAND_MAX); @@ -453,10 +454,12 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp previous = 0.0; count = 0; while(count < rowtotal[i]) { + previous = 0.0; + if (m->control_pressed) { return 0; } randnum = rand() / double(RAND_MAX); for(int j=0;j previous && nullmatrix[i][j] != 1) { + if((randnum <= current && randnum > previous && nullmatrix[i][j] != 1) || (previous==current)){ nullmatrix[i][j] = 1; count++; previous = 0.0; @@ -473,6 +476,7 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp for(int j=0;jcontrol_pressed) { return 0; } randnum = rand() / double(RAND_MAX); for(int i=0;i RareFactCommand::createGroupFile(vector& outputNames, map //find different types of files map > typesFiles; - map temp; for (int i = 0; i < outputNames.size(); i++) { string extension = m->getExtension(outputNames[i]); @@ -485,9 +484,15 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map string newLine = labels.substr(0, labels.find_first_of('\t')); newLine += "\tGroup" + labels.substr(labels.find_first_of('\t')); - - temp[outputNames[i]] = file2Group[i]; - typesFiles[extension] = temp; + + map >::iterator itfind = typesFiles.find(extension); + if (itfind != typesFiles.end()) { + (itfind->second)[outputNames[i]] = file2Group[i]; + }else { + map temp; + temp[outputNames[i]] = file2Group[i]; + typesFiles[extension] = temp; + } string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + extension; @@ -507,7 +512,6 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + it->first; m->openOutputFileAppend(combineFileName, out); newFileNames.push_back(combineFileName); - map thisTypesFiles = it->second; //open each type summary file @@ -518,7 +522,7 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map string thisfilename = itFileNameGroup->first; string group = itFileNameGroup->second; - + ifstream temp; m->openInputFile(thisfilename, temp); @@ -541,7 +545,6 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map count++; thisFilesLines.push_back(thisLine); - m->gobble(temp); } @@ -562,7 +565,6 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map for (map::iterator itFileNameGroup = thisTypesFiles.begin(); itFileNameGroup != thisTypesFiles.end(); itFileNameGroup++) { string thisfilename = itFileNameGroup->first; - map::iterator itLine = lineToNumber.find(k); if (itLine != lineToNumber.end()) { string output = toString(itLine->second); diff --git a/trialswap2.h b/trialswap2.h index 2bd6939..4c03278 100644 --- a/trialswap2.h +++ b/trialswap2.h @@ -21,7 +21,7 @@ public: double calc_pvalue_lessthan (vector, double); double calc_pvalue_greaterthan (vector, double); - void swap_checkerboards (vector > &, vector, vector, int, int); + int swap_checkerboards (vector > &, vector, vector, int, int); int calc_combo (int, int, vector > &); double calc_vratio (int, int, vector, vector); int calc_checker (vector > &, vector, int, int); -- 2.39.2