]> git.donarmstrong.com Git - mothur.git/blobdiff - mgclustercommand.cpp
pat's updates on 7/19/10
[mothur.git] / mgclustercommand.cpp
index f8f3c78e6fc68c507bcc896bf0789a2ba2d7e373..b92927b1d3d51c0505fbcadd14231eade34b78e5 100644 (file)
@@ -208,7 +208,7 @@ int MGClusterCommand::execute(){
                                listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                return 0; 
                        }
-                       
+               
                        //cluster using cluster classes
                        while (distMatrix->getSmallDist() < cutoff && distMatrix->getNNodes() > 0){
                                
@@ -227,7 +227,6 @@ int MGClusterCommand::execute(){
                                }else{
                                        rndDist = roundDist(dist, precision); 
                                }
-
                                
                                if(previousDist <= 0.0000 && dist != previousDist){
                                        oldList.setLabel("unique");
@@ -235,7 +234,6 @@ int MGClusterCommand::execute(){
                                }
                                else if(rndDist != rndPreviousDist){
                                        if (merge) {
-                                               Seq2Bin = cluster->getSeqtoBin();
                                                ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
                                                
                                                if (m->control_pressed) { 
@@ -252,11 +250,11 @@ int MGClusterCommand::execute(){
                                                printData(&oldList);
                                        }
                                }
-                               
+       
                                previousDist = dist;
-       cout << "prev distance = " << previousDist << " dist = " << dist << endl;
                                rndPreviousDist = rndDist;
                                oldList = *list;
+                               Seq2Bin = cluster->getSeqtoBin();
                                oldSeq2Bin = Seq2Bin;
                        }
                        
@@ -266,7 +264,6 @@ int MGClusterCommand::execute(){
                        }
                        else if(rndPreviousDist<cutoff){
                                if (merge) {
-                                       Seq2Bin = cluster->getSeqtoBin();
                                        ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
                                        
                                        if (m->control_pressed) { 
@@ -359,7 +356,6 @@ int MGClusterCommand::execute(){
                                                }
                                                else if((rndDist != rndPreviousDist)){
                                                        if (merge) {
-                                                               Seq2Bin = hcluster->getSeqtoBin();
                                                                ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
                                                                
                                                                if (m->control_pressed) { 
@@ -382,6 +378,7 @@ int MGClusterCommand::execute(){
                                                previousDist = seqs[i].dist;
                                                rndPreviousDist = rndDist;
                                                oldList = *list;
+                                               Seq2Bin = cluster->getSeqtoBin();
                                                oldSeq2Bin = Seq2Bin;
                                        }
                                }
@@ -394,7 +391,6 @@ int MGClusterCommand::execute(){
                        }
                        else if(rndPreviousDist<cutoff){
                                if (merge) {
-                                       Seq2Bin = hcluster->getSeqtoBin();
                                        ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
                                        
                                        if (m->control_pressed) { 
@@ -415,8 +411,8 @@ int MGClusterCommand::execute(){
                        }
                        
                        delete hcluster;
-                       //remove(distFile.c_str());
-                       //remove(overlapFile.c_str());
+                       remove(distFile.c_str());
+                       remove(overlapFile.c_str());
                }
                
                delete list; 
@@ -475,6 +471,7 @@ ListVector* MGClusterCommand::mergeOPFs(map<string, int> binInfo, float dist){
        try {
                //create new listvector so you don't overwrite the clustering
                ListVector* newList = new ListVector(oldList);
+
                bool done = false;
                ifstream inOverlap;
                int count = 0;
@@ -528,13 +525,13 @@ ListVector* MGClusterCommand::mergeOPFs(map<string, int> binInfo, float dist){
 
                                int binKeep = itBin1->second;
                                int binRemove = itBin2->second;
-                               
+                       
                                //if not merge bins and update binInfo
                                if(binKeep != binRemove) {
                
                                        //save names in old bin
                                        string names = newList->get(binRemove);
-                                       
+               
                                        //merge bins into name1s bin
                                        newList->set(binKeep, newList->get(binRemove)+','+newList->get(binKeep));
                                        newList->set(binRemove, "");