+/**************************************************************************************************/
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+#else
+static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){
+ classifyData* pDataArray;
+ pDataArray = (classifyData*)lpParam;
+
+ try {
+ ofstream outTax;
+ pDataArray->m->openOutputFile(pDataArray->taxFName, outTax);
+
+ ofstream outTaxSimple;
+ pDataArray->m->openOutputFile(pDataArray->tempTFName, outTaxSimple);
+
+ ofstream outAcc;
+ pDataArray->m->openOutputFile(pDataArray->accnos, outAcc);
+
+ ifstream inFASTA;
+ pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
+
+ string taxonomy;
+
+ //print header if you are process 0
+ if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
+ inFASTA.seekg(0);
+ }else { //this accounts for the difference in line endings.
+ inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA);
+ }
+
+ pDataArray->count = pDataArray->end;
+
+ //make classify
+ Classify* myclassify;
+ if(pDataArray->method == "bayesian"){ myclassify = new Bayesian(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->cutoff, pDataArray->iters, pDataArray->threadID, pDataArray->flip, pDataArray->writeShortcuts); }
+ else if(pDataArray->method == "knn"){ myclassify = new Knn(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->numWanted, pDataArray->threadID); }
+ else if(pDataArray->method == "zap"){
+ outputMethodTag = search + "_" + outputMethodTag;
+ if (pDataArray->search == "kmer") { myclassify = new KmerTree(pDataArray->templateFileName, pDataArray->taxonomyFileName, pDataArray->kmerSize, pDataArray->cutoff); }
+ else { myclassify = new AlignTree(pDataArray->templateFileName, pDataArray->taxonomyFileName, pDataArray->cutoff); }
+ }
+ else {
+ pDataArray->m->mothurOut(pDataArray->search + " is not a valid method option. I will run the command using bayesian.");
+ pDataArray->m->mothurOutEndLine();
+ myclassify = new Bayesian(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->cutoff, pDataArray->iters, pDataArray->threadID, pDataArray->flip, pDataArray->writeShortcuts);
+ }
+
+ if (pDataArray->m->control_pressed) { delete myclassify; return 0; }
+
+ int count = 0;
+ for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
+
+ if (pDataArray->m->control_pressed) { delete myclassify; return 0; }
+
+ Sequence* candidateSeq = new Sequence(inFASTA); pDataArray->m->gobble(inFASTA);
+
+ if (candidateSeq->getName() != "") {
+
+ taxonomy = myclassify->getTaxonomy(candidateSeq);
+
+ if (pDataArray->m->control_pressed) { delete candidateSeq; return 0; }
+
+ if (taxonomy == "unknown;") { pDataArray->m->mothurOut("[WARNING]: " + candidateSeq->getName() + " could not be classified. You can use the remove.lineage command with taxon=unknown; to remove such sequences."); pDataArray->m->mothurOutEndLine(); }
+
+ //output confidence scores or not
+ if (pDataArray->probs) {
+ outTax << candidateSeq->getName() << '\t' << taxonomy << endl;
+ }else{
+ outTax << candidateSeq->getName() << '\t' << myclassify->getSimpleTax() << endl;
+ }
+
+ outTaxSimple << candidateSeq->getName() << '\t' << myclassify->getSimpleTax() << endl;
+
+ if (myclassify->getFlipped()) { outAcc << candidateSeq->getName() << endl; }
+
+ count++;
+ }
+ delete candidateSeq;
+ //report progress
+ if((count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+
+ }
+ //report progress
+ if((count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+
+ delete myclassify;
+ inFASTA.close();
+ outTax.close();
+ outTaxSimple.close();
+
+ }
+ catch(exception& e) {
+ pDataArray->m->errorOut(e, "ClassifySeqsCommand", "MyClassThreadFunction");
+ exit(1);
+ }
+}
+#endif
+
+
+
+