]> git.donarmstrong.com Git - mothur.git/blobdiff - chopseqscommand.cpp
working on pca
[mothur.git] / chopseqscommand.cpp
index 1133ff46a8620817708c72607141691d59d5c4ac..a09ff65856ae39c1e8fbb1a662ed8bacd8860694 100644 (file)
@@ -25,7 +25,7 @@ vector<string> ChopSeqsCommand::getValidParameters(){
 //**********************************************************************************************************************
 ChopSeqsCommand::ChopSeqsCommand(){    
        try {
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
@@ -61,10 +61,10 @@ vector<string> ChopSeqsCommand::getRequiredFiles(){
 //**********************************************************************************************************************
 ChopSeqsCommand::ChopSeqsCommand(string option)  {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -133,7 +133,7 @@ ChopSeqsCommand::ChopSeqsCommand(string option)  {
 
 void ChopSeqsCommand::help(){
        try {
-               m->mothurOut("The chop.seqs command reads a fasta file and outputs a .chop.fasta containing the trimmed sequences.\n");
+               m->mothurOut("The chop.seqs command reads a fasta file and outputs a .chop.fasta containing the trimmed sequences. Note: If a sequence is completely 'chopped', an accnos file will be created with the names of the sequences removed. \n");
                m->mothurOut("The chop.seqs command parameters are fasta, numbases, countgaps and keep. fasta and numbases are required required.\n");
                m->mothurOut("The chop.seqs command should be in the following format: chop.seqs(fasta=yourFasta, numbases=yourNum, keep=yourKeep).\n");
                m->mothurOut("The numbases parameter allows you to specify the number of bases you want to keep.\n");
@@ -155,7 +155,7 @@ void ChopSeqsCommand::help(){
 int ChopSeqsCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta";
                string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos";
@@ -202,6 +202,21 @@ int ChopSeqsCommand::execute(){
                
                m->mothurOutEndLine();
                
+               //set fasta file as new current fastafile
+               string current = "";
+               itTypes = outputTypes.find("fasta");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
+               }
+               
+               if (wroteAccnos) { //set accnos file as new current accnosfile
+                       itTypes = outputTypes.find("accnos");
+                       if (itTypes != outputTypes.end()) {
+                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
+                       }
+               }
+               
+               
                return 0;               
        }