]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug in read.tree
authorpschloss <pschloss>
Wed, 18 Feb 2009 15:56:06 +0000 (15:56 +0000)
committerpschloss <pschloss>
Wed, 18 Feb 2009 15:56:06 +0000 (15:56 +0000)
Mothur.xcodeproj/project.pbxproj
readtree.cpp
readtree.h
unifracweightedcommand.cpp
utilities.hpp

index c3c2a7209784cb71d7e2a873046bf8b567f94b57..93e0e58cf60e16ef5098d680acc14637f59403c0 100644 (file)
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_OPTIMIZATION_LEVEL = 3;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "_GLIBCXX_DEBUG=1",
                                        "_GLIBCXX_DEBUG_PEDANTIC=1",
                        buildSettings = {
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                GCC_MODEL_TUNING = G5;
+                               GCC_OPTIMIZATION_LEVEL = 3;
                                INSTALL_PATH = /usr/local/bin;
                                PRODUCT_NAME = mothur;
                        };
index 77277e71a889171e8b248de4d7ad19c0a78babb3..1910c4a5a1761e4cf73cd95ce8a1df9b97ee4b33 100644 (file)
@@ -27,9 +27,10 @@ ReadTree::ReadTree() {
 /***********************************************************************/
 int ReadTree::readSpecialChar(istream& f, char c, string name) {
     try {
-               char d;
        
-               while(isspace(d=f.get()))               {;}
+               gobble(f);
+               char d = f.get();
+       
                if(d == EOF){
                        cerr << "Error: Input file ends prematurely, expecting a " << name << "\n";
                        exit(1);
@@ -39,10 +40,8 @@ int ReadTree::readSpecialChar(istream& f, char c, string name) {
                        exit(1);
                }
                if(d == ')' && f.peek() == '\n'){
-                       while(isspace(d=f.get()))               {;}
-                       f.putback(d);
+                       gobble(f);
                }       
-       
                return d;
        }
        catch(exception& e) {
@@ -58,8 +57,10 @@ int ReadTree::readSpecialChar(istream& f, char c, string name) {
 
 int ReadTree::readNodeChar(istream& f) {
        try {
-               char d;
-               while(isspace(d=f.get()))               {;}
+//             while(isspace(d=f.get()))               {;}
+               gobble(f);
+               char d = f.get();
+
                if(d == EOF){
                        cerr << "Error: Input file ends prematurely, expecting a left parenthesis\n";
                        exit(1);
@@ -86,7 +87,7 @@ float ReadTree::readBranchLength(istream& f) {
                        cerr << "Error: Missing branch length in input tree.\n";
                        exit(1);
                }
-    
+               gobble(f);
                return b;
        }
        catch(exception& e) {
@@ -126,6 +127,7 @@ void ReadNewickTree::read() {
                                readTreeString();  
                                //save trees for later commands
                                globaldata->gTree.push_back(T); 
+                               gobble(filehandle);
                        }
                //if you are a nexus file
                }else if ((c = filehandle.peek()) == '#') {
@@ -230,6 +232,7 @@ void ReadNewickTree::readTreeString() {
                
                if(ch == '('){
                        n = numLeaves;  //number of leaves / sequences, we want node 1 to start where the leaves left off
+
                        lc = readNewickInt(filehandle, n, T);
                
                        if(filehandle.peek()==','){                                                     
@@ -253,8 +256,8 @@ void ReadNewickTree::readTreeString() {
                        filehandle.get(name, MAX_LINE,'\n');
                        SKIPLINE(filehandle, ch);
                
-               
                        n = T->getIndex(name);
+
                        if(n!=0){
                                cerr << "Internal error: The only taxon is not taxon 0.\n";
                                exit(1);
@@ -263,7 +266,7 @@ void ReadNewickTree::readTreeString() {
                } 
                
                while((ch=filehandle.get())!=';'){;}                                            
-                       if(rooted != 1){                                                                        
+               if(rooted != 1){                                                                        
                        T->tree[n].setChildren(lc,rc);
                        T->tree[n].setBranchLength(0);
                        T->tree[n].setParent(-1);
@@ -291,7 +294,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                if(c == '('){
                        int lc = readNewickInt(f, n, T);
                        readSpecialChar(f,',',"comma");
-               
+
                        int rc = readNewickInt(f, n, T);                
                        if(f.peek()==')'){      
                                readSpecialChar(f,')',"right parenthesis");                                     
index 02b6129b21b0bc960e1d16f9d028baab374bb465..653a853c5f300de0886205217a6b8d99682627b6 100644 (file)
@@ -14,6 +14,7 @@ using namespace std;
 #include <string>
 #include <iostream>
 #include "globaldata.hpp"
+#include "utilities.hpp"
 #include "tree.h"
 
 #define MAX_LINE               513
index 4a8325afda1cf2ea95d3aa19ce228e9f4451cc96..3b3abf82db928f25bb07a7e3dfdf04f4228a35dd 100644 (file)
@@ -122,7 +122,7 @@ int UnifracWeightedCommand::execute() {
                        //copy T[i]'s info.
                        randT->getCopy(T[i]); 
                        
-                       //get pscores for random trees
+                       //get scores for random trees
                        for (int j = 0; j < iters; j++) {
                                //create a random tree with same topology as T[i], but different labels
                                randT->assembleRandomUnifracTree();
@@ -178,7 +178,7 @@ int UnifracWeightedCommand::execute() {
                        float ucumul = 0.0000;
                        float rcumul = 0.0000;
                        //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
-                       for (it = validScores[b].begin(); it != validScores[b].end(); it++) { 
+                       for (it = validScores[b].end(); it == validScores[b].begin(); it--) { 
                                it2 = uscoreFreq[b].find(it->first);
                                //user data has that score 
                                if (it2 != uscoreFreq[b].end()) { uscoreFreq[b][it->first] /= T.size(); ucumul+= it2->second;  }
index 0c67561e427737ec95e2bb9e0ae29e8b87ff46ef..bf7df2d6a96d5c294ef662ae2f1bd19bc11ff9b5 100644 (file)
@@ -58,7 +58,7 @@ string toString(const T&x, int i){
 
 /***********************************************************************/
 
-inline void gobble(ifstream& f){
+inline void gobble(istream& f){
        
        char d;
     while(isspace(d=f.get()))          {;}