]> git.donarmstrong.com Git - mothur.git/commitdiff
added cutoff change to mgcluster
authorwestcott <westcott>
Tue, 21 Jun 2011 16:07:40 +0000 (16:07 +0000)
committerwestcott <westcott>
Tue, 21 Jun 2011 16:07:40 +0000 (16:07 +0000)
mgclustercommand.cpp

index fd2671750afa59b42fb3015c182df778b8871583..b982b8d1deb3cbc51716cf74339b8dcaea5d136d 100644 (file)
@@ -235,6 +235,8 @@ int MGClusterCommand::execute(){
                        return 0; 
                }
                
+               double saveCutoff = cutoff;
+               
                if (!hclusterWanted) {
                        //get distmatrix and overlap
                        SparseMatrix* distMatrix = read->getDistMatrix();
@@ -373,6 +375,11 @@ int MGClusterCommand::execute(){
                
                                seqs = hcluster->getSeqs();
                                
+                               //to account for cutoff change in average neighbor
+                               if (seqs.size() != 0) {
+                                       if (seqs[0].dist > cutoff) { break; }
+                               }
+                               
                                if (m->control_pressed) { 
                                        delete nameMap;  delete list; delete rabund; delete hcluster;
                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
@@ -386,7 +393,7 @@ int MGClusterCommand::execute(){
                                        
                                        if (seqs[i].seq1 != seqs[i].seq2) {
                
-                                               hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
+                                               cutoff = hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
                                                
                                                if (m->control_pressed) { 
                                                        delete nameMap;  delete list; delete rabund; delete hcluster;
@@ -491,6 +498,13 @@ int MGClusterCommand::execute(){
                m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
                m->mothurOutEndLine();
                
+               if (saveCutoff != cutoff) { 
+                       if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
+                       else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
+                       
+                       m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
+               }
+               
                //set list file as new current listfile
                string current = "";
                itTypes = outputTypes.find("list");