]> git.donarmstrong.com Git - mothur.git/commitdiff
minor bug in chimera maligner
authorwestcott <westcott>
Mon, 25 Apr 2011 18:00:39 +0000 (18:00 +0000)
committerwestcott <westcott>
Mon, 25 Apr 2011 18:00:39 +0000 (18:00 +0000)
chimeraslayer.cpp
chimeraslayercommand.cpp
maligner.cpp
mothur.cpp
sharedcommand.cpp

index c6613bfd507c3dd74f00edeaaa452c8e9d39e950..73037c783be84270a28b0dacf1795c51a3668d0e 100644 (file)
@@ -751,14 +751,14 @@ int ChimeraSlayer::getChimeras(Sequence* query) {
                if (m->control_pressed) {  return 0;  }
                
                vector<results> Results = maligner.getOutput();
-       
-               if (realign) {
-                       ChimeraReAligner realigner(thisTemplate, match, misMatch);
-                       realigner.reAlign(query, Results);
-               }
 
                if (chimeraFlag == "yes") {
                        
+                       if (realign) {
+                               ChimeraReAligner realigner(thisTemplate, match, misMatch);
+                               realigner.reAlign(query, Results);
+                       }
+                       
                        //get sequence that were given from maligner results
                        vector<SeqDist> seqs;
                        map<string, float> removeDups;
index cf082f87a2721650d50ffed24c4a0a55a3ffa469..9b49a4f3b4fdad3b1468abbbe512067b25c6c023 100644 (file)
@@ -635,7 +635,7 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f
                
                        Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
                        string candidateAligned = candidateSeq->getAligned();
-                               
+                       
                        if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
                                
                                if (candidateSeq->getAligned().length() != templateSeqsLength) {  
@@ -698,15 +698,16 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f
                                }
                                count++;
                        }
-                       delete candidateSeq;
                        
                        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                                unsigned long int pos = inFASTA.tellg();
+                       //cout << candidateSeq->getName() << '\t' << pos << endl;
                                if ((pos == -1) || (pos >= filePos->end)) { break; }
                        #else
                                if (inFASTA.eof()) { break; }
                        #endif
                        
+                       delete candidateSeq;
                        //report progress
                        if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
                }
index 4a00c1d47709d2137a2f79e875367b55bde1ed95..252b453cb6989868f65ceb71e59a27587d9baa7a 100644 (file)
@@ -106,7 +106,7 @@ string Maligner::chimeraMaligner(int chimeraPenalty, DeCalculator* decalc) {
 //             }
                
                if (trace.size() > 1) {         chimera = "yes";        }
-               else { chimera = "no";  }
+               else { chimera = "no";  return chimera; }
                
                int traceStart = trace[0].col;
                int traceEnd = trace[trace.size()-1].oldCol;    
index 67ede87039d783c71a40a0317d3a1ccbffdc7b97..b551302646c10b813740516eaa65cc46453b4a1d 100644 (file)
@@ -78,13 +78,14 @@ int main(int argc, char *argv[]){
                m->setVersion(mothurVersion);
                
                //will make the gui output "pretty"
-               bool guiMode = false;
+               bool outputHeader = true;
                if (argc>1) {
                        string guiInput = argv[1];
-                       if (guiInput[0] == '+') { guiMode = true; }
+                       if (guiInput[0] == '+') { outputHeader = false; }
+                       if (guiInput[0] == '-') { outputHeader = false; }
                }
                
-               if (!guiMode) {
+               if (outputHeader)  {
                        //version
                        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                                #if defined (__APPLE__) || (__MACH__)
@@ -161,7 +162,7 @@ int main(int argc, char *argv[]){
                //srand(54321);
                srand( (unsigned)time( NULL ) );
                
-               Engine* mothur;
+               Engine* mothur = NULL;
                bool bail = 0;
                string input;
  
@@ -177,6 +178,12 @@ int main(int argc, char *argv[]){
                        }else if (input[0] == '+') {
                                        mothur = new ScriptEngine(argv[0], argv[1]);
                                        m->gui = true;
+                       }else if (input == "-version") {
+                               m->mothurOut("Mothur version=" + mothurVersion + "\nRelease Date=" + releaseDate); m->mothurOutEndLine(); m->mothurOutEndLine(); m->closeLog();
+                               #ifdef USE_MPI
+                                       MPI_Finalize();
+                               #endif
+                               return 0;
                        }else{
                                m->mothurOutJustToLog("Batch Mode");
                                m->mothurOutEndLine(); m->mothurOutEndLine();
@@ -229,7 +236,7 @@ int main(int argc, char *argv[]){
                }
                
                                
-               delete mothur;
+               if (mothur != NULL) { delete mothur; }
                
                #ifdef USE_MPI
                        MPI_Finalize();
index 2b4d56ec44591400f977e365f6501e89170c9f02..cb4b4e6ced702b08d2b1dda3668f376a82e1e624 100644 (file)
@@ -58,6 +58,7 @@ SharedCommand::SharedCommand(){
                vector<string> tempOutNames;
                outputTypes["rabund"] = tempOutNames;
                outputTypes["shared"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "SharedCommand", "SharedCommand");
@@ -136,7 +137,7 @@ SharedCommand::SharedCommand(string option)  {
                         else if (ordergroupfile == "not found") { ordergroupfile = ""; }
                                                 
                         groupfile = validParameter.validFile(parameters, "group", true);
-                        if (groupfile == "not open") { abort = true; } 
+                        if (groupfile == "not open") { groupfile = ""; abort = true; } 
                         else if (groupfile == "not found") { 
                                 groupfile = m->getGroupFile(); 
                                 if (groupfile != "") { 
@@ -172,41 +173,6 @@ SharedCommand::SharedCommand(string option)  {
                                 if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                 else { allLines = 1;  }
                         }
-                       
-                       //getting output filename
-                       filename = listfile;
-                       if (outputDir == "") { outputDir += m->hasPath(filename); }
-                                       
-                       filename = outputDir + m->getRootName(m->getSimpleName(filename));
-                       filename = filename + "shared";
-                       outputTypes["shared"].push_back(filename);
-                               
-                       m->openOutputFile(filename, out);
-                       pickedGroups = false;
-                                               
-                       //if hte user has not specified any groups then use them all
-                       if (Groups.size() == 0) {
-                               Groups = groupMap->namesOfGroups; m->Groups = Groups;
-                       }
-                       
-                       //fill filehandles with neccessary ofstreams
-                       int i;
-                       ofstream* temp;
-                       for (i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]] = temp;
-                       }
-                               
-                       //set fileroot
-                       fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
-                               
-                       //clears file before we start to write to it below
-                       for (int i=0; i<Groups.size(); i++) {
-                               remove((fileroot + Groups[i] + ".rabund").c_str());
-                               outputNames.push_back((fileroot + Groups[i] + ".rabund"));
-                               outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
-                       }
-                       
                }
                
        }
@@ -222,6 +188,41 @@ int SharedCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
+               //getting output filename
+               filename = listfile;
+               
+               if (outputDir == "") { outputDir += m->hasPath(filename); }
+               
+               filename = outputDir + m->getRootName(m->getSimpleName(filename));
+               filename = filename + "shared";
+               outputTypes["shared"].push_back(filename);
+               
+               m->openOutputFile(filename, out);
+               pickedGroups = false;
+               
+               //if hte user has not specified any groups then use them all
+               if (Groups.size() == 0) {
+                       Groups = groupMap->namesOfGroups; m->Groups = Groups;
+               }else { pickedGroups = true; }
+               
+               //fill filehandles with neccessary ofstreams
+               int i;
+               ofstream* temp;
+               for (i=0; i<Groups.size(); i++) {
+                       temp = new ofstream;
+                       filehandles[Groups[i]] = temp;
+               }
+               
+               //set fileroot
+               fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
+               
+               //clears file before we start to write to it below
+               for (int i=0; i<Groups.size(); i++) {
+                       remove((fileroot + Groups[i] + ".rabund").c_str());
+                       outputNames.push_back((fileroot + Groups[i] + ".rabund"));
+                       outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
+               }
+               
                //lookup.clear();
                string errorOff = "no error";
                //errorOff = "";
@@ -261,7 +262,7 @@ int SharedCommand::execute(){
                }
                
                //if user has specified groups make new groupfile for them
-               if (m->Groups.size() != 0) { //make new group file
+               if (pickedGroups) { //make new group file
                        string groups = "";
                        if (m->Groups.size() < 4) {
                                for (int i = 0; i < m->Groups.size(); i++) {
@@ -270,6 +271,8 @@ int SharedCommand::execute(){
                        }else { groups = "merge"; }
                
                        string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + "groups";
+                       outputTypes["group"].push_back(newGroupFile); 
+                       outputNames.push_back(newGroupFile);
                        ofstream outGroups;
                        m->openOutputFile(newGroupFile, outGroups);
                
@@ -420,6 +423,11 @@ int SharedCommand::execute(){
                        if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
                }       
                
+               itTypes = outputTypes.find("group");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
+               }
+               
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }