From: westcott Date: Thu, 29 Oct 2009 18:17:36 +0000 (+0000) Subject: fixed bug with hcluster X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=3c856e629e20261496b0433c2587f27b2c8ba3f6 fixed bug with hcluster --- diff --git a/clustercommand.cpp b/clustercommand.cpp index 8208b7e..baf4224 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -133,7 +133,7 @@ int ClusterCommand::execute(){ if (abort == true) { return 0; } time_t estart = time(NULL); - int ndist = matrix->getNNodes(); + //int ndist = matrix->getNNodes(); float previousDist = 0.00000; float rndPreviousDist = 0.00000; oldRAbund = *rabund; @@ -200,9 +200,9 @@ int ClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - if (isTrue(timing)) { - mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster " + toString(ndist) + " distances"); mothurOutEndLine(); - } + //if (isTrue(timing)) { + mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); mothurOutEndLine(); + //} return 0; } catch(exception& e) { diff --git a/hcluster.cpp b/hcluster.cpp index df36260..4e83777 100644 --- a/hcluster.cpp +++ b/hcluster.cpp @@ -95,8 +95,9 @@ void HCluster::printInfo(){ } cout << endl; for (int i = 0; i < linkTable.size(); i++) { + cout << i << '\t'; for (it = linkTable[i].begin(); it != linkTable[i].end(); it++) { - cout << it->first << '\t' << it->second << '\t' << '\t'; + cout << it->first << '-' << it->second << '\t'; } cout << endl; } @@ -241,14 +242,13 @@ void HCluster::updateArrayandLinkTable() { activeLinks.erase(smallCol); if(rowSpot>colSpot) { activeLinks[size] = colSpot; } - else{ activeLinks[size] = colSpot-1; } + else{ activeLinks[size] = colSpot; } //adjust everybody elses spot since you deleted - time vs. space for (it = activeLinks.begin(); it != activeLinks.end(); it++) { if (it->second > rowSpot) { activeLinks[it->first]--; } } - //cout << "here4" << endl; } @@ -269,7 +269,7 @@ bool HCluster::update(int row, int col, float distance){ //find upmost parent of row and col smallRow = getUpmostParent(smallRow); smallCol = getUpmostParent(smallCol); - //cout << "smallRow = " << smallRow << " smallCol = " << smallCol << endl; + //cout << "row = " << row << " smallRow = " << smallRow << " col = " << col << " smallCol = " << smallCol << " dist = " << distance << endl; //are they active in the link table int linkValue = makeActive(); //after this point this nodes info is active in linkTable @@ -277,6 +277,7 @@ bool HCluster::update(int row, int col, float distance){ //cout << "linkValue = " << linkValue << " times = " << (clusterArray[smallRow].numSeq * clusterArray[smallCol].numSeq) << endl; //can we cluster??? if (linkValue == (clusterArray[smallRow].numSeq * clusterArray[smallCol].numSeq)) { + //printInfo(); updateArrayandLinkTable(); clusterBins(); clusterNames(); @@ -284,7 +285,7 @@ bool HCluster::update(int row, int col, float distance){ //printInfo(); } - + //printInfo(); return clustered; } catch(exception& e) { diff --git a/hcluster.h b/hcluster.h index 2688c19..ff02b1c 100644 --- a/hcluster.h +++ b/hcluster.h @@ -19,7 +19,7 @@ class ListVector; struct clusterNode { int numSeq; int parent; - int smallChild; //used to make linkTable work with list and rabund + int smallChild; //used to make linkTable work with list and rabund. represents bin number of this cluster node clusterNode(int num, int par, int kid) : numSeq(num), parent(par), smallChild(kid) {}; }; diff --git a/hclustercommand.cpp b/hclustercommand.cpp index 38ba4b6..6e3ec24 100644 --- a/hclustercommand.cpp +++ b/hclustercommand.cpp @@ -144,6 +144,8 @@ int HClusterCommand::execute(){ globaldata->nameMap = NULL; } + time_t estart = time(NULL); + if (!sorted) { read = new ReadCluster(distfile, cutoff); read->setFormat(format); @@ -156,6 +158,9 @@ int HClusterCommand::execute(){ list = new ListVector(globaldata->nameMap->getListVector()); } + mothurOut("It took " + toString(time(NULL) - estart) + " seconds to sort. "); mothurOutEndLine(); + estart = time(NULL); + //list vector made by read contains all sequence names if(list != NULL){ rabund = new RAbundVector(list->getRAbundVector()); @@ -254,9 +259,10 @@ int HClusterCommand::execute(){ sabundFile.close(); rabundFile.close(); listFile.close(); - if (isTrue(timing)) { - //mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster " + toString(ndist) + " distances"); mothurOutEndLine(); - } + + //if (isTrue(timing)) { + mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster. "); mothurOutEndLine(); + //} return 0; } catch(exception& e) { diff --git a/readdistcommand.cpp b/readdistcommand.cpp index c4756c3..719740c 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -155,7 +155,7 @@ int ReadDistCommand::execute(){ if (abort == true) { return 0; } - //time_t start = time(NULL); + time_t start = time(NULL); size_t numDists = 0; if (format == "matrix") { @@ -203,7 +203,7 @@ int ReadDistCommand::execute(){ // } //mothurOut(dist_string); mothurOutEndLine(); mothurOut(count_string); mothurOutEndLine(); } - //mothurOut("It took " + toString(time(NULL) - start) + " secs to read " + toString(numDists) + " distances (cutoff: " + toString(cutoff) + ")"); mothurOutEndLine(); + mothurOut("It took " + toString(time(NULL) - start) + " secs to read "); mothurOutEndLine(); return 0; } diff --git a/readotucommand.cpp b/readotucommand.cpp index 2e2bbc9..584eb85 100644 --- a/readotucommand.cpp +++ b/readotucommand.cpp @@ -21,7 +21,7 @@ ReadOtuCommand::ReadOtuCommand(string option){ else { //valid paramters for this command - string Array[] = {"list","order","shared", "label","group","sabund", "rabund"}; + string Array[] = {"list","order","shared", "label","group","sabund", "rabund","groups"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -66,6 +66,13 @@ ReadOtuCommand::ReadOtuCommand(string option){ groupMap->readMap(); globaldata->gGroupmap = groupMap; } + + groups = validParameter.validFile(parameters, "groups", false); + if (groups == "not found") { groups = ""; } + else { + splitAtDash(groups, Groups); + globaldata->Groups = Groups; + } //you are doing a list and group shared if ((listfile != "") && (groupfile != "")) { globaldata->setFormat("shared"); } diff --git a/readotucommand.h b/readotucommand.h index dd0cf3a..543642b 100644 --- a/readotucommand.h +++ b/readotucommand.h @@ -29,7 +29,8 @@ private: InputData* input; Command* shared; GroupMap* groupMap; - string filename, listfile, orderfile, sharedfile, label, groupfile, sabundfile, rabundfile, format; + string filename, listfile, orderfile, sharedfile, label, groupfile, sabundfile, rabundfile, format, groups; + vector Groups; bool abort, allLines; set labels; //holds labels to be used