X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=fullmatrix.cpp;h=43c6f2e30a6dc04458e5aab7c42a8ada3636dae5;hb=44b464979e91c2a1f144ac45ca12c14fcf6579f0;hp=0255d07f00bbcfef3a9c62658149ec39fd6fc5bf;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/fullmatrix.cpp b/fullmatrix.cpp index 0255d07..43c6f2e 100644 --- a/fullmatrix.cpp +++ b/fullmatrix.cpp @@ -44,6 +44,7 @@ FullMatrix::FullMatrix(ifstream& filehandle) { for(int i=0;i> matrix[0][i]; + if (globaldata->sim) { matrix[0][i] = 1.0 - matrix[0][i]; } } break; } @@ -56,10 +57,12 @@ FullMatrix::FullMatrix(ifstream& filehandle) { } //read rest of matrix - if (square == true) { readSquareMatrix(filehandle); } - else { readLTMatrix(filehandle); } + if (square == true) { readSquareMatrix(filehandle); } + else { readLTMatrix(filehandle); } - sortGroups(0, numSeqs-1); + filehandle.close(); + + if (!m->control_pressed) { sortGroups(0, numSeqs-1); } } catch(exception& e) { @@ -68,7 +71,7 @@ FullMatrix::FullMatrix(ifstream& filehandle) { } } /**************************************************************************/ -void FullMatrix::readSquareMatrix(ifstream& filehandle) { +int FullMatrix::readSquareMatrix(ifstream& filehandle) { try { Progress* reading; @@ -77,7 +80,7 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) { int count = 0; string group, name; - + for(int i=1;i> name; @@ -88,14 +91,22 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) { if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } for(int j=0;jcontrol_pressed) { delete reading; return 0; } + filehandle >> matrix[i][j]; + if (globaldata->sim) { matrix[i][j] = 1.0 - matrix[i][j]; } count++; reading->update(count); } } + + if (m->control_pressed) { delete reading; return 0; } + reading->finish(); delete reading; + + return 0; } catch(exception& e) { m->errorOut(e, "FullMatrix", "readSquareMatrix"); @@ -103,7 +114,7 @@ void FullMatrix::readSquareMatrix(ifstream& filehandle) { } } /**************************************************************************/ -void FullMatrix::readLTMatrix(ifstream& filehandle) { +int FullMatrix::readLTMatrix(ifstream& filehandle) { try { Progress* reading; reading = new Progress("Reading matrix: ", numSeqs * (numSeqs - 1) / 2); @@ -123,15 +134,24 @@ void FullMatrix::readLTMatrix(ifstream& filehandle) { if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); } for(int j=0;jcontrol_pressed) { delete reading; return 0; } + filehandle >> distance; + if (globaldata->sim) { distance = 1.0 - distance; } + matrix[i][j] = distance; matrix[j][i] = distance; + count++; reading->update(count); } } - + + if (m->control_pressed) { delete reading; return 0; } + reading->finish(); delete reading; + + return 0; } catch(exception& e) { m->errorOut(e, "FullMatrix", "readLTMatrix");