-/***********************************************************************/
-
-inline int openInputFile(string fileName, ifstream& fileHandle, string m){
-
- //get full path name
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str());
- if(!fileHandle) {
- return 1;
- }else {
- //check for blank file
- gobble(fileHandle);
- return 0;
- }
-}
-/***********************************************************************/
-
-inline int openInputFile(string fileName, ifstream& fileHandle){
-
- //get full path name
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str());
- if(!fileHandle) {
- cout << "Error: Could not open " << completeFileName << endl;
- return 1;
- }
- else {
- //check for blank file
- gobble(fileHandle);
- if (fileHandle.eof()) { cout << completeFileName << " is blank. Please correct." << endl; return 1; }
-
- return 0;
- }
-
-}
-/***********************************************************************/
-
-inline int renameFile(string oldName, string newName){
-
- ifstream inTest;
- int exist = openInputFile(newName, inTest, "");
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if (exist == 0) { //you could open it so you want to delete it
- inTest.close();
- string command = "rm " + newName;
- system(command.c_str());
- }
-
- string command = "mv " + oldName + " " + newName;
- system(command.c_str());
-#else
- remove(newName.c_str());
- int renameOk = rename(oldName.c_str(), newName.c_str());
-#endif
- return 0;
-}
-
-/***********************************************************************/
-
-inline int openOutputFile(string fileName, ofstream& fileHandle){
-
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str(), ios::trunc);
- if(!fileHandle) {
- cout << "Error: Could not open " << completeFileName << endl;
- return 1;
- }
- else {
- return 0;
- }
-
-}
-
-/***********************************************************************/
-
-inline int getNumSeqs(ifstream& file){
-
- int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
- file.seekg(0);
- return numSeqs;
-
-}
-/***********************************************************************/
-
-inline bool inVector(string member, vector<string> group){
-
- for (int i = 0; i < group.size(); i++) {
- if (group[i] == member) { return true; }
- }
-
- return false;
-}
-/***********************************************************************/
-
-//This function parses the estimator options and puts them in a vector
-inline void splitAtDash(string& estim, vector<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-//This function parses the label options and puts them in a set
-inline void splitAtDash(string& estim, set<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.insert(individual);
- }
- }
- //get last one
- container.insert(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-//This function parses the line options and puts them in a set
-inline void splitAtDash(string& estim, set<int>& container) {
- try {
- string individual;
- int lineNum;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- convert(individual, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- }
- //get last one
- convert(estim, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-//This function parses the a string and puts peices in a vector
-inline void splitAtComma(string& estim, vector<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of(',') != -1) {
- individual = estim.substr(0,estim.find_first_of(','));
- if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
- estim = estim.substr(estim.find_first_of(',')+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-
-//This function splits up the various option parameters
-inline void splitAtComma(string& prefix, string& suffix){
- try {
- prefix = suffix.substr(0,suffix.find_first_of(','));
- if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
- suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
- string space = " ";
- while(suffix.at(0) == ' ')
- suffix = suffix.substr(1, suffix.length());
- }
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/