if (abort == false) {
+ //used in tree constructor
+ globaldata->runParse = false;
+
validCalculator = new ValidCalculators();
int i;
for (int i=0; i < treeCalculators.size(); i++) {
tempo = new ofstream;
out.push_back(tempo);
- }
+ }
+
+ //make a vector of tree* for each calculator
+ trees.resize(treeCalculators.size());
}
}
delete order;
}
-
+
+
+
//reset groups parameter
globaldata->Groups.clear();
}
//**********************************************************************************************************************
-void BootSharedCommand::createTree(ostream* out){
+void BootSharedCommand::createTree(ostream* out, Tree* t){
try {
- //create tree
- t = new Tree();
//do merges and create tree structure by setting parents and children
//there are numGroups - 1 merges to do
for (int i = 0; i < (numGroups - 1); i++) {
- float largest = -1.0;
+ float largest = -1000.0;
int row, column;
//find largest value in sims matrix by searching lower triangle
for (int j = 1; j < simMatrix.size(); j++) {
index[column] = numGroups+i;
//zero out highest value that caused the merge.
- simMatrix[row][column] = -1.0;
- simMatrix[column][row] = -1.0;
+ simMatrix[row][column] = -1000.0;
+ simMatrix[column][row] = -1000.0;
//merge values in simsMatrix
for (int n = 0; n < simMatrix.size(); n++) {
simMatrix[row][n] = (simMatrix[row][n] + simMatrix[column][n]) / 2;
simMatrix[n][row] = simMatrix[row][n];
//delete column
- simMatrix[column][n] = -1.0;
- simMatrix[n][column] = -1.0;
+ simMatrix[column][n] = -1000.0;
+ simMatrix[n][column] = -1000.0;
}
}
+
+ //adjust tree to make sure root to tip length is .5
+ int root = t->findRoot();
+ t->tree[root].setBranchLength((0.5 - t->tree[root].getLengthToLeaves()));
//assemble tree
t->assembleTree();
//print newick file
t->print(*out);
- //delete tree
- delete t;
-
}
catch(exception& e) {
errorOut(e, "BootSharedCommand", "createTree");
EstOutput data;
vector<SharedRAbundVector*> subset;
+
//open an ostream for each calc to print to
for (int z = 0; z < treeCalculators.size(); z++) {
//create a new filename
openOutputFile(outputFile, *(out[z]));
}
+ mothurOut("Generating bootstrap trees..."); cout.flush();
+
//create a file for each calculator with the 1000 trees in it.
for (int p = 0; p < iters; p++) {
- util->getSharedVectorswithReplacement(Groups, lookup, order); //fills group vectors from order vector.
+ util->getSharedVectorswithReplacement(globaldata->Groups, lookup, order); //fills group vectors from order vector.
+
//for each calculator
for(int i = 0 ; i < treeCalculators.size(); i++) {
}
}
}
-
+
+ tempTree = new Tree();
+
//creates tree from similarity matrix and write out file
- createTree(out[i]);
+ createTree(out[i], tempTree);
+
+ //save trees for concensus command.
+ trees[i].push_back(tempTree);
}
}
+
+ mothurOut("\tDone."); mothurOutEndLine();
+ //delete globaldata's tree
+ for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
+ globaldata->clear();
+
+
+ //create concensus trees for each bootstrapped tree set
+ for (int k = 0; k < trees.size(); k++) {
+
+ mothurOut("Generating concensus tree for " + treeCalculators[k]->getName()); mothurOutEndLine();
+
+ //set global data to calc trees
+ globaldata->gTree = trees[k];
+
+ string filename = getRootName(globaldata->inputFileName) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
+ concensus = new ConcensusCommand(filename);
+ concensus->execute();
+ delete concensus;
+
+ //delete globaldata's tree
+ for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
+ globaldata->clear();
+
+ }
+
+
+
//close ostream for each calc
for (int z = 0; z < treeCalculators.size(); z++) { out[z]->close(); }
-
+
}
catch(exception& e) {
errorOut(e, "BootSharedCommand", "process");
#include "tree.h"
#include "treemap.h"
#include "sharedutilities.h"
+#include "concensuscommand.h"
class GlobalData;
void help();
private:
- void createTree(ostream*);
+ void createTree(ostream*, Tree*);
void printSims();
void process(SharedOrderVector*);
ReadOTUFile* read;
TreeMap* tmap;
Tree* t;
+ Tree* tempTree;
+ ConcensusCommand* concensus;
+ vector< vector<Tree*> > trees; //a vector of trees for each calculator chosen
vector<Calculator*> treeCalculators;
vector<ofstream*> out;
vector< vector<float> > simMatrix;
#include "readtreecommand.h"
#include "readotucommand.h"
#include "clustercommand.h"
-#include "parselistcommand.h"
#include "collectcommand.h"
#include "collectsharedcommand.h"
#include "getgroupcommand.h"
#include "getoturepcommand.h"
#include "treegroupscommand.h"
#include "bootstrapsharedcommand.h"
-#include "concensuscommand.h"
+//#include "concensuscommand.h"
#include "distancecommand.h"
#include "aligncommand.h"
#include "matrixoutputcommand.h"
commands["get.sabund"] = "get.sabund";
commands["get.rabund"] = "get.rabund";
commands["bootstrap.shared"] = "bootstrap.shared";
- commands["concensus"] = "concensus";
+ //commands["concensus"] = "concensus";
commands["help"] = "help";
commands["filter.seqs"] = "filter.seqs";
commands["align.seqs"] = "align.seqs";
else if(commandName == "tree.shared") { command = new TreeGroupCommand(optionString); }
else if(commandName == "dist.shared") { command = new MatrixOutputCommand(optionString); }
else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(optionString); }
- else if(commandName == "concensus") { command = new ConcensusCommand(optionString); }
+ //else if(commandName == "concensus") { command = new ConcensusCommand(optionString); }
else if(commandName == "dist.seqs") { command = new DistanceCommand(optionString); }
else if(commandName == "align.seqs") { command = new AlignCommand(optionString); }
else if(commandName == "summary.seqs") { command = new SeqSummaryCommand(optionString); }
//**********************************************************************************************************************
-ConcensusCommand::ConcensusCommand(string option){
+ConcensusCommand::ConcensusCommand(string fileroot){
try {
globaldata = GlobalData::getInstance();
abort = false;
+ filename = fileroot;
//allow user to run help
- if(option == "help") { help(); abort = true; }
+ //if(option == "help") { help(); abort = true; }
- else {
- if (option != "") { mothurOut("There are no valid parameters for the concensus command."); mothurOutEndLine(); abort = true; }
+ //else {
+ //if (option != "") { mothurOut("There are no valid parameters for the concensus command."); mothurOutEndLine(); abort = true; }
- //no trees were read
- if (globaldata->gTree.size() == 0) { mothurOut("You must execute the read.tree command, before you may use the concensus command."); mothurOutEndLine(); abort = true; }
- else { t = globaldata->gTree; }
- }
+ // //no trees were read
+ // if (globaldata->gTree.size() == 0) { mothurOut("You must execute the read.tree command, before you may use the concensus command."); mothurOutEndLine(); abort = true; }
+ //else {
+ t = globaldata->gTree;
+ // }
+ //}
}
catch(exception& e) {
errorOut(e, "ConcensusCommand", "ConcensusCommand");
getSets();
//open file for pairing not included in the tree
- notIncluded = getRootName(globaldata->inputFileName) + "concensuspairs";
+ notIncluded = filename + ".concensuspairs";
openOutputFile(notIncluded, out2);
concensusTree = new Tree();
out2 << '\t' << it2->second << endl;
}
- outputFile = getRootName(globaldata->inputFileName) + "concensus.tre";
+ outputFile = filename + ".cons.tre";
openOutputFile(outputFile, out);
concensusTree->printForBoot(out);
map< vector<string>, int > nodePairsInTree;
map<string, int>::iterator it;
map< vector<string>, int>::iterator it2;
- string outputFile, notIncluded;
+ string outputFile, notIncluded, filename;
ofstream out, out2;
int numNodes, numLeaves, count; //count is the next available spot in the tree vector
globaldata = GlobalData::getInstance();
globaldata->argv = path;
- system("clear");
+
}
/***********************************************************************/
openedBatch = openInputFile(batchFileName, inputBatchFile);
globaldata->argv = path;
- system("clear");
+
// char buffer = ' ';
// ifstream header("introtext.txt");
globaldata->argv = path;
- system("clear");
+
}
catch(exception& e) {
int main(int argc, char *argv[]){
try {
+ system("clear");
+
//remove old logfile
string logFileName = "mothur.logFile";
remove(logFileName.c_str());
return output.str();
}
-
/***********************************************************************/
inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
fileHandle.open(fileName.c_str(), ios::app);
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ cout << "Error: Could not open " << fileName << endl;
return 1;
}
else {
}
-
/**************************************************************************************************/
inline void mothurOut(string message) {
}
+
+
/***********************************************************************/
inline void gobble(istream& f){
fileHandle.open(fileName.c_str());
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ mothurOut("Error: Could not open " + fileName); mothurOutEndLine();
return 1;
}
else {
fileHandle.open(fileName.c_str(), ios::trunc);
if(!fileHandle) {
- cerr << "Error: Could not open " << fileName << endl;
+ mothurOut("Error: Could not open " + fileName); mothurOutEndLine();
return 1;
}
else {
lastLabel = lookup[0]->getLabel();
if (lookup.size() < 2) { mothurOut("You have not provided enough valid groups. I cannot run the command."); mothurOutEndLine(); return 0; }
-
+
+ //used in tree constructor
globaldata->runParse = false;
//create tree file
//fills globaldatas tree names
globaldata->Treenames = globaldata->Groups;
+ //used in tree constructor
globaldata->runParse = false;
makeSimsDist();