]> git.donarmstrong.com Git - mothur.git/blobdiff - chimerauchimecommand.h
Merge remote-tracking branch 'origin/master'
[mothur.git] / chimerauchimecommand.h
index f6e0ab55d5cff328c4a6a247ddb2b72e1ee26df6..5423a171d5698bda82c5869401e3509e1f059439 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.uchime";              }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "uchime by Robert C. Edgar\nhttp://drive5.com/uchime\nThis code is donated to the public domain.\nhttp://www.mothur.org/wiki/Chimera.uchime\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection, Bioinformatics, in press.\n"; }
        string getDescription()         { return "detect chimeric sequences"; }
@@ -45,7 +46,7 @@ private:
        int createProcesses(string, string, string, string, int&);
                
        bool abort, useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract;
-       string fastafile, groupfile, templatefile, outputDir, namefile, abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
+       string fastafile, groupfile, templatefile, outputDir, namefile, abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract, uchimeLocation;
        int processors;
        
        
@@ -59,7 +60,7 @@ private:
        int printFile(vector<seqPriorityNode>&, string);
        int deconvoluteResults(SequenceParser&, string, string, string);
        int driverGroups(SequenceParser&, string, string, string, string, int, int, vector<string>);
-       int createProcessesGroups(SequenceParser&, string, string, string, string, vector<string>);
+       int createProcessesGroups(SequenceParser&, string, string, string, string, vector<string>, string, string, string);
 
 
 };
@@ -74,7 +75,7 @@ struct uchimeData {
        string namefile; 
        string groupfile;
        string outputFName;
-       string accnos, alns, filename, templatefile;
+       string accnos, alns, filename, templatefile, uchimeLocation;
        MothurOut* m;
        int start;
        int end;
@@ -84,7 +85,7 @@ struct uchimeData {
        string abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
        
        uchimeData(){}
-       uchimeData(string o, string t, string file, string f, string n, string g, string ac,  string al, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
+       uchimeData(string o, string uloc, string t, string file, string f, string n, string g, string ac,  string al, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
                fastafile = f;
                namefile = n;
                groupfile = g;
@@ -100,6 +101,7 @@ struct uchimeData {
                groups = gr;
                count = 0;
                numChimeras = 0;
+        uchimeLocation = uloc;
        }
        void setBooleans(bool Abskew, bool calns, bool MinH, bool Mindiv, bool Xn, bool Dn, bool Xa, bool Chunks, bool Minchunk, bool Idsmoothwindow, bool Minsmoothid, bool Maxp, bool skipgap, bool skipgap2, bool Minlen, bool Maxlen, bool uc, bool Queryfract) {
                useAbskew = Abskew;
@@ -141,7 +143,7 @@ struct uchimeData {
 };
 
 /**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 #else
 static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){ 
        uchimeData* pDataArray;
@@ -149,6 +151,10 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){
        
        try {
                
+               pDataArray->outputFName = pDataArray->m->getFullPathName(pDataArray->outputFName);
+               pDataArray->filename = pDataArray->m->getFullPathName(pDataArray->filename);
+               pDataArray->alns = pDataArray->m->getFullPathName(pDataArray->alns);
+               
                //clears files
                ofstream out, out1, out2;
                pDataArray->m->openOutputFile(pDataArray->outputFName, out); out.close(); 
@@ -179,18 +185,8 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){
                        
                        vector<char*> cPara;
                        
-                       string path = pDataArray->m->argv;
-                       string tempPath = path;
-                       for (int j = 0; j < path.length(); j++) { tempPath[j] = tolower(path[j]); }
-                       path = path.substr(0, (tempPath.find_last_of('m')));
-                       
-                       string uchimeCommand = path;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-                       uchimeCommand += "uchime ";
-#else
-                       uchimeCommand += "uchime";
-                       uchimeCommand = "\"" + uchimeCommand + "\"";
-#endif                 
+            string uchimeCommand = pDataArray->uchimeLocation;
+            uchimeCommand = "\"" + uchimeCommand + "\"";
                        
                        char* tempUchime;
                        tempUchime= new char[uchimeCommand.length()+1]; 
@@ -326,17 +322,6 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){
                                cPara.push_back(tempIdsmoothwindow);
                        }
                        
-                       /*if (useMinsmoothid) {
-                        char* tempminsmoothid = new char[14]; 
-                        //strcpy(tempminsmoothid, "--minsmoothid"); 
-                        *tempminsmoothid = '\0'; strncat(tempminsmoothid, "--minsmoothid", 13);
-                        cPara.push_back(tempminsmoothid);
-                        char* tempMinsmoothid = new char[minsmoothid.length()+1];
-                        *tempMinsmoothid = '\0'; strncat(tempMinsmoothid, minsmoothid.c_str(), minsmoothid.length());
-                        //strcpy(tempMinsmoothid, minsmoothid.c_str());
-                        cPara.push_back(tempMinsmoothid);
-                        }*/
-                       
                        if (pDataArray->useMaxp) {
                                char* tempmaxp = new char[7]; 
                                //strcpy(tempmaxp, "--maxp"); 
@@ -410,10 +395,10 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){
                        
                        //uchime_main(numArgs, uchimeParameters); 
                        //cout << "commandString = " << commandString << endl;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-#else
                        commandString = "\"" + commandString + "\"";
-#endif
+            
+            if (pDataArray->m->debug) { pDataArray->m->mothurOut("[DEBUG]: uchime command = " + commandString + ".\n"); }
+            
                        system(commandString.c_str());
                        
                        //free memory
@@ -494,6 +479,10 @@ static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){
        
        try {
                
+               pDataArray->outputFName = pDataArray->m->getFullPathName(pDataArray->outputFName);
+               pDataArray->filename = pDataArray->m->getFullPathName(pDataArray->filename);
+               pDataArray->alns = pDataArray->m->getFullPathName(pDataArray->alns);
+               
                int totalSeqs = 0;
                int numChimeras = 0;
        
@@ -508,11 +497,14 @@ static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){
                
                vector<char*> cPara;
                
-               char* tempUchime;
-               tempUchime= new char[8]; 
-               *tempUchime = '\0';
-               strncat(tempUchime, "uchime ", 7); 
-               cPara.push_back(tempUchime);
+               string uchimeCommand = pDataArray->uchimeLocation;
+        uchimeCommand = "\"" + uchimeCommand + "\"";
+        
+        char* tempUchime;
+        tempUchime= new char[uchimeCommand.length()+1]; 
+        *tempUchime = '\0';
+        strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
+        cPara.push_back(tempUchime);
                
                char* tempIn = new char[8]; 
                *tempIn = '\0'; strncat(tempIn, "--input", 7);
@@ -725,6 +717,7 @@ static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){
                
                //uchime_main(numArgs, uchimeParameters); 
                //cout << "commandString = " << commandString << endl;
+        if (pDataArray->m->debug) { pDataArray->m->mothurOut("[DEBUG]: uchime command = " + commandString + ".\n"); }
                system(commandString.c_str());
                
                //free memory