]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
1.18.1
[mothur.git] / mothurout.cpp
index eb452b19a681e5ebe83d71ca7975a4140f703a55..8fde2fd105d2b100715cc244a6d9a16bbd9eb353 100644 (file)
@@ -18,6 +18,97 @@ MothurOut* MothurOut::getInstance() {
        return _uniqueInstance;
 }
 /*********************************************************************************************/
+void MothurOut::printCurrentFiles()  {
+       try {
+               if (accnosfile != "")           {  mothurOut("accnos=" + accnosfile); mothurOutEndLine();                       }
+               if (columnfile != "")           {  mothurOut("column=" + columnfile); mothurOutEndLine();                       }
+               if (designfile != "")           {  mothurOut("design=" + designfile); mothurOutEndLine();                       }
+               if (fastafile != "")            {  mothurOut("fasta=" + fastafile); mothurOutEndLine();                         }
+               if (groupfile != "")            {  mothurOut("group=" + groupfile); mothurOutEndLine();                         }
+               if (listfile != "")                     {  mothurOut("list=" + listfile); mothurOutEndLine();                           }
+               if (namefile != "")                     {  mothurOut("name=" + namefile); mothurOutEndLine();                           }
+               if (oligosfile != "")           {  mothurOut("oligos=" + oligosfile); mothurOutEndLine();                       }
+               if (orderfile != "")            {  mothurOut("order=" + orderfile); mothurOutEndLine();                         }
+               if (ordergroupfile != "")       {  mothurOut("ordergroup=" + ordergroupfile); mothurOutEndLine();       }
+               if (phylipfile != "")           {  mothurOut("phylip=" + phylipfile); mothurOutEndLine();                       }
+               if (qualfile != "")                     {  mothurOut("qfile=" + qualfile); mothurOutEndLine();                          }
+               if (rabundfile != "")           {  mothurOut("rabund=" + rabundfile); mothurOutEndLine();                       }
+               if (relabundfile != "")         {  mothurOut("relabund=" + relabundfile); mothurOutEndLine();           }
+               if (sabundfile != "")           {  mothurOut("sabund=" + sabundfile); mothurOutEndLine();                       }
+               if (sfffile != "")                      {  mothurOut("sff=" + sfffile); mothurOutEndLine();                                     }
+               if (sharedfile != "")           {  mothurOut("shared=" + sharedfile); mothurOutEndLine();                       }
+               if (taxonomyfile != "")         {  mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine();           }
+               if (treefile != "")                     {  mothurOut("tree=" + treefile); mothurOutEndLine();                           }
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "printCurrentFiles");
+               exit(1);
+       }
+}
+/*********************************************************************************************/
+bool MothurOut::hasCurrentFiles()  {
+       try {
+               bool hasCurrent = false;
+               
+               if (accnosfile != "")           {  return true;                 }
+               if (columnfile != "")           {  return true;                 }
+               if (designfile != "")           {  return true;                 }
+               if (fastafile != "")            {  return true;                 }
+               if (groupfile != "")            {  return true;                 }
+               if (listfile != "")                     {  return true;                 }
+               if (namefile != "")                     {  return true;                 }
+               if (oligosfile != "")           {  return true;                 }
+               if (orderfile != "")            {  return true;                 }
+               if (ordergroupfile != "")       {  return true;                 }
+               if (phylipfile != "")           {  return true;                 }
+               if (qualfile != "")                     {  return true;                 }
+               if (rabundfile != "")           {  return true;                 }
+               if (relabundfile != "")         {  return true;                 }
+               if (sabundfile != "")           {  return true;                 }
+               if (sfffile != "")                      {  return true;                 }
+               if (sharedfile != "")           {  return true;                 }
+               if (taxonomyfile != "")         {  return true;                 }
+               if (treefile != "")                     {  return true;                 }
+               
+               return hasCurrent;
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "hasCurrentFiles");
+               exit(1);
+       }
+}
+
+/*********************************************************************************************/
+void MothurOut::clearCurrentFiles()  {
+       try {
+               phylipfile = "";
+               columnfile = "";
+               listfile = "";
+               rabundfile = "";
+               sabundfile = "";
+               namefile = "";
+               groupfile = "";
+               designfile = "";
+               orderfile = "";
+               treefile = "";
+               sharedfile = "";
+               ordergroupfile = "";
+               relabundfile = "";
+               fastafile = "";
+               qualfile = "";
+               sfffile = "";
+               oligosfile = "";
+               accnosfile = "";
+               taxonomyfile = "";              
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "clearCurrentFiles");
+               exit(1);
+       }
+}
+/*********************************************************************************************/
 void MothurOut::setFileName(string filename)  {
        try {
                logFileName = filename;
@@ -489,6 +580,7 @@ bool MothurOut::isBlank(string fileName){
                        //check for blank file
                        gobble(fileHandle);
                        if (fileHandle.eof()) { fileHandle.close(); return true;  }
+                       fileHandle.close();
                }
                return false;
        }
@@ -926,7 +1018,7 @@ vector<unsigned long int> MothurOut::setFilePosFasta(string filename, int& num)
                        
                        in.seekg(size);
                
-                       while(char c = in.get()){
+                       while(in.get()){
                                if(in.eof())            {       break;  }
                                else                            {       size++; }
                        }
@@ -1095,6 +1187,36 @@ float MothurOut::ceilDist(float dist, int precision){
                exit(1);
        }
 }
+/**********************************************************************************************************************/
+map<string, int> MothurOut::readNames(string namefile) { 
+       try {
+               
+               map<string, int> nameMap;
+               
+               //open input file
+               ifstream in;
+               openInputFile(namefile, in);
+               
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+                       string firstCol, secondCol;
+                       in >> firstCol >> secondCol; gobble(in);
+                       
+                       int num = getNumNames(secondCol);
+                       
+                       nameMap[firstCol] = num;
+               }
+               in.close();
+               
+               return nameMap;
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readNames");
+               exit(1);
+       }
+}
 
 /***********************************************************************/
 
@@ -1642,7 +1764,23 @@ bool MothurOut::checkReleaseVersion(ifstream& file, string version) {
                exit(1);
        }
 }
-
+/**************************************************************************************************/
+bool MothurOut::isContainingOnlyDigits(string input) {
+       try{
+               
+               //are you a digit in ascii code
+               for (int i = 0;i < input.length(); i++){
+                       if( input[i]>47 && input[i]<58){}
+                       else { return false; }
+               }
+               
+               return true;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "isContainingOnlyDigits");             
+               exit(1);
+       }
+}
 /**************************************************************************************************/