]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug with hcluster
authorwestcott <westcott>
Thu, 29 Oct 2009 18:17:36 +0000 (18:17 +0000)
committerwestcott <westcott>
Thu, 29 Oct 2009 18:17:36 +0000 (18:17 +0000)
clustercommand.cpp
hcluster.cpp
hcluster.h
hclustercommand.cpp
readdistcommand.cpp
readotucommand.cpp
readotucommand.h

index 8208b7efbde6148c4d5c6c0ad0d090335edd6d0c..baf4224c952a5a47bea7aa911f56196c6dabdead 100644 (file)
@@ -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) {
index df3626055d33346d0f483e68e2bdc606e357fc0e..4e83777751fa50686903758f41dd61fcdd53c52f 100644 (file)
@@ -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) {
index 2688c191d7d364a980d51727a3d82f3b929cb45e..ff02b1caff85b8fc48757d3d2b018b3b997ff7f4 100644 (file)
@@ -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) {};
 };
 
index 38ba4b6cd9839205aef8ff01887cdcf7f2b2ecef..6e3ec243addd289a6d44226adeddd6a3fccbb0d2 100644 (file)
@@ -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) {
index c4756c3260db6a660526ef09b66f668b25de12ef..719740cf7589e121029197bb46e30bbdd62e6bda 100644 (file)
@@ -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;
                
        }
index 2e2bbc90baf0fbcfe9abb79b049c1cf2589edfe0..584eb8543d57dd5e5da10775b5ce684250d28229 100644 (file)
@@ -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<string> 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"); }
index dd0cf3adab7798c71e9e853ff1e5b33c8f53a690..543642b66b4bd4b889fd54c8d19776fc71b17b8d 100644 (file)
@@ -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<string> Groups;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used