]> git.donarmstrong.com Git - mothur.git/blobdiff - makefastqcommand.cpp
cleaned up code
[mothur.git] / makefastqcommand.cpp
index 995dc6606d86963d64d1bee857233c9656836da6..c6dcf2c83092303abdd685848efe9c875ca75976 100644 (file)
@@ -37,7 +37,7 @@ string MakeFastQCommand::getHelpString(){
                helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
                helpString += "The make.fastq command should be in the following format: make.fastq(qfile=yourQualityFile, fasta=yourFasta).\n";
                helpString += "Example make.fastq(fasta=amazon.fasta, qfile=amazon.qual).\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) {
@@ -46,6 +46,26 @@ string MakeFastQCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MakeFastQCommand::getOutputFileNameTag(string type, string inputName=""){       
+       try {
+        string outputFileName = "";
+               map<string, vector<string> >::iterator it;
+        
+        //is this a type this command creates
+        it = outputTypes.find(type);
+        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
+        else {
+            if (type == "fastq")             {   outputFileName =  "fastq";         }
+            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
+        }
+        return outputFileName;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MakeFastQCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 MakeFastQCommand::MakeFastQCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -65,6 +85,7 @@ MakeFastQCommand::MakeFastQCommand(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();
@@ -115,7 +136,7 @@ MakeFastQCommand::MakeFastQCommand(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); }   
                        
                        qualfile = validParameter.validFile(parameters, "qfile", true);
                        if (qualfile == "not open") { abort = true; qualfile = ""; }
@@ -123,7 +144,7 @@ MakeFastQCommand::MakeFastQCommand(string option)  {
                                qualfile = m->getQualFile(); 
                                if (qualfile != "") {  m->mothurOut("Using " + qualfile + " as input file for the qfile parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("You have no current qualfile and the qfile parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }       
+                       }else { m->setQualFile(qualfile); }     
                        
                        //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);              }
@@ -144,7 +165,7 @@ int MakeFastQCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "fastq";
+               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fastq");
                outputNames.push_back(outputFile); outputTypes["fastq"].push_back(outputFile);
                
                ofstream out;
@@ -180,7 +201,7 @@ int MakeFastQCommand::execute(){
                qFile.close();
                out.close();
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0; }
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -200,7 +221,7 @@ string MakeFastQCommand::convertQual(vector<int> qual) {
        try {
                string qualScores;
                
-               int controlChar = int('!');
+               int controlChar = int('@');
                
                for (int i = 0; i < qual.size(); i++) { 
                        int temp = qual[i] + controlChar;