]> git.donarmstrong.com Git - mothur.git/blobdiff - trimseqscommand.cpp
sens.spec changes
[mothur.git] / trimseqscommand.cpp
index 944e2cdc0a110828157301f14f2470a06ac3e052..cbf5e13603ced805d185196fad9129eacb573d22 100644 (file)
@@ -283,6 +283,7 @@ int TrimSeqsCommand::execute(){
                                                                                
                for(int i=0;i<fastaFileNames.size();i++){
                        if (isBlank(fastaFileNames[i])) { remove(fastaFileNames[i].c_str()); }
+                       else if (filesToRemove.count(fastaFileNames[i]) > 0) { remove(fastaFileNames[i].c_str()); }
                        else {
                                ifstream inFASTA;
                                string seqName;
@@ -443,7 +444,6 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                                                        }
                                                }
                                                outGroups << currSeq.getName() << '\t' << thisGroup << endl;
-                                               
                                                if(allFiles){
                                                        currSeq.printSequence(*fastaFileNames[indexToFastaFile]);                                       
                                                }
@@ -583,11 +583,14 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec){ //vector<ofstream*
                
                while(!inOligos.eof()){
                        inOligos >> type;
-                       
+                                       
                        if(type[0] == '#'){
                                while (!inOligos.eof()) {       char c = inOligos.get(); if (c == 10 || c == 13){       break;  }       } // get rest of line if there's any crap there
                        }
                        else{
+                               //make type case insensitive
+                               for(int i=0;i<type.length();i++){       type[i] = toupper(type[i]);  }
+                               
                                inOligos >> oligo;
                                
                                for(int i=0;i<oligo.length();i++){
@@ -595,7 +598,7 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec){ //vector<ofstream*
                                        if(oligo[i] == 'U')     {       oligo[i] = 'T'; }
                                }
                                
-                               if(type == "forward"){
+                               if(type == "FORWARD"){
                                        group = "";
                                        
                                        // get rest of line in case there is a primer name
@@ -614,18 +617,21 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec){ //vector<ofstream*
                                        groupVector.push_back(group);
                                        
                                        if(allFiles){
-                                               if (group != "") { //there is a group for this primer
+                                               outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
+                                               if (group == "") { //if there is not a group for this primer, then this file will not get written to, but we add it to keep the indexes correct
+                                                       filesToRemove.insert((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
+                                               }else {
                                                        outputNames.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
-                                                       outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
                                                }
                                        }
+
                                }
-                               else if(type == "reverse"){
+                               else if(type == "REVERSE"){
                                        Sequence oligoRC("reverse", oligo);
                                        oligoRC.reverseComplement();
                                        revPrimer.push_back(oligoRC.getUnaligned());
                                }
-                               else if(type == "barcode"){
+                               else if(type == "BARCODE"){
                                        inOligos >> group;
                                        
                                        //check for repeat barcodes