]> git.donarmstrong.com Git - mothur.git/blobdiff - readtree.cpp
committing so I can work on the other machine
[mothur.git] / readtree.cpp
index 51f44e217899c3acebc1a34879b31d6624389191..1df49b5502f405bf29b31ee585fb5d6a264f9cda 100644 (file)
@@ -296,6 +296,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
 
                        int rc = readNewickInt(f, n, T);
                        if (rc == -1) { return -1; }  //reports an error in reading     
+                       
                        if(f.peek()==')'){      
                                readSpecialChar(f,')',"right parenthesis");     
                                //to pass over labels in trees
@@ -316,23 +317,52 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                        }                                               
                        
                        //to account for multifurcating trees generated by fasttree, we are forcing them to be bifurcating
-               /*      if(f.peek() == ','){
+                       while(f.peek() == ','){
                                
                                //force this node to be left child and read new rc
                                T->tree[n].setChildren(lc,rc);
                                T->tree[lc].setParent(n);
                                T->tree[rc].setParent(n);
                                
+                               T->printTree(); cout << endl;
+                               lc = n;
                                n++;
                                
+                               readSpecialChar(f,',',"comma");
 
-                       
-                       }*/
-                       
+                               int rc = readNewickInt(f, n, T);
+               cout << n << '\t' << lc << '\t' << rc << endl;
+                               if (rc == -1) { return -1; }  //reports an error in reading     
+                               
+                               if(f.peek()==')'){      
+                               string k;
+                               k = f.peek();
+               cout << "in here " << k << endl;
+                                       readSpecialChar(f,')',"right parenthesis");     
+                                       //to pass over labels in trees
+                                       c=filehandle.get();
+                                       while((c!=',') && (c != -1) && (c!= ':') && (c!=';')){ c=filehandle.get(); }
+                                       filehandle.putback(c);
+                                       
+                                       if(f.peek() == ':'){                                                                          
+                                       readSpecialChar(f,':',"colon"); 
+                                       
+                                       if(n >= numNodes){      m->mothurOut("Error: Too many nodes in input tree\n");  readOk = -1; return -1; }
+                                       
+                                       T->tree[n].setBranchLength(readBranchLength(f));
+                                       }else{
+                                               T->tree[n].setBranchLength(0.0); 
+                                       }                                               
+
+                                       break;
+                               }                       
+                       }
+       cout << n << '\t' << lc << '\t' << rc << endl;          
                        T->tree[n].setChildren(lc,rc);
                        T->tree[lc].setParent(n);
                        T->tree[rc].setParent(n);
-               
+                       T->printTree();  cout << endl;
+                       
                        return n++;
                }else{
                        f.putback(c);
@@ -342,7 +372,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
                                name += d;
                                d=f.get();
                        }
-               
+               cout << name << endl;
                        int blen = 0;
                        if(d == ':')    {               blen = 1;       }