]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeracheckrdp.cpp
modified mpi code to save ram by writing out every 10 seqs.
[mothur.git] / chimeracheckrdp.cpp
index 0a2ea59e0257b9fb58be28e9ca0cb3e0356d749e..790d3ebe01100c1d615be9d189e73d6fa03f28ef 100644 (file)
@@ -19,15 +19,15 @@ ChimeraCheckRDP::~ChimeraCheckRDP() {
                delete kmer;
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "~AlignSim");
+               m->errorOut(e, "ChimeraCheckRDP", "~AlignSim");
                exit(1);
        }
 }      
 //***************************************************************************************************************
-void ChimeraCheckRDP::print(ostream& out, ostream& outAcc) {
+int ChimeraCheckRDP::print(ostream& out, ostream& outAcc) {
        try {
                
-               mothurOut("Processing: " + querySeq->getName()); mothurOutEndLine();
+               m->mothurOut("Processing: " + querySeq->getName()); m->mothurOutEndLine();
                
                out << querySeq->getName() << endl;
                out << "IS scores: " << '\t';
@@ -48,26 +48,30 @@ void ChimeraCheckRDP::print(ostream& out, ostream& outAcc) {
                                makeSVGpic(IS);  //zeros out negative results
                        }
                }
+               
+               return 0;
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "print");
+               m->errorOut(e, "ChimeraCheckRDP", "print");
                exit(1);
        }
 }
 //***************************************************************************************************************
-void ChimeraCheckRDP::doPrep() {
+int ChimeraCheckRDP::doPrep() {
        try {
                templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0);
-               mothurOutEndLine();
+               m->mothurOutEndLine();
                
                kmer = new Kmer(kmerSize);
                
                if (name != "") { 
                        readName(name);  //fills name map with names of seqs the user wants to have .svg for.  
                }
+               
+               return 0;
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "doPrep");
+               m->errorOut(e, "ChimeraCheckRDP", "doPrep");
                exit(1);
        }
 }
@@ -89,7 +93,7 @@ int ChimeraCheckRDP::getChimeras(Sequence* query) {
                return 0;
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "getChimeras");
+               m->errorOut(e, "ChimeraCheckRDP", "getChimeras");
                exit(1);
        }
 }
@@ -118,14 +122,14 @@ vector<sim> ChimeraCheckRDP::findIS() {
                int start = seq.length() / 10;
                        
                //for each window
-               for (int m = start; m < (seq.length() - start); m+=increment) {
+               for (int f = start; f < (seq.length() - start); f+=increment) {
                        
-                       if ((m - kmerSize) < 0)  { mothurOut("Your sequence is too short for your kmerSize."); mothurOutEndLine(); exit(1); }
+                       if ((f - kmerSize) < 0)  { m->mothurOut("Your sequence is too short for your kmerSize."); m->mothurOutEndLine(); exit(1); }
                        
                        sim temp;
                        
-                       string fragLeft = seq.substr(0, m);  //left side of breakpoint
-                       string fragRight = seq.substr(m);  //right side of breakpoint
+                       string fragLeft = seq.substr(0, f);  //left side of breakpoint
+                       string fragRight = seq.substr(f);  //right side of breakpoint
                        
                        //make a sequence of the left side and right side
                        Sequence* left = new Sequence(queryName, fragLeft);
@@ -145,7 +149,7 @@ vector<sim> ChimeraCheckRDP::findIS() {
                        //right side is tricky - since the counts grow on eachother to find the correct counts of only the right side you must subtract the counts of the left side
                        //iterate through left sides map to subtract the number of times you saw things before you got the the right side
                        map<int, int> rightside = queryKmerInfo[queryKmerInfo.size()-1];
-                       for (map<int, int>::iterator itleft = queryKmerInfo[m-kmerSize].begin(); itleft != queryKmerInfo[m-kmerSize].end(); itleft++) {
+                       for (map<int, int>::iterator itleft = queryKmerInfo[f-kmerSize].begin(); itleft != queryKmerInfo[f-kmerSize].end(); itleft++) {
                                int howManyTotal = queryKmerInfo[queryKmerInfo.size()-1][itleft->first];   //times that kmer was seen in total
 
                                //itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
@@ -158,7 +162,7 @@ vector<sim> ChimeraCheckRDP::findIS() {
                        }
                        
                        map<int, int> closerightside = closeRightKmerInfo[closeRightKmerInfo.size()-1];
-                       for (map<int, int>::iterator itright = closeRightKmerInfo[m-kmerSize].begin(); itright != closeRightKmerInfo[m-kmerSize].end(); itright++) {
+                       for (map<int, int>::iterator itright = closeRightKmerInfo[f-kmerSize].begin(); itright != closeRightKmerInfo[f-kmerSize].end(); itright++) {
                                int howManyTotal = closeRightKmerInfo[(closeRightKmerInfo.size()-1)][itright->first];   //times that kmer was seen in total
 
                                //itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
@@ -171,7 +175,7 @@ vector<sim> ChimeraCheckRDP::findIS() {
                        }
 
                        
-                       int nLeft = calcKmers(closeLeftKmerInfo[m-kmerSize], queryKmerInfo[m-kmerSize]);
+                       int nLeft = calcKmers(closeLeftKmerInfo[f-kmerSize], queryKmerInfo[f-kmerSize]);
 
                        int nRight = calcKmers(closerightside, rightside);
 
@@ -181,7 +185,7 @@ vector<sim> ChimeraCheckRDP::findIS() {
                        temp.leftParent = closestLeft.getName();
                        temp.rightParent = closestRight.getName();
                        temp.score = is;
-                       temp.midpoint = m;
+                       temp.midpoint = f;
                        
                        isValues.push_back(temp);
                        
@@ -193,7 +197,7 @@ vector<sim> ChimeraCheckRDP::findIS() {
        
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "findIS");
+               m->errorOut(e, "ChimeraCheckRDP", "findIS");
                exit(1);
        }
 }
@@ -215,7 +219,7 @@ void ChimeraCheckRDP::readName(string namefile) {
        
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "readName");
+               m->errorOut(e, "ChimeraCheckRDP", "readName");
                exit(1);
        }
 }
@@ -252,7 +256,7 @@ int ChimeraCheckRDP::calcKmers(map<int, int> query, map<int, int> subject) {
                
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "calcKmers");
+               m->errorOut(e, "ChimeraCheckRDP", "calcKmers");
                exit(1);
        }
 }
@@ -310,7 +314,7 @@ void ChimeraCheckRDP::makeSVGpic(vector<sim> info) {
 
        }
        catch(exception& e) {
-               errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
+               m->errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
                exit(1);
        }
 }