try {
m->mothurOut("The filter.seqs command reads a file containing sequences and creates a .filter and .filter.fasta file.\n");
- m->mothurOut("The filter.seqs command parameters are fasta, trump, soft, hard and vertical. \n");
+ m->mothurOut("The filter.seqs command parameters are fasta, trump, soft, hard, processors and vertical. \n");
m->mothurOut("The fasta parameter is required. You may enter several fasta files to build the filter from and filter, by separating their names with -'s.\n");
m->mothurOut("For example: fasta=abrecovery.fasta-amazon.fasta \n");
m->mothurOut("The trump parameter .... The default is ...\n");
m->mothurOut("The soft parameter .... The default is ....\n");
m->mothurOut("The hard parameter allows you to enter a file containing the filter you want to use.\n");
m->mothurOut("The vertical parameter removes columns where all sequences contain a gap character. The default is T.\n");
+ m->mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n");
m->mothurOut("The filter.seqs command should be in the following format: \n");
m->mothurOut("filter.seqs(fasta=yourFastaFile, trump=yourTrump) \n");
m->mothurOut("Example filter.seqs(fasta=abrecovery.fasta, trump=.).\n");
ofstream outFilter;
- string filterFile = outputDir + filterFileName + ".filter";
+ //prevent giantic file name
+ string filterFile;
+ if (fastafileNames.size() > 3) { filterFile = outputDir + "merge.filter"; }
+ else { filterFile = outputDir + filterFileName + ".filter"; }
+
m->openOutputFile(filterFile, outFilter);
outFilter << filter << endl;
outFilter.close();
if (m->control_pressed) { return 1; }
#else
- numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]);
+ int numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]);
numSeqs += numFastaSeqs;
if (m->control_pressed) { return 1; }
count++;
}
- unsigned long int pos = in.tellg();
- if ((pos == -1) || (pos >= filePos->end)) { break; }
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ unsigned long int pos = in.tellg();
+ if ((pos == -1) || (pos >= filePos->end)) { break; }
+ #else
+ if (in.eof()) { break; }
+ #endif
//report progress
if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
if (m->control_pressed) { return filterString; }
#else
- numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]);
+ int numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]);
numSeqs += numFastaSeqs;
if (m->control_pressed) { return filterString; }
#endif
count++;
}
- unsigned long int pos = in.tellg();
- if ((pos == -1) || (pos >= filePos->end)) { break; }
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ unsigned long int pos = in.tellg();
+ if ((pos == -1) || (pos >= filePos->end)) { break; }
+ #else
+ if (in.eof()) { break; }
+ #endif
//report progress
if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) {
try {
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- int process = 0;
+ int process = 1;
int num = 0;
processIDS.clear();
}else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
}
+ //parent do your part
+ num = driverCreateFilter(F, filename, lines[0]);
+
//force parent to wait until all the processes are done
- for (int i=0;i<processors;i++) {
+ for (int i=0;i<(processors-1);i++) {
int temp = processIDS[i];
wait(&temp);
}
- //parent reads in and combine Filter info
+ //parent reads in and combines Filter info
for (int i = 0; i < processIDS.size(); i++) {
string tempFilename = filename + toString(processIDS[i]) + "filterValues.temp";
ifstream in;