]> git.donarmstrong.com Git - mothur.git/blobdiff - hclustercommand.cpp
minor mods to seq.error
[mothur.git] / hclustercommand.cpp
index 12f1f9e0b33904639cca446f0b0d698e9f64f625..ec4d35ceef2d37172d21d4d40a2ca6cfb9737404 100644 (file)
@@ -74,6 +74,7 @@ HClusterCommand::HClusterCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -134,16 +135,17 @@ HClusterCommand::HClusterCommand(string option)  {
                        phylipfile = validParameter.validFile(parameters, "phylip", true);
                        if (phylipfile == "not open") { abort = true; }
                        else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  distfile = phylipfile;  format = "phylip";      }
+                       else {  distfile = phylipfile;  format = "phylip";      m->setPhylipFile(phylipfile); }
                        
                        columnfile = validParameter.validFile(parameters, "column", true);
                        if (columnfile == "not open") { abort = true; } 
                        else if (columnfile == "not found") { columnfile = ""; }
-                       else {  distfile = columnfile; format = "column";       }
+                       else {  distfile = columnfile; format = "column";       m->setColumnFile(columnfile); }
                        
                        namefile = validParameter.validFile(parameters, "name", true);
                        if (namefile == "not open") { abort = true; }   
                        else if (namefile == "not found") { namefile = ""; }
+                       else { m->setNameFile(namefile); }
                        
                        if ((phylipfile == "") && (columnfile == "")) { 
                                //is there are current file available for either of these?
@@ -308,11 +310,17 @@ int HClusterCommand::execute(){
                                return 0;  
                }
 
+               float saveCutoff = cutoff;
                
                while (seqs.size() != 0){
                
                        seqs = cluster->getSeqs();
                        
+                       //to account for cutoff change in average neighbor
+                       if (seqs.size() != 0) {
+                               if (seqs[0].dist > cutoff) { break; }
+                       }
+                       
                        if (m->control_pressed) {  
                                delete cluster;
                                sabundFile.close();
@@ -325,7 +333,7 @@ int HClusterCommand::execute(){
                        for (int i = 0; i < seqs.size(); i++) {  //-1 means skip me
                                
                                if (seqs[i].seq1 != seqs[i].seq2) {
-                                       cluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
+                                       cutoff = cluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
                                        
                                        if (m->control_pressed) {  
                                                delete cluster;
@@ -386,6 +394,14 @@ int HClusterCommand::execute(){
                        return 0;  
                }
                
+               
+               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");