]> git.donarmstrong.com Git - mothur.git/blobdiff - ccode.cpp
added name option to read.tree for use in unifrac and parimony commands
[mothur.git] / ccode.cpp
index ec2e355f882d86a60aba6f520604ef06ead6e6c8..c474d7a0ad7cb54729f809cf9921ed234f48d5db 100644 (file)
--- a/ccode.cpp
+++ b/ccode.cpp
@@ -13,7 +13,7 @@
 
 
 //***************************************************************************************************************
-Ccode::Ccode(string filename, string temp) {  fastafile = filename;  templateFile = temp;  }
+Ccode::Ccode(string filename, string temp, string o) {  fastafile = filename;  templateFile = temp;  outputDir = o; }
 //***************************************************************************************************************
 
 Ccode::~Ccode() {
@@ -32,7 +32,7 @@ void Ccode::print(ostream& out) {
                
                mothurOutEndLine();
                
-               string mapInfo = getRootName(fastafile) + "mapinfo";
+               string mapInfo = outputDir + getRootName(getSimpleName(fastafile)) + "mapinfo";
                ofstream out2;
                openOutputFile(mapInfo, out2);
                
@@ -128,7 +128,7 @@ void Ccode::print(ostream& out) {
 }
 
 //***************************************************************************************************************
-void Ccode::getChimeras() {
+int Ccode::getChimeras() {
        try {
                
                //read in query sequences and subject sequences
@@ -139,6 +139,8 @@ void Ccode::getChimeras() {
                
                int numSeqs = querySeqs.size();
                
+               if (unaligned) { mothurOut("Your sequences need to be aligned when you use the bellerophon ccode."); mothurOutEndLine(); return 1;  }
+               
                closest.resize(numSeqs);
                
                refCombo.resize(numSeqs, 0);
@@ -177,18 +179,8 @@ void Ccode::getChimeras() {
                                lines.push_back(new linePair((i*linesPerProcess), numSeqs));
                        }
                        
-                       //find breakup of templatefile for quantiles
-                       if (processors == 1) {   templateLines.push_back(new linePair(0, templateSeqs.size()));  }
-                       else { 
-                               for (int i = 0; i < processors; i++) {
-                                       templateLines.push_back(new linePair());
-                                       templateLines[i]->start = int (sqrt(float(i)/float(processors)) * templateSeqs.size());
-                                       templateLines[i]->end = int (sqrt(float(i+1)/float(processors)) * templateSeqs.size());
-                               }
-                       }
                #else
                        lines.push_back(new linePair(0, numSeqs));
-                       templateLines.push_back(new linePair(0, templateSeqs.size()));
                #endif
        
                distCalc = new eachGapDist();
@@ -305,10 +297,10 @@ void Ccode::getChimeras() {
                
                //free memory
                for (int i = 0; i < lines.size(); i++)                                  {       delete lines[i];                                }
-               for (int i = 0; i < templateLines.size(); i++)                  {       delete templateLines[i];                }
                delete distCalc;
                delete decalc;
-                       
+               
+               return 0;
        }
        catch(exception& e) {
                errorOut(e, "Ccode", "getChimeras");
@@ -434,15 +426,15 @@ vector<int> Ccode::findWindows(int query) {
                it = trim[query].begin();
                
                int length = it->second - it->first;
-               
+       
                //default is wanted = 10% of total length
                if (windowSizes[query] > length) { 
                        mothurOut("You have slected a window larger than your sequence length after all filters, masks and trims have been done. I will use the default 10% of sequence length.");
                        windowSizes[query] = length / 10;
                }else if (windowSizes[query] == 0) { windowSizes[query] = length / 10;  }
-               else if (windowSizes[query] > (length 20)) {
+               else if (windowSizes[query] > (length * 0.20)) {
                        mothurOut("You have selected a window that is larger than 20% of your sequence length.  This is not recommended, but I will continue anyway."); mothurOutEndLine();
-               }else if (windowSizes[query] < (length 5)) {
+               }else if (windowSizes[query] < (length * 0.05)) {
                        mothurOut("You have selected a window that is smaller than 5% of your sequence length.  This is not recommended, but I will continue anyway."); mothurOutEndLine();
                }
                
@@ -1491,7 +1483,7 @@ void Ccode::createProcessesVariances() {
                        
                        //find the averages for the query 
                        for (int i = 0; i < querySeqs.size(); i++) {
-                               findVarianceQuery(i);  //fills varQuery[i] and sdQuery[i] also sets minimum error rate to 0.001 to avoid divide by 0.
+                               findVarianceQuery(i);  //fills v arQuery[i] and sdQuery[i] also sets minimum error rate to 0.001 to avoid divide by 0.
                        }
 #endif         
        }