objects = {
/* Begin PBXBuildFile section */
+ 211C38320F961DD400FEE541 /* sharedutilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 211C38300F961DD400FEE541 /* sharedutilities.cpp */; };
+ 211C38380F961E1F00FEE541 /* treegroupscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 211C38360F961E1F00FEE541 /* treegroupscommand.cpp */; };
+ 21DDC01B0F97A8FE0060691C /* bootstrapsharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21DDC01A0F97A8FE0060691C /* bootstrapsharedcommand.cpp */; };
370B88070F8A4EE4005AB382 /* getoturepcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 370B88060F8A4EE4005AB382 /* getoturepcommand.cpp */; };
372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E126F0F26365B0095CF7E /* readotucommand.cpp */; };
372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12950F263D5A0095CF7E /* readdistcommand.cpp */; };
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 211C38300F961DD400FEE541 /* sharedutilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedutilities.cpp; sourceTree = "<group>"; };
+ 211C38310F961DD400FEE541 /* sharedutilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedutilities.h; sourceTree = "<group>"; };
+ 211C38360F961E1F00FEE541 /* treegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treegroupscommand.cpp; sourceTree = "<group>"; };
+ 211C38370F961E1F00FEE541 /* treegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treegroupscommand.h; sourceTree = "<group>"; };
+ 21DDC0190F97A8FE0060691C /* bootstrapsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootstrapsharedcommand.h; sourceTree = "<group>"; };
+ 21DDC01A0F97A8FE0060691C /* bootstrapsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bootstrapsharedcommand.cpp; sourceTree = "<group>"; };
370B88050F8A4EE4005AB382 /* getoturepcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getoturepcommand.h; sourceTree = "<group>"; };
370B88060F8A4EE4005AB382 /* getoturepcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getoturepcommand.cpp; sourceTree = "<group>"; };
372E126E0F26365B0095CF7E /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotucommand.h; sourceTree = "<group>"; };
37D928490F21331F001D4494 /* summarydisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarydisplay.h; sourceTree = "<group>"; };
37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summarysharedcommand.cpp; sourceTree = "<group>"; };
37D9284B0F21331F001D4494 /* summarysharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarysharedcommand.h; sourceTree = "<group>"; };
- 37D9284C0F21331F001D4494 /* utilities.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utilities.hpp; sourceTree = "<group>"; };
37D9284D0F21331F001D4494 /* uvest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uvest.cpp; sourceTree = "<group>"; };
37D9284E0F21331F001D4494 /* uvest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uvest.h; sourceTree = "<group>"; };
37D9284F0F21331F001D4494 /* validcalculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validcalculator.cpp; sourceTree = "<group>"; };
37D9281C0F21331F001D4494 /* sequence.cpp */,
37D928210F21331F001D4494 /* shared.h */,
37D928200F21331F001D4494 /* shared.cpp */,
+ 211C38310F961DD400FEE541 /* sharedutilities.h */,
+ 211C38300F961DD400FEE541 /* sharedutilities.cpp */,
37D928420F21331F001D4494 /* singlelinkage.cpp */,
37D928480F21331F001D4494 /* summarydata.h */,
37D928490F21331F001D4494 /* summarydisplay.h */,
- 37D9284C0F21331F001D4494 /* utilities.hpp */,
37519AB30F810FAE00FED5E8 /* venn.h */,
37519AB40F810FAE00FED5E8 /* venn.cpp */,
);
37D927CD0F21331F001D4494 /* command.hpp */,
37C1D9710F86506E0059E3F0 /* binsequencecommand.h */,
37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */,
+ 21DDC0190F97A8FE0060691C /* bootstrapsharedcommand.h */,
+ 21DDC01A0F97A8FE0060691C /* bootstrapsharedcommand.cpp */,
37D927C40F21331F001D4494 /* clustercommand.h */,
37D927C30F21331F001D4494 /* clustercommand.cpp */,
37D927C80F21331F001D4494 /* collectcommand.h */,
37D928460F21331F001D4494 /* summarycommand.cpp */,
37D9284B0F21331F001D4494 /* summarysharedcommand.h */,
37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */,
+ 211C38370F961E1F00FEE541 /* treegroupscommand.h */,
+ 211C38360F961E1F00FEE541 /* treegroupscommand.cpp */,
3746109B0F40657600460C57 /* unifracunweightedcommand.h */,
3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */,
374610760F40645300460C57 /* unifracweightedcommand.h */,
7E412F490F8D21B600381DD0 /* slibshuff.cpp in Sources */,
7E412FEA0F8D3E2C00381DD0 /* libshuff.cpp in Sources */,
7E4130F80F8E58FA00381DD0 /* dlibshuff.cpp in Sources */,
+ 211C38320F961DD400FEE541 /* sharedutilities.cpp in Sources */,
+ 211C38380F961E1F00FEE541 /* treegroupscommand.cpp in Sources */,
+ 21DDC01B0F97A8FE0060691C /* bootstrapsharedcommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
--- /dev/null
+/*
+ * bootstrapsharedcommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 4/16/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "bootstrapsharedcommand.h"
+#include "sharedjabund.h"
+#include "sharedsorabund.h"
+#include "sharedjclass.h"
+#include "sharedsorclass.h"
+#include "sharedjest.h"
+#include "sharedsorest.h"
+#include "sharedthetayc.h"
+#include "sharedthetan.h"
+#include "sharedmorisitahorn.h"
+
+
+//**********************************************************************************************************************
+
+BootSharedCommand::BootSharedCommand(){
+ try {
+ globaldata = GlobalData::getInstance();
+ format = globaldata->getFormat();
+ convert(globaldata->getIters(), iters);
+ validCalculator = new ValidCalculators();
+ util = new SharedUtil();
+
+
+ int i;
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("boot", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "jabund") {
+ treeCalculators.push_back(new JAbund());
+ }else if (globaldata->Estimators[i] == "sorensonabund") {
+ treeCalculators.push_back(new SorAbund());
+ }else if (globaldata->Estimators[i] == "jclass") {
+ treeCalculators.push_back(new Jclass());
+ }else if (globaldata->Estimators[i] == "sorclass") {
+ treeCalculators.push_back(new SorClass());
+ }else if (globaldata->Estimators[i] == "jest") {
+ treeCalculators.push_back(new Jest());
+ }else if (globaldata->Estimators[i] == "sorest") {
+ treeCalculators.push_back(new SorEst());
+ }else if (globaldata->Estimators[i] == "thetayc") {
+ treeCalculators.push_back(new ThetaYC());
+ }else if (globaldata->Estimators[i] == "thetan") {
+ treeCalculators.push_back(new ThetaN());
+ }else if (globaldata->Estimators[i] == "morisitahorn") {
+ treeCalculators.push_back(new MorHorn());
+ }
+ }
+ }
+
+ ofstream* temp;
+ for (int i=0; i < treeCalculators.size(); i++) {
+ temp = new ofstream;
+ out.push_back(temp);
+ }
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function BootSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the BootSharedCommand class function BootSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+BootSharedCommand::~BootSharedCommand(){
+ delete input;
+ delete read;
+ delete util;
+}
+
+//**********************************************************************************************************************
+
+int BootSharedCommand::execute(){
+ try {
+ int count = 1;
+ EstOutput data;
+
+ //if the users entered no valid calculators don't execute command
+ if (treeCalculators.size() == 0) { return 0; }
+
+ if (format == "sharedfile") {
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }
+
+ //set users groups
+ util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "treegroup");
+ numGroups = globaldata->Groups.size();
+
+ //clear globaldatas old tree names if any
+ globaldata->Treenames.clear();
+
+ //fills globaldatas tree names
+ globaldata->Treenames = globaldata->Groups;
+
+ //create treemap class from groupmap for tree class to use
+ tmap = new TreeMap();
+ tmap->makeSim(globaldata->gGroupmap);
+ globaldata->gTreemap = tmap;
+
+ while(order != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+
+ cout << order->getLabel() << '\t' << count << endl;
+
+ //open an ostream for each calc to print to
+ for (int z = 0; z < treeCalculators.size(); z++) {
+ //create a new filename
+ outputFile = getRootName(globaldata->inputFileName) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
+ openOutputFile(outputFile, *(out[z]));
+ }
+
+ //create a file for each calculator with the 1000 trees in it.
+ for (int p = 0; p < iters; p++) {
+
+ util->getSharedVectorswithReplacement(globaldata->Groups, lookup, order); //fills group vectors from order vector.
+
+ //for each calculator
+ for(int i = 0 ; i < treeCalculators.size(); i++) {
+
+ //initialize simMatrix
+ simMatrix.clear();
+ simMatrix.resize(numGroups);
+ for (int m = 0; m < simMatrix.size(); m++) {
+ for (int j = 0; j < simMatrix.size(); j++) {
+ simMatrix[m].push_back(0.0);
+ }
+ }
+
+ //initialize index
+ index.clear();
+ for (int g = 0; g < numGroups; g++) { index[g] = g; }
+
+ for (int k = 0; k < lookup.size(); k++) { // pass cdd each set of groups to commpare
+ for (int l = k; l < lookup.size(); l++) {
+ if (k != l) { //we dont need to similiarity of a groups to itself
+ //get estimated similarity between 2 groups
+ data = treeCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
+ //save values in similarity matrix
+ simMatrix[k][l] = data[0];
+ simMatrix[l][k] = data[0];
+ }
+ }
+ }
+
+ //creates tree from similarity matrix and write out file
+ createTree(out[i]);
+ }
+ }
+ //close ostream for each calc
+ for (int z = 0; z < treeCalculators.size(); z++) { out[z]->close(); }
+ }
+
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
+ }else {
+ break;
+ }
+ }
+ count++;
+ }
+
+ //reset groups parameter
+ globaldata->Groups.clear(); globaldata->setGroups("");
+
+ return 0;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the BootSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+void BootSharedCommand::createTree(ostream* out){
+ 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 = 0.0;
+ int row, column;
+ //find largest value in sims matrix by searching lower triangle
+ for (int j = 1; j < simMatrix.size(); j++) {
+ for (int k = 0; k < j; k++) {
+ if (simMatrix[j][k] > largest) { largest = simMatrix[j][k]; row = j; column = k; }
+ }
+ }
+
+ //set non-leaf node info and update leaves to know their parents
+ //non-leaf
+ t->tree[numGroups + i].setChildren(index[row], index[column]);
+
+ //parents
+ t->tree[index[row]].setParent(numGroups + i);
+ t->tree[index[column]].setParent(numGroups + i);
+
+ //blength = distance / 2;
+ float blength = ((1.0 - largest) / 2);
+
+ //branchlengths
+ t->tree[index[row]].setBranchLength(blength - t->tree[index[row]].getLengthToLeaves());
+ t->tree[index[column]].setBranchLength(blength - t->tree[index[column]].getLengthToLeaves());
+
+ //set your length to leaves to your childs length plus branchlength
+ t->tree[numGroups + i].setLengthToLeaves(t->tree[index[row]].getLengthToLeaves() + t->tree[index[row]].getBranchLength());
+
+
+ //update index
+ index[row] = numGroups+i;
+ index[column] = numGroups+i;
+
+ //zero out highest value that caused the merge.
+ simMatrix[row][column] = 0.0;
+ simMatrix[column][row] = 0.0;
+
+ //merge values in simsMatrix
+ for (int n = 0; n < simMatrix.size(); n++) {
+ //row becomes merge of 2 groups
+ simMatrix[row][n] = (simMatrix[row][n] + simMatrix[column][n]) / 2;
+ simMatrix[n][row] = simMatrix[row][n];
+ //delete column
+ simMatrix[column][n] = 0.0;
+ simMatrix[n][column] = 0.0;
+ }
+ }
+
+ //assemble tree
+ t->assembleTree();
+
+ //print newick file
+ t->print(*out);
+
+ //delete tree
+ delete t;
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the BootSharedCommand class function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************/
+void BootSharedCommand::printSims() {
+ try {
+ cout << "simsMatrix" << endl;
+ for (int m = 0; m < simMatrix.size(); m++) {
+ for (int n = 0; n < simMatrix.size(); n++) {
+ cout << simMatrix[m][n] << '\t';
+ }
+ cout << endl;
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the BootSharedCommand class Function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the BootSharedCommand class function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************/
+
+
--- /dev/null
+#ifndef BOOTSTRAPSHAREDCOMMAND_H
+#define BOOTSTRAPSHAREDCOMMAND_H
+
+/*
+ * bootstrapsharedcommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 4/16/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+#include "sharedordervector.h"
+#include "sharedlistvector.h"
+#include "inputdata.h"
+#include "groupmap.h"
+#include "readmatrix.hpp"
+#include "validcalculator.h"
+#include "tree.h"
+#include "treemap.h"
+#include "sharedutilities.h"
+
+class GlobalData;
+
+class BootSharedCommand : public Command {
+
+public:
+ BootSharedCommand();
+ ~BootSharedCommand();
+ int execute();
+
+private:
+ void createTree(ostream*);
+ void printSims();
+
+ GlobalData* globaldata;
+ SharedUtil* util;
+ ReadMatrix* read;
+ TreeMap* tmap;
+ Tree* t;
+ vector<Calculator*> treeCalculators;
+ vector<ofstream*> out;
+ vector< vector<float> > simMatrix;
+ map<int, int> index; //maps row in simMatrix to vector index in the tree
+ InputData* input;
+ ValidCalculators* validCalculator;
+ SharedListVector* SharedList;
+ SharedOrderVector* order;
+ vector<SharedRAbundVector*> lookup;
+ string format, outputFile;
+ int numGroups, iters;
+
+};
+
+
+#endif
+
+
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
#include "binsequencecommand.h"
#include "getoturepcommand.h"
#include "treegroupscommand.h"
+#include "bootstrapsharedcommand.h"
/***********************************************************/
else if(commandName == "venn") { command = new VennCommand(); }
else if(commandName == "bin.seqs") { command = new BinSeqCommand(); }
else if(commandName == "get.oturep") { command = new GetOTURepCommand(); }
- else if(commandName == "tree.groups") { command = new TreeGroupCommand(); }
+ else if(commandName == "tree.shared") { command = new TreeGroupCommand(); }
+ else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(); }
else { command = new NoCommand(); }
return command;
if (parameter == "abund" ) { abund = value; }
if (parameter == "random" ) { randomtree = value; }
if (parameter == "sorted" ) { sorted = value; }
- if (parameter == "scaler" ) { scaler = value; }
+ if (parameter == "scale" ) { scale = value; }
}
if (parameter == "random" ) { randomtree = value; }
if (parameter == "abund" ) { abund = value; }
if (parameter == "sorted" ) { sorted = value; }
- if (parameter == "scaler" ) { scaler = value; }
+ if (parameter == "scale" ) { scale = value; }
}
}
if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single, rarefaction.single or summary.single commands." << endl; return false; }
}
- if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.groups") ){
+ if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.shared") || (commandName == "bootstrap.shared")){
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared or tree.groups commands." << endl; return false; }
- else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared or tree.groups commands." << endl; return false; }
+ if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
+ else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
}
}
void clear();
void refresh();
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, cutoff, format;
- string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, scaler;
+ string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, scale;
string commandName, optionText;
bool errorFree;
renameOk = rename(outName.c_str(), inName.c_str());
//checks to make sure user was able to rename and remove successfully
- if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; }
+ if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; cout << outName << " g " << inName << endl;}
}
catch(exception& e) {
/***********************************************************************/
/***********************************************************************/
-ThreeColumnFile2::~ThreeColumnFile2(){
+ColumnFile::~ColumnFile(){
inFile.close();
outFile.close();
/***********************************************************************/
-void ThreeColumnFile2::initFile(string label, vector<string> tags){
+void ColumnFile::initFile(string label, vector<string> tags){
try {
if(counter != 0){
openOutputFile(outName, outFile);
getline(inFile, inputBuffer);
outFile << inputBuffer << '\t';
- for(int i = 1; i < tags.size(); i++) {
+ for(int i = 0; i < tags.size(); i++) {
outFile << label + tags[i] << '\t';
}
outFile << endl;
outFile << label + tags[i] << '\t';
}
outFile << endl;
-
}
outFile.setf(ios::fixed, ios::floatfield);
outFile.setf(ios::showpoint);
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
catch(...) {
- cout << "An unknown error has occurred in the ThreeColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "An unknown error has occurred in the ColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
}
/***********************************************************************/
-void ThreeColumnFile2::output(vector<double> data){
+void ColumnFile::output(vector<double> data){
try {
if(counter != 0){
string inputBuffer;
getline(inFile, inputBuffer);
- outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
+ outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length());
+ for (int i = 1; i< data.size(); i++) {
+ outFile << '\t' << data[i];
+ }
+ outFile << endl;
}
else{
- outFile << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
-
+ outFile << setprecision(6) << data[0] << setprecision(globaldata->getIters().length());
+ for (int i = 1; i< data.size(); i++) {
+ outFile << '\t' << data[i];
+ }
+ outFile << endl;
}
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile2 class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
catch(...) {
- cout << "An unknown error has occurred in the ThreeColumnFile2 class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "An unknown error has occurred in the ColumnFile class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
};
/***********************************************************************/
-void ThreeColumnFile2::resetFile(){
+void ColumnFile::resetFile(){
try {
if(counter != 0){
outFile.close();
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile2 class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "Standard Error: " << e.what() << " has occurred in the ColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
catch(...) {
- cout << "An unknown error has occurred in the ThreeColumnFile2 class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ cout << "An unknown error has occurred in the ColumnFile class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
}
public:
FileOutput(){};
~FileOutput(){};
- virtual void output(int, vector<double>) = 0;
+
virtual void initFile(string) = 0;
- virtual void resetFile() = 0;
- virtual string getFileName() = 0;
virtual void initFile(string, vector<string>) = 0;
+ virtual void output(int, vector<double>) = 0;
virtual void output(vector<double>) = 0;
+ virtual void resetFile() = 0;
+ virtual string getFileName() = 0;
protected:
GlobalData* globaldata;
void resetFile();
string getFileName() { return inName; };
- void initFile(string, vector<string>) {};
+ void initFile(string, vector<string>){};
void output(vector<double>) {};
private:
/***********************************************************************/
-class ThreeColumnFile2 : public FileOutput {
+class ColumnFile : public FileOutput {
public:
- ThreeColumnFile2(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { globaldata = GlobalData::getInstance(); };
- ~ThreeColumnFile2();
+ ColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { globaldata = GlobalData::getInstance(); };
+ ~ColumnFile();
//to make compatible with parent class
void output(int, vector<double>){};
* Mothur
*
* Created by Thomas Ryabin on 2/23/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 2/23/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
* Mothur
*
* Created by Thomas Ryabin on 2/2/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 2/2/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 1/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 1/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 1/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 1/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
if (key == "step") { step = value; }
if (key == "form") { form = value; }
if (key == "sorted") { sorted = value; }
- if (key == "scaler") { scaler = value; }
+ if (key == "scale") { scale = value; }
if (key == "step") { step = value; }
if (key == "form") { form = value; }
if (key == "sorted") { sorted = value; }
- if (key == "scaler") { scaler = value; }
+ if (key == "scale") { scale = value; }
if (key == "line") {//stores lines to be used in a vector
Estimators.clear();
splitAtDash(calc, Estimators);
}
- if (commandName == "tree.groups") {
+ if ((commandName == "tree.shared") || (commandName == "bootstrap.shared")) {
if (calc != "") {
Estimators.clear();
splitAtDash(calc, Estimators);
string GlobalData::getStep() { return step; }
string GlobalData::getForm() { return form; }
string GlobalData::getSorted() { return sorted; }
-string GlobalData::getScaler() { return scaler; }
+string GlobalData::getScale() { return scale; }
void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;}
void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;}
void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;}
abund = "10";
step = "0.01";
form = "integral";
- sorted = "1"; //0 means don't sort, 1 means sort.
- scaler = "log10";
+ sorted = "T"; //F means don't sort, T means sort.
+ scale = "log10";
}
//*******************************************************/
iters = "1000";
groups = "";
jumble = "1"; //0 means don't jumble, 1 means jumble.
- sorted = "1"; //0 means don't sort, 1 means sort.
+ sorted = "T"; //F means don't sort, T means sort.
randomtree = ""; //"" means user will enter some user trees, "outputfile" means they just want the random tree distribution to be outputted to outputfile.
freq = "100";
method = "furthest";
//use nexus translation rather than parsing tree to save time
if ((holder == "translate") || (holder == "Translate")) {
-cout << "there is a translate " << endl;
+
string number, name, h;
h = ""; // so it enters the loop the first time
while((h != ";") && (number != ";")) {
string getStep();
string getForm();
string getSorted();
- string getScaler();
+ string getScale();
void setListFile(string);
void setPhylipFile(string);
private:
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups;
- string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, scaler;
+ string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, scale;
static GlobalData* _uniqueInstance;
GlobalData( const GlobalData& ); // Disable copy constructor
rabund = order->getRAbundVector();
//get users scaling method
- scaler = globaldata->getScaler();
+ scaler = globaldata->getScale();
float maxbin = 0.0;
for (int i = 0; i < rabund.size(); i++) {
if (rabund.get(i) != 0) { //don't want log value of 0.
if (scaler == "log10") {
- colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))] = "";
- if (maxbin < (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))) { maxbin = (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100)); }
+ colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))) { maxbin = (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000)); }
}else if (scaler == "log2") {
- colorScale[(log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))] = "";
- if (maxbin < (log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))) { maxbin = (log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 100)); }
+ colorScale[(log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))) { maxbin = (log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000)); }
}else if (scaler == "linear") {
colorScale[rabund.get(i)] = "";
if (maxbin < rabund.get(i)) { maxbin = rabund.get(i); }
}else { //if user enters invalid scaler option.
cout << scaler << " is not a valid scaler option. I will use log10." << endl;
- colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))] = "";
- if (maxbin < (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))) { maxbin = (log10((rabund.get(i)) / (float)rabund.getNumSeqs()) * 100); }
+ colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))) { maxbin = (log10((rabund.get(i)) / (float)rabund.getNumSeqs()) * 1000); }
}
}else { colorScale[0] = "00"; }
}
outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"25\">Heatmap at distance " + order->getLabel() + "</text>\n";
//output legend and color labels
- //go through map and give each score a color value
string color;
int x = 0;
int y = 103 + (rabund.getNumBins()*5);
- if (maxbin != 0) {
- //convert maxbin to relative abundance again
- if (scaler == "log10") {
- maxbin = pow(10, maxbin) / 100;
- }else if (scaler == "log2") {
- maxbin = pow(2, maxbin) / 100;
- }else { maxbin = pow(10, maxbin) / 100; }
- }else { maxbin = 0.00; }
+ printLegend(y, maxbin);
- //5 is the number of boxes in the legend
- float maxbinScaler = maxbin / 10;
- float colorScaler = 255 / 10;
-
- for (int i = 0; i < 10; i++) {
- string label = toString(((i+1) * maxbinScaler));
- //set precision of relative abundance to 3
- int pos = label.find_first_of('.');
- label = label.substr(0,pos+4);
- color = toHex(int((float)(i+1) * colorScaler));
-
- outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"30\" height=\"10\"/>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\">" + label + "</text>\n";
- x += 30;
- }
-
- x = 0;
y = 70;
for (int i = 0; i <= rabund.getNumBins(); i++) {
if (rabund.get(i) != 0) { //don't want log value of 0.
if (scaler == "log10") {
- color = colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))];
+ color = colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))];
}else if (scaler == "log2") {
- color = colorScale[(log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))];
+ color = colorScale[(log2((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))];
}else if (scaler == "linear") {
color = colorScale[rabund.get(i)];
- }else { color = colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 100))]; }
+ }else { color = colorScale[(log10((rabund.get(i) / (float)rabund.getNumSeqs()) * 1000))]; }
}else { color = "OO"; }
outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
//fills vector of sharedsabunds - lookup
util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector.
-
+
//sort lookup so shared bins are on top
- if (sorted == "1") { sortSharedVectors(); }
-
+ if (sorted == "T") { sortSharedVectors(); }
+
//get users scaling method
- scaler = globaldata->getScaler();
+ scaler = globaldata->getScale();
float maxbin = 0.0;
for (int i = 0; i < lookup.size(); i++) {
for (int j = 0; j < lookup[i]->size(); j++) {
if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0.
if (scaler == "log10") {
- colorScale[(log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))] = "";
- if (maxbin < (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))) { maxbin = (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100)); }
+ colorScale[(log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))) { maxbin = (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000)); }
}else if (scaler == "log2") {
- colorScale[(log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))] = "";
- if (maxbin < (log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))) { maxbin = (log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100)); }
+ colorScale[(log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))) { maxbin = (log2((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000)); }
}else if (scaler == "linear") {
colorScale[lookup[i]->getAbundance(j)] = "";
if (maxbin < lookup[i]->getAbundance(j)) { maxbin = lookup[i]->getAbundance(j); }
}else { //if user enters invalid scaler option.
cout << scaler << " is not a valid scaler option. I will use log10." << endl;
- colorScale[(log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))] = "";
- if (maxbin < (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 100))) { maxbin = (log10((lookup[i]->getAbundance(j)) / (float)lookup[i]->getNumSeqs()) * 100); }
+ colorScale[(log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))] = "";
+ if (maxbin < (log10((lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) * 1000))) { maxbin = (log10((lookup[i]->getAbundance(j)) / (float)lookup[i]->getNumSeqs()) * 1000); }
}
}else { colorScale[0] = "00"; }
}
}
//output legend and color labels
- //go through map and give each score a color value
string color;
int x = 0;
int y = 103 + (lookup[0]->getNumBins()*5);
- if (maxbin != 0) {
- //convert maxbin to relative abundance again
- if (scaler == "log10") {
- maxbin = pow(10, maxbin) / 100;
- }else if (scaler == "log2") {
- maxbin = pow(2, maxbin) / 100;
- }else { maxbin = pow(10, maxbin) / 100; }
- }else { maxbin = 0.00; }
-
- //((lookup.size() * 300) / 60) is the number of boxes in the legend
- float maxbinScaler = maxbin / ((lookup.size() * 300) / 60);
- float colorScaler = 255 / ((lookup.size() * 300) / 60);
-
- for (int i = 0; i < ((lookup.size() * 300) / 60); i++) {
- string label = toString(((i+1) * maxbinScaler));
- //set precision of relative abundance to 3
- int pos = label.find_first_of('.');
- label = label.substr(0,pos+4);
+ printLegend(y, maxbin);
- color = toHex(int(((i+1) * colorScaler) + 15));
- outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"30\" height=\"10\"/>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\">" + label + "</text>\n";
- x += 30;
- }
-
- x = 0;
y = 70;
-
- for (int i = 0; i <= lookup[0]->getNumBins(); i++) {
+ for (int i = 0; i < lookup[0]->size(); i++) {
for (int j = 0; j < lookup.size(); j++) {
if (lookup[j]->getAbundance(i) != 0) { //don't want log value of 0.
if (scaler == "log10") {
- color = colorScale[(log10((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 100))];
+ color = colorScale[(log10((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 1000))];
}else if (scaler == "log2") {
- color = colorScale[(log2((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 100))];
+ color = colorScale[(log2((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 1000))];
}else if (scaler == "linear") {
color = colorScale[lookup[j]->getAbundance(i)];
- }else { color = colorScale[(log10((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 100))]; }
+ }else { color = colorScale[(log10((lookup[j]->getAbundance(i) / (float)lookup[j]->getNumSeqs()) * 1000))]; }
}else { color = "OO"; }
}
//**********************************************************************************************************************
+void HeatMap::printLegend(int y, float maxbin) {
+ try {
+
+ //output legend and color labels
+ //go through map and give each score a color value
+ string color;
+ int x = 0;
+ if (maxbin != 0) {
+ //convert maxbin to relative abundance again
+ if (scaler == "log10") {
+ maxbin = pow(10, maxbin) / 1000;
+ }else if (scaler == "log2") {
+ maxbin = pow(2, maxbin) / 1000;
+ }else { maxbin = pow(10, maxbin) / 1000; }
+ }else { maxbin = 0.00; }
+
+ //5 is the number of boxes in the legend
+ float maxbinScaler = maxbin / 10;
+ float colorScaler = 255 / 10;
+
+ //prints legend
+ for (int i = 0; i < 10; i++) {
+ color = toHex(int((float)(i+1) * colorScaler));
+ outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"30\" height=\"10\"/>\n";
+ x += 30;
+ }
+
+ //prints legend labels
+ x -= 30;
+ for (int i = 10; i > 0; i = i-2) {
+ string label = toString((i * maxbinScaler));
+ //set precision of relative abundance to 3
+ int pos = label.find_first_of('.');
+ label = label.substr(0,pos+4);
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y-3) + "\">" + label + "</text>\n";
+ x -= 60;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the HeatMap class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
private:
void sortSharedVectors();
+ void printLegend(int, float);
GlobalData* globaldata;
SharedUtil* util;
HelpCommand::HelpCommand(){
globaldata = GlobalData::getInstance();
validCommands = new ValidCommands();
+ validCalcs = new ValidCalculators();
}
//**********************************************************************************************************************
cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
cout << "Example collect(label=unique-.01-.03, line=0-5-10, iters=10000, freq=10, calc=sobs-chao-ace-jack)." << "\n";
cout << "The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson." << "\n";
+ validCalcs->printCalc("single", cout);
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "collect.shared") {
cout << "The collect.shared command parameters are label, line, freq, jumble, calc and groups. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The collect.shared command should be in the following format: " << "\n";
cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, calc=yourEstimators, groups=yourGroups)." << "\n";
- cout << "Example collect.shared(label=unique-.01-.03, line=0-5-10, freq=10, jumble=1, groups=B-C, calc=sharedChao-sharedAce-Jabund-SorensonAbund-Jclass-SorClass-Jest-SorEst-ThetaYC-ThetaN)." << "\n";
- cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and calc are sharedsobs-sharedChao-sharedAce-Jabund-SorensonAbund-Jclass-SorClass-Jest-SorEst-ThetaYC-ThetaN." << "\n";
+ cout << "Example collect.shared(label=unique-.01-.03, line=0-5-10, freq=10, jumble=1, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
+ cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan." << "\n";
cout << "The default value for groups is all the groups in your groupfile." << "\n";
+ validCalcs->printCalc("shared", cout);
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups." << "\n";
cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
cout << "Example rarefaction.single(label=unique-.01-.03, line=0-5-10, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
cout << "The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
+ validCalcs->printCalc("rarefaction", cout);
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "rarefaction.shared") {
cout << "Example rarefaction.shared(label=unique-.01-.03, line=0-5-10, iters=10000, jumble=1, groups=B-C, calc=sharedobserved)." << "\n";
cout << "The default values for iters is 1000, jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness." << "\n";
cout << "The default value for groups is all the groups in your groupfile." << "\n";
+ validCalcs->printCalc("sharedrarefaction", cout);
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups." << "\n";
cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
cout << "both the line and label parameters at the same time. The summary.single command should be in the following format: " << "\n";
cout << "summary.single(label=yourLabel, line=yourLines, calc=yourEstimators)." << "\n";
cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
+ validCalcs->printCalc("summary", cout);
cout << "The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson" << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
cout << "The summary.shared command parameters are label, line, jumble and calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The summary.shared command should be in the following format: " << "\n";
cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, calc=yourEstimators, groups=yourGroups)." << "\n";
- cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, groups=B-C, calc=sharedChao-sharedAce-Jabund-SorensonAbund-Jclass-SorClass-Jest-SorEst-ThetaYC-ThetaN)." << "\n";
- cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and calc is sharedsobs-sharedChao-sharedAce-Jabund-SorensonAbund-Jclass-SorClass-Jest-SorEst-ThetaYC-ThetaN" << "\n";
+ cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan)." << "\n";
+ validCalcs->printCalc("sharedsummary", cout);
+ cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan" << "\n";
cout << "The default value for groups is all the groups in your groupfile." << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups." << "\n";
cout << "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters)." << "\n" << "\n";
}else if (globaldata->helpRequest == "heatmap") {
cout << "The heatmap command can only be executed after a successful read.otu command." << "\n";
- cout << "The heatmap command parameters are groups, sorted, scaler, line and label. No parameters are required, but you may not use line and label at the same time." << "\n";
+ cout << "The heatmap command parameters are groups, sorted, scale, line and label. No parameters are required, but you may not use line and label at the same time." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n";
cout << "The sorted parameter allows you to choose to see the file with the shared otus at the top or the otus in the order they appear in your input file. " << "\n";
- cout << "The scaler parameter allows you to choose the range of color your bin information will be displayed with." << "\n";
+ cout << "The scale parameter allows you to choose the range of color your bin information will be displayed with." << "\n";
cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n";
cout << "The heatmap command should be in the following format: heatmap(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n";
- cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=0, scaler=log10)." << "\n";
+ cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n";
cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n";
- cout << "The default value for sorted is 1 meaning you want the shared otus on top, you may change it to 0 meaning the exact representation of your input file." << "\n";
- cout << "The default value for scaler is log10; your other options are log2 and linear." << "\n";
+ cout << "The default value for sorted is T meaning you want the shared otus on top, you may change it to F meaning the exact representation of your input file." << "\n";
+ cout << "The default value for scale is log10; your other options are log2 and linear." << "\n";
cout << "The heatmap command outputs a .svg file for each line or label you specify." << "\n";
cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
}else if (globaldata->helpRequest == "venn") {
cout << "The venn command parameters are groups, calc, line and label. No parameters are required, but you may not use line and label at the same time." << "\n";
cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your venn diagram, you may only use a maximum of 4 groups." << "\n";
cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a venn diagram created for, and are also separated by dashes." << "\n";
- cout << "The venn command should be in the following format: venn(groups=yourGroups, calc=yourSorted, line=yourLines, label=yourLabels)." << "\n";
+ cout << "The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels)." << "\n";
cout << "Example venn(groups=A-B-C, line=1-3-5, calc=sharedsobs-sharedchao)." << "\n";
cout << "The default value for groups is all the groups in your groupfile up to 4, and all lines in your inputfile will be used." << "\n";
cout << "The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups." << "\n";
cout << "The only estmiator available four 4 groups is sharedsobs." << "\n";
cout << "The venn command outputs a .svg file for each calculator you specify at each distance you choose." << "\n";
cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+ }else if (globaldata->helpRequest == "tree.shared") {
+ cout << "The tree.shared command can only be executed after a successful read.otu command." << "\n";
+ cout << "The tree.shared command parameters are groups, calc, line and label. The calc parameter is required, and you may not use line and label at the same time." << "\n";
+ cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
+ cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes." << "\n";
+ cout << "The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels)." << "\n";
+ cout << "Example tree.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorensonabund)." << "\n";
+ cout << "The default value for groups is all the groups in your groupfile." << "\n";
+ cout << "There is no default value for calc." << "\n";
+ validCalcs->printCalc("treegroup", cout);
+ cout << "The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose." << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+ }else if (globaldata->helpRequest == "bootstrap.shared") {
+ cout << "The bootstrap.shared command can only be executed after a successful read.otu command." << "\n";
+ cout << "The bootstrap.shared command parameters are groups, calc, iters, line and label. The calc parameter is required, and you may not use line and label at the same time." << "\n";
+ cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
+ cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes." << "\n";
+ cout << "The bootstrap.shared command should be in the following format: bootstrap.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels, iters=yourIters)." << "\n";
+ cout << "Example bootstrap.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorensonabund, iters=100)." << "\n";
+ cout << "The default value for groups is all the groups in your groupfile." << "\n";
+ cout << "There is no default value for calc. The default for iters is 1000." << "\n";
+ validCalcs->printCalc("boot", cout);
+ cout << "The bootstrap.shared command outputs a .tre file for each calculator you specify at each distance you choose containing iters number of trees." << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
}else if (globaldata->helpRequest == "bin.seqs") {
cout << "The bin.seqs command can only be executed after a successful read.otu command of a list file." << "\n";
cout << "The bin.seqs command parameters are fasta, name, line and label. The fasta parameter is required, and you may not use line and label at the same time." << "\n";
#include "command.hpp"
#include "globaldata.hpp"
#include "validcommands.h"
+#include "validcalculator.h"
class HelpCommand : public Command {
private:
GlobalData* globaldata;
ValidCommands* validCommands;
+ ValidCalculators* validCalcs;
private:
* Mothur
*
* Created by Thomas Ryabin on 2/23/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 2/23/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
if (randomtree == "") {
T = globaldata->gTree;
tmap = globaldata->gTreemap;
- parsFile = globaldata->getTreeFile() + ".parsimony";
- parsFileout = globaldata->getTreeFile() + "temp" + ".parsimony";
+ output = new ColumnFile(globaldata->getTreeFile() + ".parsimony");
sumFile = globaldata->getTreeFile() + ".psummary";
openOutputFile(sumFile, outSum);
}else { //user wants random distribution
savetmap = globaldata->gTreemap;
getUserInput();
- parsFile = randomtree;
- parsFileout = globaldata->getTreeFile() + "temp";
+ output = new ColumnFile(randomtree);
}
//set users groups to analyze
void ParsimonyCommand::printParsimonyFile() {
try {
vector<double> data;
+ vector<string> tags;
- //format output
- out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
+ if (randomtree == "") {
+ tags.push_back("Score"); tags.push_back("UserFreq"); tags.push_back("UserCumul"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
+ }else {
+ tags.push_back("Score"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
+ }
for(int a = 0; a < numComp; a++) {
- initFile(groupComb[a]);
+ output->initFile(groupComb[a], tags);
//print each line
for (it = validScores.begin(); it != validScores.end(); it++) {
if (randomtree == "") {
}else{
data.push_back(it->first); data.push_back(rscoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]);
}
- output(data);
+ output->output(data);
data.clear();
}
- resetFile();
+ output->resetFile();
}
-
- out.close();
- inFile.close();
- remove(parsFileout.c_str());
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function printParsimonyFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
}
-/*****************************************************************/
-
-void ParsimonyCommand::initFile(string label){
- try {
- if(counter != 0){
- openOutputFile(parsFileout, out);
- openInputFile(parsFile, inFile);
-
- string inputBuffer;
- getline(inFile, inputBuffer);
-
- if (randomtree == "") {
- out << inputBuffer << '\t' << label + "Score" << '\t' << label + "UserFreq" << '\t' << label + "UserCumul" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }else {
- out << inputBuffer << '\t' << "Score" << '\t' << "RandFreq" << '\t' << "RandCumul" << endl;
- }
- }else{
- openOutputFile(parsFileout, out);
- //column headers
- if (randomtree == "") {
- out << label + "Score" << '\t' << label + "UserFreq" << '\t' << label + "UserCumul" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }else {
- out << "Score" << '\t' << "RandFreq" << '\t' << "RandCumul" << endl;
- }
- }
-
- out.setf(ios::fixed, ios::floatfield);
- out.setf(ios::showpoint);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the ParsimonyCommand class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-void ParsimonyCommand::output(vector<double> data){
- try {
- if(counter != 0){
- string inputBuffer;
- getline(inFile, inputBuffer);
-
- if (randomtree == "") {
- out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << endl;
- }else{
- out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
- }
- }
- else{
- if (randomtree == "") {
- out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << '\t' << data[3] << '\t' << data[4] << endl;
- }else{
- out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
- }
- }
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the ParsimonyCommand class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-
-void ParsimonyCommand::resetFile(){
- try {
- if(counter != 0){
- out.close();
- inFile.close();
- }
- else{
- out.close();
- }
- counter = 1;
-
- remove(parsFile.c_str());
- rename(parsFileout.c_str(), parsFile.c_str());
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the ParsimonyCommand class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
+/***********************************************************/
#include "treemap.h"
#include "progress.hpp"
#include "sharedutilities.h"
+#include "fileoutput.h"
using namespace std;
public:
ParsimonyCommand();
- ~ParsimonyCommand() { delete pars; delete util; }
+ ~ParsimonyCommand() { delete pars; delete util; delete output; }
int execute();
private:
GlobalData* globaldata;
SharedUtil* util;
+ FileOutput* output;
vector<Tree*> T; //user trees
Tree* randT; //random tree
Tree* copyUserTree;
TreeMap* savetmap;
Parsimony* pars;
vector<string> groupComb; // AB. AC, BC...
- string parsFile, parsFileout, sumFile, randomtree, allGroups;
+ string sumFile, randomtree, allGroups;
int iters, numGroups, numComp, counter;
vector<int> numEachGroup; //vector containing the number of sequences in each group the users wants for random distrib.
vector< vector<float> > userTreeScores; //scores for users trees for each comb.
void printParsimonyFile();
void printUSummaryFile();
void getUserInput();
- void initFile(string);
- void output(vector<double>);
- void resetFile();
-
};
* Mothur
*
* Created by Thomas Ryabin on 3/4/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/4/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
void RareDisplay::close(){
try {
+
output->initFile(label);
openInputFile(tempInName, tempInFile);
* Mothur
*
* Created by Thomas Ryabin on 3/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/6/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "calculator.h"
//This function is used to read a .shared file for the collect.shared, rarefaction.shared and summary.shared commands
//if you don't use a list and groupfile.
-SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {
+SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a shared file
try {
globaldata = GlobalData::getInstance();
maxRank = 0; numBins = 0; numSeqs = 0;
f >> inputData;
for (int j = 0; j < inputData; j++) {
- push_back(i+1, i+1, groupN);
+ push_back(i, i, groupN);
numSeqs++;
}
}
f >> inputData;
for (int j = 0; j < inputData; j++) {
- push_back(i+1, i+1, groupN);
+ push_back(i, i, groupN);
numSeqs++;
}
}
f.seekg(pos, ios::beg);
if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; }
-
+
updateStats();
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
/***********************************************************************/
int SharedOrderVector::getNumBins(){
- if(needToUpdate == 1){ updateStats(); }
return numBins;
}
/***********************************************************************/
int SharedOrderVector::getNumSeqs(){
- if(needToUpdate == 1){ updateStats(); }
return numSeqs;
}
/***********************************************************************/
int SharedOrderVector::getMaxRank(){
- if(needToUpdate == 1){ updateStats(); }
return maxRank;
}
data[index].group = groupName;
data[index].bin = binNumber;
data[index].abundance = abund;
- needToUpdate = 1;
-
+ //if (abund > maxRank) { maxRank = abund; }
+ updateStats();
}
/***********************************************************************/
newGuy.abundance = abund;
newGuy.bin = binNumber;
data.push_back(newGuy);
- needToUpdate = 1;
-
+ //numSeqs++;
+ //numBins++;
+ //if (abund > maxRank) { maxRank = abund; }
+ updateStats();
}
/***********************************************************************/
/***********************************************************************/
void SharedRAbundVector::pop_back(){
-
+ numSeqs -= data[data.size()-1].abundance;
+ numBins--;
return data.pop_back();
}
try {
output << numBins << '\t';
- for(int i=0;i<numBins;i++){ output << data[i].abundance << '\t'; }
+ for(int i=0;i<data.size();i++){ output << data[i].abundance << '\t'; }
output << endl;
}
catch(exception& e) {
temp->setGroup(Groups[i]);
lookup.push_back(temp);
}
-
+
int numSeqs = order->size();
//sample all the members
for(int i=0;i<numSeqs;i++){
exit(1);
}
}
+/**************************************************************************************************/
+
+void SharedUtil::getSharedVectorswithReplacement(vector<string> Groups, vector<SharedRAbundVector*>& lookup, SharedOrderVector* order) {
+ try {
+
+ //delete each sharedrabundvector in lookup
+ for (int j = 0; j < lookup.size(); j++) {
+ delete lookup[j];
+ }
+
+ lookup.clear();
+
+ //create and initialize vector of sharedvectors, one for each group
+ for (int i = 0; i < Groups.size(); i++) {
+ SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
+ temp->setLabel(order->getLabel());
+ temp->setGroup(Groups[i]);
+ lookup.push_back(temp);
+ }
+
+ int numSeqs = order->size();
+
+ //sample all the members
+ for(int i=0;i<numSeqs;i++){
+ //get random number
+ int random = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+ individual chosen = order->get(random);
+
+ int abundance;
+ //set info for sharedvector in chosens group
+ for (int j = 0; j < lookup.size(); j++) {
+ if (chosen.group == lookup[j]->getGroup()) {
+ abundance = lookup[j]->getAbundance(chosen.bin);
+ lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
+ break;
+ }
+ }
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getSharedVectorswithReplacement. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedUtil class function getSharedVectorswithReplacement. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
/**************************************************************************************************/
//need to have mode because different commands require different number of valid groups
~SharedUtil() {};
void getSharedVectors(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
+ void getSharedVectorswithReplacement(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
void setGroups(vector<string>&, vector<string>&, string); //globaldata->Groups, your tree or group map, mode
void setGroups(vector<string>&, vector<string>&, string&, int&, string); //globaldata->Groups, your tree or group map, allgroups, numGroups, mode
void getCombos(vector<string>&, vector<string>, int&); //groupcomb, globaldata->Groups, numcomb
exit(1);
}
}
-
+/*****************************************************************/
+void Tree::print(ostream& out) {
+ try {
+ int root = findRoot();
+ printBranch(root, out);
+ out << ";" << endl;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Tree class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Tree class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
/*****************************************************************/
// This prints out the tree in Newick form.
void Tree::createNewickFile(string f) {
filename = f;
openOutputFile(filename, out);
- printBranch(root);
+ printBranch(root, out);
// you are at the end of the tree
out << ";" << endl;
}
/*****************************************************************/
-void Tree::printBranch(int node) {
+void Tree::printBranch(int node, ostream& out) {
try {
// you are not a leaf
if (tree[node].getLChild() != -1) {
out << "(";
- printBranch(tree[node].getLChild());
+ printBranch(tree[node].getLChild(), out);
out << ",";
- printBranch(tree[node].getRChild());
+ printBranch(tree[node].getRChild(), out);
out << ")";
//if there is a branch length then print it
if (tree[node].getBranchLength() != -1) {
int getNumLeaves(){ return numLeaves; }
map<string, int> mergeUserGroups(int, vector<string>); //returns a map with a groupname and the number of times that group was seen in the children
void printTree();
+ void print(ostream&);
//this function takes the leaf info and populates the non leaf nodes
void assembleTree();
void randomLabels(vector<string>);
void randomLabels(string, string);
int findRoot(); //return index of root node
- void printBranch(int); //recursively print out tree
+ void printBranch(int, ostream&); //recursively print out tree
};
#endif
for (int g = 0; g < numGroups; g++) { index[g] = g; }
//create a new filename
- outputFile = getRootName(globaldata->inputFileName) + treeCalculators[i]->getName() + "." + order->getLabel() + groupNames + ".tre";
+ outputFile = getRootName(globaldata->inputFileName) + treeCalculators[i]->getName() + "." + order->getLabel() + ".tre";
- for (int k = 0; k < lookup.size(); k++) { // pass cdd each set of groups to commpare
+ for (int k = 0; k < lookup.size(); k++) {
for (int l = k; l < lookup.size(); l++) {
if (k != l) { //we dont need to similiarity of a groups to itself
//get estimated similarity between 2 groups
//set names of seqs to names of groups
namesOfSeqs = groupmap->namesOfGroups;
- // make map where key and value are both the group name since that what the tree.groups command wants
+ // make map where key and value are both the group name since that what the tree.shared command wants
for (int i = 0; i < namesOfGroups.size(); i++) {
treemap[namesOfGroups[i]].groupname = namesOfGroups[i];
seqsPerGroup[namesOfGroups[i]] = 1;
map<string,int> seqsPerGroup; //groupname, number of seqs in that group.
map<string, GroupIndex> treemap; //sequence name and <groupname, vector index>
void print(ostream&);
- void makeSim(GroupMap*); //takes groupmap info and fills treemap for use by tree.groups command.
+ void makeSim(GroupMap*); //takes groupmap info and fills treemap for use by tree.shared command.
private:
//get pscores for users trees
for (int i = 0; i < T.size(); i++) {
counter = 0;
- unweightedFile = globaldata->getTreeFile() + toString(i+1) + ".unweighted";
- unweightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".unweighted";
+
+ output = new ColumnFile(globaldata->getTreeFile() + toString(i+1) + ".unweighted");
outSum << i+1 << '\t';
cout << i+1 << '\t';
}
- for(int a = 0; a < numComp; a++) {
- float rcumul = 1.0000;
- //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
- for (it = validScores.begin(); it != validScores.end(); it++) {
- //make rscoreFreq map and rCumul
- it2 = rscoreFreq[a].find(it->first);
- rCumul[a][it->first] = rcumul;
- //get percentage of random trees with that info
- if (it2 != rscoreFreq[a].end()) { rscoreFreq[a][it->first] /= iters; rcumul-= it2->second; }
- else { rscoreFreq[a][it->first] = 0.0000; } //no random trees with that score
+ for(int a = 0; a < numComp; a++) {
+ float rcumul = 1.0000;
+ //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
+ for (it = validScores.begin(); it != validScores.end(); it++) {
+ //make rscoreFreq map and rCumul
+ it2 = rscoreFreq[a].find(it->first);
+ rCumul[a][it->first] = rcumul;
+ //get percentage of random trees with that info
+ if (it2 != rscoreFreq[a].end()) { rscoreFreq[a][it->first] /= iters; rcumul-= it2->second; }
+ else { rscoreFreq[a][it->first] = 0.0000; } //no random trees with that score
+ }
+ UWScoreSig[a].push_back(rCumul[a][userData[a]]);
}
- UWScoreSig[a].push_back(rCumul[a][userData[a]]);
- }
- printUnweightedFile();
- printUWSummaryFile();
+ printUnweightedFile();
+ printUWSummaryFile();
+
+ delete output;
+ rscoreFreq.clear();
+ rCumul.clear();
+ validScores.clear();
+ utreeScores.clear();
+ UWScoreSig.clear();
+ }
- rscoreFreq.clear();
- rCumul.clear();
- validScores.clear();
- utreeScores.clear();
- UWScoreSig.clear();
- }
//reset groups parameter
globaldata->Groups.clear();
outSum.close();
void UnifracUnweightedCommand::printUnweightedFile() {
try {
vector<double> data;
+ vector<string> tags;
+ tags.push_back("Score"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
for(int a = 0; a < numComp; a++) {
- initFile(groupComb[a]);
+ output->initFile(groupComb[a], tags);
//print each line
for (it = validScores.begin(); it != validScores.end(); it++) {
data.push_back(it->first); data.push_back(rscoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]);
- output(data);
+ output->output(data);
data.clear();
}
- resetFile();
+ output->resetFile();
}
-
- out.close();
- inFile.close();
- remove(unweightedFileout.c_str());
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function printUnweightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
}
-/*****************************************************************/
-
-void UnifracUnweightedCommand::initFile(string label){
- try {
- if(counter != 0){
- openOutputFile(unweightedFileout, out);
- openInputFile(unweightedFile, inFile);
-
- string inputBuffer;
- getline(inFile, inputBuffer);
-
- out << inputBuffer << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }else{
- openOutputFile(unweightedFileout, out);
- out << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }
-
- out.setf(ios::fixed, ios::floatfield);
- out.setf(ios::showpoint);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracUnweightedCommand class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-void UnifracUnweightedCommand::output(vector<double> data){
- try {
- if(counter != 0){
- string inputBuffer;
- getline(inFile, inputBuffer);
-// out << inputBuffer << setprecision(6) << '\t' << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
-
- out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
- }
- else{
- out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
- }
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracUnweightedCommand class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-};
-
-/***********************************************************************/
+/***********************************************************/
-void UnifracUnweightedCommand::resetFile(){
- try {
- if(counter != 0){
- out.close();
- inFile.close();
- }
- else{
- out.close();
- }
- counter = 1;
-
- remove(unweightedFile.c_str());
- rename(unweightedFileout.c_str(), unweightedFile.c_str());
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracUnweightedCommand class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
#include "unweighted.h"
#include "treemap.h"
#include "sharedutilities.h"
+#include "fileoutput.h"
using namespace std;
private:
GlobalData* globaldata;
SharedUtil* util;
+ FileOutput* output;
vector<Tree*> T; //user trees
TreeMap* tmap;
Unweighted* unweighted;
- string sumFile, unweightedFile, unweightedFileout, allGroups;
+ string sumFile, allGroups;
vector<string> groupComb; // AB. AC, BC...
int iters, numGroups, numComp, counter;
EstOutput userData; //unweighted score info for user tree
void printUWSummaryFile();
void printUnweightedFile();
- void initFile(string);
- void output(vector<double>);
- void resetFile();
-
+
};
counter = 0;
rScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
uScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
- //weightedFile = globaldata->getTreeFile() + toString(i+1) + ".weighted";
- //weightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".weighted";
- output = new ThreeColumnFile2(globaldata->getTreeFile() + toString(i+1) + ".weighted");
+
+ output = new ColumnFile(globaldata->getTreeFile() + toString(i+1) + ".weighted");
userData = weighted->getValues(T[i]); //userData[0] = weightedscore
}
output->resetFile();
}
-
- //out.close();
- //inFile.close();
- //remove(weightedFileout.c_str());
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function printWeightedFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
}
-/*****************************************************************
-
-void UnifracWeightedCommand::initFile(string label){
- try {
- if(counter != 0){
- openOutputFile(weightedFileout, out);
- openInputFile(weightedFile, inFile);
-
- string inputBuffer;
- getline(inFile, inputBuffer);
-
- out << inputBuffer << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }else{
- openOutputFile(weightedFileout, out);
- out << label + "Score" << '\t' << label + "RandFreq" << '\t' << label + "RandCumul" << endl;
- }
-
- out.setf(ios::fixed, ios::floatfield);
- out.setf(ios::showpoint);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracWeightedCommand class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************
-
-void UnifracWeightedCommand::output(vector<double> data){
- try {
- if(counter != 0){
- string inputBuffer;
- getline(inFile, inputBuffer);
-
- out << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
- }
- else{
- out << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl;
-
- }
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracWeightedCommand class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-};
-
-/***********************************************************************
-
-void UnifracWeightedCommand::resetFile(){
- try {
- if(counter != 0){
- out.close();
- inFile.close();
- }
- else{
- out.close();
- }
- counter = 1;
-
- remove(weightedFile.c_str());
- rename(weightedFileout.c_str(), weightedFile.c_str());
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the UnifracWeightedCommand class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-
-
-}
+/***********************************************************/
-*/
Tree* randT; //random tree
TreeMap* tmap;
Weighted* weighted;
- string weightedFile, weightedFileout, sumFile;
+ string sumFile;
int iters, numGroups, numComp, counter;
EstOutput userData; //weighted score info for user tree
EstOutput randomData; //weighted score info for random trees
//void removeValidScoresDuplicates();
int findIndex(float, int);
void calculateFreqsCumuls();
- //void initFile(string);
- //void output(vector<double>);
- //void resetFile();
-
+
};
initialVennSingle();
initialVennShared();
initialTreeGroups();
+ initialBoot();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
if ((treegroup.find(calculator)) != (treegroup.end())) {
return true;
}else {
- cout << calculator << " is not a valid estimator for the tree.groups command in shared mode and will be disregarded. Valid estimators are ";
+ cout << calculator << " is not a valid estimator for the tree.shared command in shared mode and will be disregarded. Valid estimators are ";
for (it = treegroup.begin(); it != treegroup.end(); it++) {
cout << it->first << ", ";
}
cout << endl;
return false; }
-
+ }else if (parameter == "boot") {
+ //is it valid
+ if ((boot.find(calculator)) != (boot.end())) {
+ return true;
+ }else {
+ cout << calculator << " is not a valid estimator for the bootstrap.shared command in shared mode and will be disregarded. Valid estimators are ";
+ for (it = boot.begin(); it != boot.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//not a valid parameter
}else { return false; }
exit(1);
}
}
-
-
/********************************************************************/
+void ValidCalculators::initialBoot() {
+ try {
+ boot["jabund"] = "jabund";
+ boot["sorensonabund"] = "sorensonabund";
+ boot["jclass"] = "jclass";
+ boot["sorclass"] = "orclass";
+ boot["jest"] = "jest";
+ boot["sorest"] = "sorest";
+ boot["thetayc"] = "thetayc";
+ boot["thetan"] = "thetan";
+ boot["morisitahorn"] = "morisitahorn";
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/********************************************************************/
+void ValidCalculators::printCalc(string parameter, ostream& out) {
+ try{
+ out << "The available estimators for calc are ";
+ //are you looking for a calculator for a single parameter
+ if (parameter == "single") {
+ for (it = single.begin(); it != single.end(); it++) {
+ out << it->first << ", ";
+ }
+ //are you looking for a calculator for a shared parameter
+ }else if (parameter == "shared") {
+ for (it = shared.begin(); it != shared.end(); it++) {
+ out << it->first << ", ";
+ }
+ //are you looking for a calculator for a rarefaction parameter
+ }else if (parameter == "rarefaction") {
+ for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
+ out << it->first << ", ";
+ }
+ //are you looking for a calculator for a summary parameter
+ }else if (parameter == "summary") {
+ for (it = summary.begin(); it != summary.end(); it++) {
+ out << it->first << ", ";
+ }
+ //are you looking for a calculator for a sharedsummary parameter
+ }else if (parameter == "sharedsummary") {
+ for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
+ out << it->first << ", ";
+ }
+ }else if (parameter == "sharedrarefaction") {
+ for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
+ out << it->first << ", ";
+ }
+ }else if (parameter == "vennsingle") {
+ for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
+ out << it->first << ", ";
+ }
+ }else if (parameter == "vennshared") {
+ for (it = vennshared.begin(); it != vennshared.end(); it++) {
+ out << it->first << ", ";
+ }
+ }else if (parameter == "treegroup") {
+ for (it = treegroup.begin(); it != treegroup.end(); it++) {
+ out << it->first << ", ";
+ }
+ }else if (parameter == "boot") {
+ for (it = boot.begin(); it != boot.end(); it++) {
+ out << it->first << ", ";
+ }
+ }
+ out << endl;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
-
+}
+/********************************************************************/
ValidCalculators();
~ValidCalculators();
bool isValidCalculator(string, string);
+ void printCalc(string, ostream&);
private:
map<string, string> single;
map<string, string> vennsingle;
map<string, string> vennshared;
map<string, string> treegroup;
+ map<string, string> boot;
map<string, string>::iterator it;
void initialSingle();
void initialVennSingle();
void initialVennShared();
void initialTreeGroups();
+ void initialBoot();
};
#endif
commands["unifrac.weighted"] = "unifrac.weighted";
commands["unifrac.unweighted"] = "unifrac.unweighted";
commands["libshuff"] = "libshuff";
- commands["tree.groups"] = "tree.groups";
+ commands["tree.shared"] = "tree.shared";
commands["heatmap"] = "heatmap";
commands["venn"] = "venn";
commands["get.group"] = "get.group";
commands["get.label"] = "get.label";
commands["get.line"] = "get.line";
+ commands["bootstrap.shared"] = "bootstrap.shared";
commands["help"] = "help";
commands["quit"] = "quit";
string unifracUnweightedArray[] = {"groups","iters"};
commandParameters["unifrac.unweighted"] = addParameters(unifracUnweightedArray, sizeof(unifracUnweightedArray)/sizeof(string));
- string heatmapArray[] = {"groups","line","label","sorted","scaler"};
+ string heatmapArray[] = {"groups","line","label","sorted","scale"};
commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
string vennArray[] = {"groups","line","label","calc"};
commandParameters["get.oturep"] = addParameters(getOTURepArray, sizeof(getOTURepArray)/sizeof(string));
string treeGroupsArray[] = {"line","label","calc","groups"};
- commandParameters["tree.groups"] = addParameters(treeGroupsArray, sizeof(treeGroupsArray)/sizeof(string));
+ commandParameters["tree.shared"] = addParameters(treeGroupsArray, sizeof(treeGroupsArray)/sizeof(string));
+
+ string bootstrapArray[] = {"line","label","calc","groups","iters"};
+ commandParameters["bootstrap.shared"] = addParameters(bootstrapArray, sizeof(bootstrapArray)/sizeof(string));
string quitArray[] = {};
commandParameters["quit"] = addParameters(quitArray, sizeof(quitArray)/sizeof(string));
}
}
-