]> git.donarmstrong.com Git - mothur.git/blobdiff - readtree.cpp
changes while testing
[mothur.git] / readtree.cpp
index 71c4bd5b96fcd1cc435f2954616899fdde3eedb8..b9c38e973f2cea531c03c17071ed65a155bf65a3 100644 (file)
@@ -115,8 +115,10 @@ int ReadNewickTree::read(CountTable* ct) {
                
                //if you are not a nexus file 
                if ((c = filehandle.peek()) != '#') {  
-                       while((c = filehandle.peek()) != EOF) { 
+                       while((c = filehandle.peek()) != EOF) {
+                if (m->control_pressed) {  filehandle.close(); return 0; }
                                while ((c = filehandle.peek()) != EOF) {
+                    if (m->control_pressed) {  filehandle.close(); return 0; }
                                        // get past comments
                                        if(c == '[') {
                                                comment = 1;
@@ -146,9 +148,11 @@ int ReadNewickTree::read(CountTable* ct) {
                        Tree* temp = new Tree(ct);  delete temp;
                        
                        nexusTranslation(ct);  //reads file through the translation and updates treemap
-                       while((c = filehandle.peek()) != EOF) { 
+                       while((c = filehandle.peek()) != EOF) {
+                if (m->control_pressed) {  filehandle.close(); return 0; }
                                // get past comments
-                               while ((c = filehandle.peek()) != EOF) {        
+                               while ((c = filehandle.peek()) != EOF) {
+                    if (m->control_pressed) {  filehandle.close(); return 0; }
                                        if(holder == "[" || holder == "[!"){
                                                comment = 1;
                                        }
@@ -242,7 +246,7 @@ int ReadNewickTree::readTreeString(CountTable* ct) {
                        n = numLeaves;  //number of leaves / sequences, we want node 1 to start where the leaves left off
 
                        lc = readNewickInt(filehandle, n, T, ct);
-                       if (lc == -1) { m->mothurOut("error with lc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
+                       if (lc == -1) { m->mothurOut("error with lc"); m->mothurOutEndLine(); m->control_pressed = true; return -1; } //reports an error in reading
        
                        if(filehandle.peek()==','){                                                     
                                readSpecialChar(filehandle,',',"comma");
@@ -254,7 +258,7 @@ int ReadNewickTree::readTreeString(CountTable* ct) {
                
                        if(rooted != 1){                                                                
                                rc = readNewickInt(filehandle, n, T, ct);
-                               if (rc == -1) { m->mothurOut("error with rc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
+                               if (rc == -1) { m->mothurOut("error with rc"); m->mothurOutEndLine(); m->control_pressed = true; return -1; } //reports an error in reading
                                if(filehandle.peek() == ')'){                                   
                                        readSpecialChar(filehandle,')',"right parenthesis");
                                }                                                                                       
@@ -378,7 +382,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T, CountTable* ct) {
                
                        //set group info
                        vector<string> group = ct->getGroups(name);
-                       
+            //cout << name << endl;    
                        //find index in tree of name
                        int n1 = T->getIndex(name);