]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
added forward and reverse barcodes to trim.seqs to process illumina seqs
[mothur.git] / filterseqscommand.cpp
index 806ca0d69cabd6056de8ce1870c628e40916e080..a7d42b331bc3044de372c030175da4663f9e3a9c 100644 (file)
@@ -125,7 +125,12 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                        fasta = validParameter.validFile(parameters, "fasta", false);
                        if (fasta == "not found") {                             
                                fasta = m->getFastaFile(); 
-                               if (fasta != "") { fastafileNames.push_back(fasta);  m->mothurOut("Using " + fasta + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
+                               if (fasta != "") { 
+                    fastafileNames.push_back(fasta);  
+                    m->mothurOut("Using " + fasta + " as input file for the fasta parameter."); m->mothurOutEndLine();
+                    string simpleName = m->getSimpleName(fasta);
+                    filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
+                }
                                else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
                        }
                        else { 
@@ -420,8 +425,21 @@ int FilterSeqsCommand::filterSequences() {
                                MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                                
 #else
-                       vector<unsigned long long> positions = savedPositions[s];
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+            
+            vector<unsigned long long> positions;
+            if (savedPositions.size() != 0) { positions = savedPositions[s]; }
+            else {
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+                               positions = m->divideFile(fastafileNames[s], processors);
+#else
+                if(processors != 1){
+                    int numFastaSeqs = 0;
+                    positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); 
+                    if (positions.size() < processors) { processors = positions.size(); }
+                }
+#endif
+            }
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                        //vector<unsigned long long> positions = m->divideFile(fastafileNames[s], processors);
                        
                        for (int i = 0; i < (positions.size()-1); i++) {
@@ -578,7 +596,7 @@ int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string i
                                count++;
                        }
                        
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                unsigned long long pos = in.tellg();
                                if ((pos == -1) || (pos >= filePos->end)) { break; }
                        #else
@@ -611,7 +629,7 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename, strin
                int num = 0;
                processIDS.clear();
         
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                
                
                //loop through and create all the processes you want
@@ -799,7 +817,7 @@ string FilterSeqsCommand::createFilter() {
 #else
                                
                 vector<unsigned long long> positions;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                positions = m->divideFile(fastafileNames[s], processors);
                                for (int i = 0; i < (positions.size()-1); i++) {
                                        lines.push_back(new linePair(positions[i], positions[(i+1)]));
@@ -820,6 +838,7 @@ string FilterSeqsCommand::createFilter() {
                                }else {
                     int numFastaSeqs = 0;
                     positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); 
+                    if (positions.size() < processors) { processors = positions.size(); }
                     
                     //figure out how many sequences you have to process
                     int numSeqsPerProcessor = numFastaSeqs / processors;
@@ -957,7 +976,7 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair*
                                        count++;
                        }
                        
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                unsigned long long pos = in.tellg();
                                if ((pos == -1) || (pos >= filePos->end)) { break; }
                        #else
@@ -1033,7 +1052,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename)
                int num = 0;
                processIDS.clear();
 
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                
                //loop through and create all the processes you want
                while (process != processors) {