]> git.donarmstrong.com Git - mothur.git/blobdiff - trimseqscommand.cpp
started work on sffinfo command. fixed bug across all paralellized commands if the...
[mothur.git] / trimseqscommand.cpp
index 71cf7143c55392208523c390cfb3924304eeede9..af3bfc8fcbf5ee10cb1a50b192ff414063bd740e 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;
@@ -377,7 +378,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                        int success = 1;
                        
                        Sequence currSeq(inFASTA);
-       cout << i << '\t' << currSeq.getName() << endl;
+
                        string origSeq = currSeq.getUnaligned();
                        if (origSeq != "") {
                                int groupBar, groupPrime;
@@ -443,7 +444,6 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                                                        }
                                                }
                                                outGroups << currSeq.getName() << '\t' << thisGroup << endl;
-                                               
                                                if(allFiles){
                                                        currSeq.printSequence(*fastaFileNames[indexToFastaFile]);                                       
                                                }
@@ -519,7 +519,7 @@ int TrimSeqsCommand::setLines(string filename, vector<linePair*>& lines) {
                
                lines.clear();
                
-               vector<long int> positions;
+               vector<unsigned long int> positions;
                
                ifstream inFASTA;
                openInputFile(filename, inFASTA);
@@ -529,7 +529,7 @@ int TrimSeqsCommand::setLines(string filename, vector<linePair*>& lines) {
                        input = getline(inFASTA);
 
                        if (input.length() != 0) {
-                               if(input[0] == '>'){ long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1);     }
+                               if(input[0] == '>'){ unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1);    }
                        }
                }
                inFASTA.close();
@@ -537,7 +537,7 @@ int TrimSeqsCommand::setLines(string filename, vector<linePair*>& lines) {
                int numFastaSeqs = positions.size();
        
                FILE * pFile;
-               long size;
+               unsigned long int size;
                
                //get num bytes in file
                pFile = fopen (filename.c_str(),"rb");
@@ -552,11 +552,11 @@ int TrimSeqsCommand::setLines(string filename, vector<linePair*>& lines) {
                
                for (int i = 0; i < processors; i++) {
 
-                       long int startPos = positions[ i * numSeqsPerProcessor ];
+                       unsigned long int startPos = positions[ i * numSeqsPerProcessor ];
                        if(i == processors - 1){
                                numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;
                        }else{  
-                               long int myEnd = positions[ (i+1) * numSeqsPerProcessor ];
+                               unsigned long int myEnd = positions[ (i+1) * numSeqsPerProcessor ];
                        }
                        lines.push_back(new linePair(startPos, numSeqsPerProcessor));
                }
@@ -617,9 +617,11 @@ 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"));
                                                }
                                        }