X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readcolumn.cpp;h=53a8c4263dddc4687acc5a64cf7c5b1d27aac647;hb=e0ce7cbc93d7d2fbb753ca694182db092a0ea0e7;hp=f61a40c483b69f7418ca4d2702ca995f4180f3e2;hpb=fdc1f6eaf544f695fc1511f24bddd7e6069c33ba;p=mothur.git diff --git a/readcolumn.cpp b/readcolumn.cpp index f61a40c..53a8c42 100644 --- a/readcolumn.cpp +++ b/readcolumn.cpp @@ -14,9 +14,17 @@ ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){ - successOpen = openInputFile(distFile, fileHandle); + successOpen = m->openInputFile(distFile, fileHandle); + sim = false; } +/***********************************************************************/ + +ReadColumnMatrix::ReadColumnMatrix(string df, bool s) : distFile(df){ + + successOpen = m->openInputFile(distFile, fileHandle); + sim = s; +} /***********************************************************************/ @@ -47,15 +55,11 @@ int ReadColumnMatrix::read(NameAssignment* nameMap){ 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"; exit(1); - } - if(itB == nameMap->end()){ - cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1); - } + if(itA == nameMap->end()){ m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1); } + if(itB == nameMap->end()){ m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1); } if (distance == -1) { distance = 1000000; } - else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert. + else if (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,7 +94,7 @@ int ReadColumnMatrix::read(NameAssignment* nameMap){ } reading->update(itA->second * nseqs); } - gobble(fileHandle); + m->gobble(fileHandle); } if(lt == 0){ // oops, it was square @@ -98,7 +102,7 @@ int ReadColumnMatrix::read(NameAssignment* nameMap){ fileHandle.close(); //let's start over D->clear(); //let's start over - openInputFile(distFile, fileHandle); //let's start over + m->openInputFile(distFile, fileHandle); //let's start over while(fileHandle){ fileHandle >> firstName >> secondName >> distance; @@ -108,15 +112,11 @@ int ReadColumnMatrix::read(NameAssignment* nameMap){ map::iterator itA = nameMap->find(firstName); map::iterator itB = nameMap->find(secondName); - if(itA == nameMap->end()){ - cerr << "BError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; - } - if(itB == nameMap->end()){ - cerr << "BError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; - } + if(itA == nameMap->end()){ m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1); } + if(itB == nameMap->end()){ m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1); } if (distance == -1) { distance = 1000000; } - else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert. + else if (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); @@ -124,7 +124,7 @@ int ReadColumnMatrix::read(NameAssignment* nameMap){ reading->update(itA->second * nseqs); } - gobble(fileHandle); + m->gobble(fileHandle); } }