]> git.donarmstrong.com Git - mothur.git/blobdiff - clustersplitcommand.cpp
added fasta method to cluster.split
[mothur.git] / clustersplitcommand.cpp
index 363b695dfe7439f244f675b2c4c3736c4a210c6a..8d21d1a83e1eff3d518861273dff976650d8c56c 100644 (file)
@@ -113,7 +113,7 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                        fastafile = validParameter.validFile(parameters, "fasta", true);
                        if (fastafile == "not open") { abort = true; }  
                        else if (fastafile == "not found") { fastafile = ""; }
-                       else { splitmethod = "fasta";  }
+                       else { distfile = fastafile;  splitmethod = "fasta";  }
                        
                        taxFile = validParameter.validFile(parameters, "taxonomy", true);
                        if (taxFile == "not open") { abort = true; }    
@@ -128,6 +128,7 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                        
                        if (fastafile != "") {
                                if (taxFile == "") { m->mothurOut("You need to provide a taxonomy file if you are using a fasta file to generate the split."); m->mothurOutEndLine(); abort = true; }
+                               if (namefile == "") { m->mothurOut("You need to provide a names file if you are using a fasta file to generate the split."); m->mothurOutEndLine(); abort = true; }
                        }
                                        
                        //check for optional parameter and set defaults
@@ -195,7 +196,7 @@ void ClusterSplitCommand::help(){
                m->mothurOut("For the distance file method, you need only provide your distance file and mothur will split the file into distinct groups. \n");
                m->mothurOut("For the classification method, you need to provide your distance file and taxonomy file, and set the splitmethod to classify.  \n");
                m->mothurOut("You will also need to set the taxlevel you want to split by. mothur will split the sequence into distinct taxonomy groups, and split the distance file based on those groups. \n");
-               m->mothurOut("For the classification method using a fasta file, you need to provide your fasta file and taxonomy file.  \n");
+               m->mothurOut("For the classification method using a fasta file, you need to provide your fasta file, names file and taxonomy file.  \n");
                m->mothurOut("You will also need to set the taxlevel you want to split by. mothur will split the sequence into distinct taxonomy groups, and create distance files for each grouping. \n");
                m->mothurOut("The phylip and column parameter allow you to enter your distance file. \n");
                m->mothurOut("The fasta parameter allows you to enter your aligned fasta file. \n");
@@ -270,10 +271,10 @@ int ClusterSplitCommand::execute(){
                
                //split matrix into non-overlapping groups
                SplitMatrix* split;
-               if (splitmethod == "distance")                  {       split = new SplitMatrix(distfile, namefile, taxFile, cutoff, splitmethod, large);                       }
-               else if (splitmethod == "classify")             {       split = new SplitMatrix(distfile, namefile, taxFile, taxLevelCutoff, splitmethod, large);   }
-               else if (splitmethod == "fasta")                {       split = new SplitMatrix(fastafile, taxFile, taxLevelCutoff, splitmethod);                                       }
-               else { m->mothurOut("Not a valid splitting method.  Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); return 0; }
+               if (splitmethod == "distance")                  {       split = new SplitMatrix(distfile, namefile, taxFile, cutoff, splitmethod, large);                                                       }
+               else if (splitmethod == "classify")             {       split = new SplitMatrix(distfile, namefile, taxFile, taxLevelCutoff, splitmethod, large);                                       }
+               else if (splitmethod == "fasta")                {       split = new SplitMatrix(fastafile, namefile, taxFile, taxLevelCutoff, splitmethod, processors, outputDir);      }
+               else { m->mothurOut("Not a valid splitting method.  Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); return 0;             }
                
                split->split();
                
@@ -775,8 +776,8 @@ vector<string> ClusterSplitCommand::cluster(vector< map<string, string> > distNa
                                listFileNames.clear(); return listFileNames;
                        }
                        
-                       //remove(thisDistFile.c_str());
-                       //remove(thisNamefile.c_str());
+                       remove(thisDistFile.c_str());
+                       remove(thisNamefile.c_str());
                }