From: westcott Date: Tue, 1 Jun 2010 15:44:15 +0000 (+0000) Subject: changed the daughterLevels in classifiers summary file to reflect the classifications... X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=7837a9bfdfccdc26360987a44c389832fdb82651 changed the daughterLevels in classifiers summary file to reflect the classifications only the classifications in the query file. --- diff --git a/engine.cpp b/engine.cpp index acd417c..2ed819f 100644 --- a/engine.cpp +++ b/engine.cpp @@ -71,12 +71,6 @@ bool InteractEngine::getInput(){ #ifdef USE_MPI int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); - - if ((pid != 0) && !(cFactory->MPIEnabled(commandName))) { -cout << pid << " is waiting " << commandName << endl; - char buf[4]; - MPI_Bcast(buf, 4, MPI_CHAR, 0, MPI_COMM_WORLD); //make everyone wait - just in case - } cout << pid << " is here " << commandName << endl; if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { @@ -88,13 +82,6 @@ cout << pid << " is here " << commandName << endl; mout->executing = false; #ifdef USE_MPI - if (!(cFactory->MPIEnabled(commandName))) { - char buf[4]; - strcpy(buf, "done"); - - MPI_Bcast(buf, 4, MPI_CHAR, 0, MPI_COMM_WORLD); //make everyone wait - just in case - cout << pid << " is broadcasting " << endl; - } } #endif }else { @@ -112,6 +99,10 @@ cout << pid << " is here " << commandName << endl; /***********************************************************************/ string Engine::getCommand() { try { + #ifdef USE_MPI + MPI_Barrier(MPI_COMM_WORLD); + #endif + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #ifdef USE_READLINE char* nextCommand = NULL; @@ -187,11 +178,11 @@ bool BatchEngine::getInput(){ //CommandFactory cFactory; int quitCommandCalled = 0; - + int count = 0; while(quitCommandCalled == 0){ - if (inputBatchFile.eof()) { input = "quit()"; } - else { input = getline(inputBatchFile); } + input = getNextCommand(inputBatchFile); + count++; if (input[0] != '#') { @@ -214,13 +205,7 @@ bool BatchEngine::getInput(){ int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); - if ((pid != 0) && !(cFactory->MPIEnabled(commandName))) { -cout << pid << " is waiting " << commandName << endl; - char buf[4]; - MPI_Bcast(buf, 4, MPI_CHAR, 0, MPI_COMM_WORLD); //make everyone wait - just in case - } - -cout << pid << " is here " << commandName << endl; +cout << pid << " is here " << commandName << '\t' << count << endl; if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { #endif //executes valid command @@ -230,13 +215,6 @@ cout << pid << " is here " << commandName << endl; mout->executing = false; #ifdef USE_MPI - if (!(cFactory->MPIEnabled(commandName))) { - char buf[4]; - strcpy(buf, "done"); - - MPI_Bcast(buf, 4, MPI_CHAR, 0, MPI_COMM_WORLD); //make everyone wait - just in case - cout << pid << " is broadcasting " << endl; - } } #endif }else { @@ -256,7 +234,27 @@ cout << pid << " is here " << commandName << endl; exit(1); } } - +/***********************************************************************/ +string BatchEngine::getNextCommand(ifstream& inputBatchFile) { + try { + + #ifdef USE_MPI + int err = MPI_Barrier(MPI_COMM_WORLD); +//cout << "barrier = " << err << '\t' << MPI_SUCCESS << endl; + #endif + + string nextcommand = ""; + + if (inputBatchFile.eof()) { nextcommand = "quit()"; } + else { nextcommand = getline(inputBatchFile); } + + return nextcommand; + } + catch(exception& e) { + mout->errorOut(e, "BatchEngine", "getNextCommand"); + exit(1); + } +} /***********************************************************************/ /***********************************************************************/ @@ -318,20 +316,9 @@ bool ScriptEngine::getInput(){ #ifdef USE_MPI int pid, numProcesses; MPI_Status status; - //MPI_Request request; MPI_Comm_rank(MPI_COMM_WORLD, &pid); MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); - - if ((pid != 0) && (!(cFactory->MPIEnabled(commandName)))) { -cout << pid << " is waiting " << commandName << endl; - char buf[12]; - - MPI_Recv(buf, 12, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status); //make everyone wait - just in case - //MPI_Wait(&request, &status); - cout << pid << " received " << buf << endl; - } - cout << pid << " is here " << commandName << endl; if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { @@ -345,17 +332,6 @@ cout << pid << " is here " << commandName << endl; #ifdef USE_MPI cout << pid << " is done in execute" << endl; - if ((pid == 0) && (!(cFactory->MPIEnabled(commandName)))) { - char buf[12]; - strcpy(buf, "command done"); - - for(int i = 1; i < numProcesses; i++) { - MPI_Send(buf, 12, MPI_CHAR, i, 2001, MPI_COMM_WORLD); //make everyone wait - just in case - //MPI_Wait(&request, &status); - cout << pid << " sent " << buf << endl; - } - cout << pid << " is sending " << endl; - } } #endif }else { @@ -378,8 +354,7 @@ string ScriptEngine::getNextCommand(string& commandString) { try { #ifdef USE_MPI - int ierr = MPI_Barrier(MPI_COMM_WORLD); -cout << "barrier = " << ierr << endl; + MPI_Barrier(MPI_COMM_WORLD); #endif string nextcommand = ""; diff --git a/engine.hpp b/engine.hpp index 0020a7f..0e7721a 100644 --- a/engine.hpp +++ b/engine.hpp @@ -49,6 +49,7 @@ public: private: GlobalData* globaldata; ifstream inputBatchFile; + string getNextCommand(ifstream&); }; diff --git a/makefile b/makefile index f50b554..0c5adac 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,7 @@ ifeq ($(strip $(USEREADLINE)),yes) -L../readline-6.0 endif -USEMPI ?= no +USEMPI ?= yes ifeq ($(strip $(USEMPI)),yes) CC = mpic++ diff --git a/phylosummary.cpp b/phylosummary.cpp index 5612d7b..84b0861 100644 --- a/phylosummary.cpp +++ b/phylosummary.cpp @@ -179,8 +179,15 @@ void PhyloSummary::print(ofstream& out){ out << endl; + int totalChildrenInTree = 0; + + map::iterator it; + for(it=tree[0].children.begin();it!=tree[0].children.end();it++){ + if (tree[it->second].total != 0) { totalChildrenInTree++; } + } + //print root - out << tree[0].level << "\t" << tree[0].rank << "\t" << tree[0].name << "\t" << tree[0].children.size() << "\t" << tree[0].total << "\t"; + out << tree[0].level << "\t" << tree[0].rank << "\t" << tree[0].name << "\t" << totalChildrenInTree << "\t" << tree[0].total << "\t"; map::iterator itGroup; if (groupmap != NULL) { @@ -208,7 +215,15 @@ void PhyloSummary::print(int i, ofstream& out){ for(it=tree[i].children.begin();it!=tree[i].children.end();it++){ if (tree[it->second].total != 0) { - out << tree[it->second].level << "\t" << tree[it->second].rank << "\t" << tree[it->second].name << "\t" << tree[it->second].children.size() << "\t" << tree[it->second].total << "\t"; + + int totalChildrenInTree = 0; + + map::iterator it2; + for(it2=tree[it->second].children.begin();it2!=tree[it->second].children.end();it2++){ + if (tree[it2->second].total != 0) { totalChildrenInTree++; } + } + + out << tree[it->second].level << "\t" << tree[it->second].rank << "\t" << tree[it->second].name << "\t" << totalChildrenInTree << "\t" << tree[it->second].total << "\t"; map::iterator itGroup; if (groupmap != NULL) {