X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classifyseqscommand.h;h=6d11d9236778028e326c6f4fdd4925dd6430fd50;hb=ea4f373c28543cd1002b0dd7dc6e55c526647d59;hp=0e21a203caaa0c4a8166d7ecb08a685cd36f3169;hpb=0ca63a8165baa0afa459e644ebe140ba496d5ba0;p=mothur.git diff --git a/classifyseqscommand.h b/classifyseqscommand.h index 0e21a20..6d11d92 100644 --- a/classifyseqscommand.h +++ b/classifyseqscommand.h @@ -10,7 +10,7 @@ * */ -#include "mothur.h" + #include "command.hpp" #include "classify.h" #include "referencedb.h" @@ -41,6 +41,7 @@ public: vector setParameters(); string getCommandName() { return "classify.seqs"; } string getCommandCategory() { return "Phylotype Analysis"; } + string getOutputFileNameTag(string, string); string getHelpString(); string getCitation() { return "Wang Q, Garrity GM, Tiedje JM, Cole JR (2007). Naive Bayesian classifier for rapid assignment of rRNA sequences into the new bacterial taxonomy. Appl Environ Microbiol 73: 5261-7. [ for Bayesian classifier ] \nAltschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ (1997). Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Res 25: 3389-402. [ for BLAST ] \nDeSantis TZ, Hugenholtz P, Larsen N, Rojas M, Brodie EL, Keller K, Huber T, Dalevi D, Hu P, Andersen GL (2006). Greengenes, a chimera-checked 16S rRNA gene database and workbench compatible with ARB. Appl Environ Microbiol 72: 5069-72. [ for kmer ] \nhttp://www.mothur.org/wiki/Classify.seqs"; } string getDescription() { return "classify sequences"; } @@ -61,6 +62,7 @@ private: vector lines; vector fastaFileNames; vector namefileNames; + vector countfileNames; vector groupfileNames; vector outputNames; map > nameMap; @@ -69,19 +71,18 @@ private: Classify* classify; ReferenceDB* rdb; - string fastaFileName, templateFileName, distanceFileName, namefile, search, method, taxonomyFileName, outputDir, groupfile; + string fastaFileName, templateFileName, countfile, distanceFileName, namefile, search, method, taxonomyFileName, outputDir, groupfile; int processors, kmerSize, numWanted, cutoff, iters; float match, misMatch, gapOpen, gapExtend; - bool abort, probs, save; + bool abort, probs, save, flip, hasName, hasCount, writeShortcuts; - int driver(linePair*, string, string, string); - void appendTaxFiles(string, string); - int createProcesses(string, string, string); + int driver(linePair*, string, string, string, string); + int createProcesses(string, string, string, string); string addUnclassifieds(string, int); int MPIReadNamesFile(string); #ifdef USE_MPI - int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector&); + int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector&); #endif }; @@ -93,16 +94,17 @@ struct classifyData { string taxFName; string tempTFName; string filename; - string search, taxonomyFileName, templateFileName, method; + string search, taxonomyFileName, templateFileName, method, accnos; unsigned long long start; unsigned long long end; MothurOut* m; float match, misMatch, gapOpen, gapExtend; int count, kmerSize, threadID, cutoff, iters, numWanted; - bool probs; + bool probs, flip, writeShortcuts; classifyData(){} - classifyData(bool p, string me, string te, string tx, string a, string r, string f, string se, int ks, int i, int numW, MothurOut* mout, unsigned long long st, unsigned long long en, float ma, float misMa, float gapO, float gapE, int cut, int tid) { + classifyData(string acc, bool p, string me, string te, string tx, string a, string r, string f, string se, int ks, int i, int numW, MothurOut* mout, unsigned long long st, unsigned long long en, float ma, float misMa, float gapO, float gapE, int cut, int tid, bool fli, bool wsh) { + accnos = acc; taxonomyFileName = tx; templateFileName = te; taxFName = a; @@ -124,11 +126,13 @@ struct classifyData { threadID = tid; probs = p; count = 0; + flip = fli; + writeShortcuts = wsh; } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ classifyData* pDataArray; @@ -141,6 +145,9 @@ static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ ofstream outTaxSimple; pDataArray->m->openOutputFile(pDataArray->tempTFName, outTaxSimple); + ofstream outAcc; + pDataArray->m->openOutputFile(pDataArray->accnos, outAcc); + ifstream inFASTA; pDataArray->m->openInputFile(pDataArray->filename, inFASTA); @@ -157,12 +164,12 @@ static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ //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); } + 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 { 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); + 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; } @@ -180,16 +187,19 @@ static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ if (pDataArray->m->control_pressed) { delete candidateSeq; return 0; } - if (taxonomy != "bad seq") { - //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 (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;