X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readcolumn.cpp;h=f29f70b11fd66d8b8d9a87fdb5502ed289c7d657;hb=a6c4005cb8b45030d6621404d6082723b3b98003;hp=c03c37f1feeb888c341ca4daa01c644069c155a5;hpb=163b300cfd7d4ca4e70c454be20f07b1d8346650;p=mothur.git diff --git a/readcolumn.cpp b/readcolumn.cpp index c03c37f..f29f70b 100644 --- a/readcolumn.cpp +++ b/readcolumn.cpp @@ -20,7 +20,7 @@ ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){ /***********************************************************************/ -void ReadColumnMatrix::read(NameAssignment* nameMap){ +int ReadColumnMatrix::read(NameAssignment* nameMap){ try { string firstName, secondName; @@ -38,20 +38,25 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){ //need to see if this is a square or a triangular matrix... while(fileHandle && lt == 1){ //let's assume it's a triangular matrix... + fileHandle >> firstName >> secondName >> distance; // get the row and column names and distance + + if (m->control_pressed) { fileHandle.close(); delete reading; return 0; } map::iterator itA = nameMap->find(firstName); map::iterator itB = nameMap->find(secondName); - + if(itA == nameMap->end()){ - cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; + cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; exit(1); } if(itB == nameMap->end()){ - cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; + cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1); } +//if (((itA->second == 8) && (itB->second == 1588)) || ((itA->second == 1588) && (itB->second == 8))) { cout << "found it" << endl; } if (distance == -1) { distance = 1000000; } + else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert. if(distance < cutoff && itA != itB){ if(itA->second > itB->second){ @@ -90,6 +95,7 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){ } if(lt == 0){ // oops, it was square + fileHandle.close(); //let's start over D->clear(); //let's start over @@ -97,6 +103,8 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){ while(fileHandle){ fileHandle >> firstName >> secondName >> distance; + + if (m->control_pressed) { fileHandle.close(); delete reading; return 0; } map::iterator itA = nameMap->find(firstName); map::iterator itB = nameMap->find(secondName); @@ -109,6 +117,7 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){ } if (distance == -1) { distance = 1000000; } + else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert. if(distance < cutoff && itA->second > itB->second){ PCell value(itA->second, itB->second, distance); @@ -119,22 +128,21 @@ void ReadColumnMatrix::read(NameAssignment* nameMap){ gobble(fileHandle); } } - + + if (m->control_pressed) { fileHandle.close(); delete reading; return 0; } + reading->finish(); fileHandle.close(); list->setLabel("0"); + + return 1; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ReadColumnMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "ReadColumnMatrix", "read"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ReadColumnMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } /***********************************************************************/