+
+ #endif
+
+
+ if (mout->control_pressed) { input = "quit()"; }
+
+ //allow user to omit the () on the quit command
+ if (input == "quit") { input = "quit()"; }
+
+ CommandOptionParser parser(input);
+ commandName = parser.getCommandString();
+ options = parser.getOptionString();
+
+ if (commandName != "") {
+ mout->executing = true;
+ #ifdef USE_MPI
+ int pid, numProcesses;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+ MPI_Comm_size(MPI_COMM_WORLD, &numProcesses);
+
+//cout << pid << " is here " << commandName << endl;
+ if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
+ //cout << pid << " is in execute" << endl;
+ #endif
+ //executes valid command
+ mout->changedSeqNames = false;
+ mout->runParse = true;
+ mout->clearGroups();
+ mout->clearAllGroups();
+ mout->Treenames.clear();
+ mout->saveNextLabel = "";
+ mout->printedHeaders = false;
+ mout->commandInputsConvertError = false;
+ mout->currentBinLabels.clear();
+ mout->binLabelsInFile.clear();
+
+ Command* command = cFactory->getCommand(commandName, options);
+ if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
+ else { quitCommandCalled = command->execute(); }
+
+ //if we aborted command
+ if (quitCommandCalled == 2) { mout->mothurOut("[ERROR]: did not complete " + commandName + "."); mout->mothurOutEndLine(); }
+
+ mout->control_pressed = 0;
+ mout->executing = false;
+
+ #ifdef USE_MPI
+ //cout << pid << " is done in execute" << endl;
+ }
+ #endif
+ }else {
+ mout->mothurOut("Invalid.");
+ mout->mothurOutEndLine();
+ }
+
+
+ }
+
+ return 1;
+ }
+ catch(exception& e) {
+ mout->errorOut(e, "ScriptEngine", "getInput");
+ exit(1);
+ }
+}
+/***********************************************************************/
+string ScriptEngine::getNextCommand(string& commandString) {
+ try {
+
+ string nextcommand = "";
+ int count = 0;
+ bool ignoreSemiColons = false;
+
+ //go through string until you reach ; or end
+ while (count < commandString.length()) {
+
+ //you want to ignore any ; until you reach the next '
+ if ((commandString[count] == '\'') && (!ignoreSemiColons)) { ignoreSemiColons = true; }
+ else if ((commandString[count] == '\'') && (ignoreSemiColons)) { ignoreSemiColons = false; }
+
+ if ((commandString[count] == ';') && (!ignoreSemiColons)) { break; }
+ else { nextcommand += commandString[count]; }
+
+ count++;
+ }
+
+ //if you are not at the end
+ if (count != commandString.length()) { commandString = commandString.substr(count+1, commandString.length()); }
+ else { commandString = ""; }
+
+
+ //get rid of spaces in between commands if any
+ if (commandString.length() > 0) {
+ while (commandString[0] == ' ') {
+ commandString = commandString.substr(1,commandString.length());
+ if (commandString.length() == 0) { break; }
+ }
+ }
+
+ return nextcommand;
+ }
+ catch(exception& e) {
+ mout->errorOut(e, "ScriptEngine", "getNextCommand");
+ exit(1);
+ }
+}
+/***********************************************************************/