]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed unifrac bug with multiple processors if numComps was less than processors....
authorwestcott <westcott>
Fri, 18 Feb 2011 15:14:03 +0000 (15:14 +0000)
committerwestcott <westcott>
Fri, 18 Feb 2011 15:14:03 +0000 (15:14 +0000)
Mothur.xcodeproj/project.pbxproj
anosimcommand.cpp
getotuscommand.cpp
getsharedotucommand.cpp
subsamplecommand.cpp
unifracunweightedcommand.cpp
unifracweightedcommand.cpp
unweighted.cpp

index 902e927e15ac79e725a1277fa67e891c237e7576..e4797253008a0057cc5562ddef17f0c4b4a8efa2 100644 (file)
                        attributes = {
                                ORGANIZATIONNAME = "Schloss Lab";
                        };
-                       buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */;
+                       buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */;
                        compatibilityVersion = "Xcode 3.1";
                        developmentRegion = English;
                        hasScannedForEncodings = 1;
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
-               1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "Mothur" */ = {
+               1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "mothur" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                                1DEB928A08733DD80010E9CD /* Debug */,
index 835b5a04114d1f9a6df0976c64ddd0ab3b352cc5..9f537b8f6d15c115558a196996b48b58bda7fbb6 100644 (file)
@@ -408,7 +408,7 @@ int AnosimCommand::execute(){
                                
                                //print headers
                                out << "label\tgroupsCompared\tRValue\tpValue" << endl;  
-                               m->mothurOut("label\tgroupsCompared\tRValue\tpValue"); m->mothurOutEndLine();  
+                               m->mothurOut("\nlabel\tgroupsCompared\tRValue\tpValue"); m->mothurOutEndLine();  
                                out.close();
                        }
                        
@@ -510,7 +510,7 @@ int AnosimCommand::execute(){
                        
                        //print headers
                        out << "groupsCompared\tRValue\tpValue" << endl; 
-                       m->mothurOut("groupsCompared\tRValue\tpValue"); m->mothurOutEndLine();  
+                       m->mothurOut("\ngroupsCompared\tRValue\tpValue"); m->mothurOutEndLine();  
                        out.close();
                        
                        ReadPhylipVector readMatrix(phylipfile);
index b075cb4bb61521c15e77c1a2e6966a6966daee4c..f10142bb74a67a9fa98bded8b8a2e0d48fa85358 100644 (file)
@@ -186,7 +186,7 @@ int GetOtusCommand::execute(){
                groupMap = new GroupMap(groupfile);
                groupMap->readMap();
                
-               //get groups you want to remove
+               //get groups you want to get
                if (accnosfile != "") { readAccnos(); }
                
                //make sure groups are valid
index 6ca4ee2d3dd5630c1ee38efaffe268a1e5f130c3..7746ef9873498cf43dfb33c735757908606e673d 100644 (file)
@@ -196,7 +196,7 @@ void GetSharedOTUCommand::help(){
                m->mothurOut("The output parameter allows you to output the list of names without the group and bin number added. \n");
                m->mothurOut("With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n");
                m->mothurOut("The get.sharedseqs command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n");
-               m->mothurOut("The get.sharedseqs command should be in the following format: get.sabund(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
+               m->mothurOut("The get.sharedseqs command should be in the following format: get.sharedseqs(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
                m->mothurOut("Example get.sharedseqs(list=amazon.fn.list, label=unique-0.01, group=forest-pasture, fasta=amazon.fasta, output=accnos).\n");
                m->mothurOut("The output to the screen is the distance and the number of otus at that distance for the groups you specified.\n");
                m->mothurOut("The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n");
index 6b0e4f991f01f7d3a6e323f2670819e00ded79f9..223c9f5edf68c6eaa23f668e48ac0917854f6067 100644 (file)
@@ -413,7 +413,7 @@ int SubSampleCommand::getSubSampleFasta() {
                                        bool done = false;
                                        int myrand;
                                        while (!done) {
-                                               myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+                                               myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                                
                                                if (subset.count(names[myrand]) == 0)  { 
                                                        
@@ -426,6 +426,7 @@ int SubSampleCommand::getSubSampleFasta() {
                                }
                        }
                }else {
+                       
                        //randomly select a subset of those names to include in the subsample
                        for (int j = 0; j < size; j++) {
                                
@@ -435,7 +436,7 @@ int SubSampleCommand::getSubSampleFasta() {
                                bool done = false;
                                int myrand;
                                while (!done) {
-                                       myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+                                       myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                        
                                        if (subset.count(names[myrand]) == 0)  { 
                                                
@@ -762,7 +763,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup, ofs
                                        if (m->control_pressed) { delete order; return 0; }
                                        
                                        //get random number to sample from order between 0 and thisSize-1.
-                                       int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+                                       int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                        
                                        int bin = order->get(myrand);
                                        
@@ -959,7 +960,7 @@ int SubSampleCommand::getSubSampleList() {
                                        bool done = false;
                                        int myrand;
                                        while (!done) {
-                                               myrand = (int)((float)(rand()) / (RAND_MAX / (names.size()-1) + 1));
+                                               myrand = int((float)(names.size()) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                                
                                                if (subset.count(names[myrand]) == 0) { //you are not already added
                                                        if (groupMap->getGroup(names[myrand]) == Groups[i])  { subset.insert(names[myrand]); break;     }
@@ -976,7 +977,7 @@ int SubSampleCommand::getSubSampleList() {
                                bool done = false;
                                int myrand;
                                while (!done) {
-                                       myrand = (int)((float)(rand()) / (RAND_MAX / (names.size()-1) + 1));
+                                       myrand = int((float)(names.size()) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                        
                                        if (subset.count(names[myrand]) == 0)  { subset.insert(names[myrand]); break;   }
                                }
@@ -1262,7 +1263,7 @@ int SubSampleCommand::processRabund(RAbundVector*& rabund, ofstream& out) {
                                if (m->control_pressed) { delete order; return 0; }
                                
                                //get random number to sample from order between 0 and thisSize-1.
-                               int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+                               int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                
                                int bin = order->get(myrand);
                                
@@ -1422,7 +1423,7 @@ int SubSampleCommand::processSabund(SAbundVector*& sabund, ofstream& out) {
                                if (m->control_pressed) { delete order; return 0; }
                                
                                //get random number to sample from order between 0 and thisSize-1.
-                               int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+                               int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
                                
                                int bin = order->get(myrand);
                                
index 634bf0caff8d279e259c64fb76f28737aaaa8219..566fd10c8ef9ff90849896982343e6970bdeaba5 100644 (file)
@@ -198,6 +198,8 @@ int UnifracUnweightedCommand::execute() {
                randomData.resize(numComp,0); //data[0] = unweightedscore
                //create new tree with same num nodes and leaves as users
                
+               if (numComp < processors) { processors = numComp;  }
+               
                outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "UWScore" <<'\t' << "UWSig" <<  endl;
                m->mothurOut("Tree#\tGroups\tUWScore\tUWSig"); m->mothurOutEndLine();
                
index 4c387da9332c6ca280a9359105cf8dfa837cd0a9..1fa1a2833c1fa7604a9e2cbb07bf255ace9dcd94 100644 (file)
@@ -187,6 +187,8 @@ int UnifracWeightedCommand::execute() {
                //get weighted for users tree
                userData.resize(numComp,0);  //data[0] = weightedscore AB, data[1] = weightedscore AC...
                randomData.resize(numComp,0); //data[0] = weightedscore AB, data[1] = weightedscore AC...
+               
+               if (numComp < processors) { processors = numComp; }
                                
                //get weighted scores for users trees
                for (int i = 0; i < T.size(); i++) {
index 24b41a1d03317e343e05c65c7516e94778cd557c..ea66294a5354c7cab7c265c3213a967a4a5a01f9 100644 (file)
@@ -66,7 +66,6 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                
                                        lines.push_back(linePair(startPos, numPairsPerProcessor));
                                }
-
                                data = createProcesses(t, namesOfGroupCombos);
                                lines.clear();
                        }
@@ -317,7 +316,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
                                        }
                                        lines.push_back(linePair(startPos, numPairsPerProcessor));
                                }
-
+                                       
                                data = createProcesses(t, namesOfGroupCombos, true);
                                
                                lines.clear();
@@ -392,12 +391,13 @@ EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfG
                        if (!in.eof()) {
                                int num;
                                in >> num; m->gobble(in);
-                               
+                                       
                                if (m->control_pressed) { break; }
                                
                                double w; 
                                for (int j = 0; j < num; j++) {
                                        in >> w;
+                                       
                                        results.push_back(w);
                                }
                                m->gobble(in);