]> git.donarmstrong.com Git - mothur.git/blobdiff - chopseqscommand.cpp
removing chime source files from mother project.
[mothur.git] / chopseqscommand.cpp
index 8775d95abab9a4577aaad0f29feec2d15bc39694..4e06201cd352104b5ee9c9d1c41764d16473003e 100644 (file)
@@ -43,7 +43,7 @@ string ChopSeqsCommand::getHelpString(){
                helpString += "The short parameter allows you to specify you want to keep sequences that are too short to chop, default=false.\n";
                helpString += "For example, if you ran chop.seqs with numbases=200 and short=t, if a sequence had 100 bases mothur would keep the sequence rather than eliminate it.\n";
                helpString += "Example chop.seqs(fasta=amazon.fasta, numbases=200, keep=front).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n";
+               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
                return helpString;
        }
        catch(exception& e) {
@@ -73,6 +73,7 @@ ChopSeqsCommand::ChopSeqsCommand(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();
@@ -114,13 +115,13 @@ ChopSeqsCommand::ChopSeqsCommand(string option)  {
                                fastafile = m->getFastaFile(); 
                                if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }       
+                       }else { m->setFastaFile(fastafile); }   
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);      }
                        
                        string temp = validParameter.validFile(parameters, "numbases", false);  if (temp == "not found") { temp = "0"; } 
-                       convert(temp, numbases);   
+                       m->mothurConvert(temp, numbases);   
                        
                        temp = validParameter.validFile(parameters, "countgaps", false);        if (temp == "not found") { temp = "f"; } 
                        countGaps = m->isTrue(temp);  
@@ -164,7 +165,7 @@ int ChopSeqsCommand::execute(){
                        
                        Sequence seq(in);
                        
-                       if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); remove(outputFileName.c_str()); remove(outputFileNameAccnos.c_str()); return 0;  }
+                       if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputFileNameAccnos); return 0;  }
                        
                        if (seq.getName() != "") {
                                string newSeqString = getChopped(seq);
@@ -187,7 +188,7 @@ int ChopSeqsCommand::execute(){
                m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
                
                if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine(); outputNames.push_back(outputFileNameAccnos); outputTypes["accnos"].push_back(outputFileNameAccnos); }
-               else {  remove(outputFileNameAccnos.c_str());  }
+               else {  m->mothurRemove(outputFileNameAccnos);  }
                
                m->mothurOutEndLine();
                
@@ -232,7 +233,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        
                                        for (int i = 0; i < temp.length(); i++) {
                                                //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { temp[i] == '.'; }
+                                               if (toupper(temp[i]) == 'N') { temp[i] = '.'; }
                                                
                                                numBasesCounted++; 
                                                
@@ -240,7 +241,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        }
                                        
                                        if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(0, stopSpot);  }
+                                       else {  temp = temp.substr(0, stopSpot+1);  }
                                                        
                                }else { 
                                        if (!Short) { temp = ""; } //sequence too short
@@ -254,7 +255,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        
                                        for (int i = (temp.length()-1); i >= 0; i--) {
                                                //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { temp[i] == '.'; }
+                                               if (toupper(temp[i]) == 'N') { temp[i] = '.'; }
                                                
                                                numBasesCounted++; 
 
@@ -282,7 +283,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        for (int i = 0; i < temp.length(); i++) {
                                                //eliminate N's
                                                if (toupper(temp[i]) == 'N') { 
-                                                       temp[i] == '.'; 
+                                                       temp[i] = '.'; 
                                                        tempLength--;
                                                        if (tempLength < numbases) { stopSpot = 0; break; }
                                                }
@@ -293,7 +294,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        }
                                        
                                        if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(0, stopSpot);  }
+                                       else {  temp = temp.substr(0, stopSpot+1);  }
                                                        
                                }else { 
                                        if (!Short) { temp = ""; } //sequence too short
@@ -308,7 +309,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        for (int i = (temp.length()-1); i >= 0; i--) {
                                                //eliminate N's
                                                if (toupper(temp[i]) == 'N') { 
-                                                       temp[i] == '.'; 
+                                                       temp[i] = '.'; 
                                                        tempLength--;
                                                        if (tempLength < numbases) { stopSpot = 0; break; }
                                                }
@@ -319,7 +320,7 @@ string ChopSeqsCommand::getChopped(Sequence seq) {
                                        }
                                
                                        if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(stopSpot+1);  }
+                                       else {  temp = temp.substr(stopSpot);  }
                                }else { 
                                        if (!Short) { temp = ""; } //sequence too short
                                }