]> git.donarmstrong.com Git - mothur.git/blobdiff - globaldata.cpp
I've changed the listfile, sabundfile, etc. option handles to not need the "file...
[mothur.git] / globaldata.cpp
index c28321d5a74879492975f2c0e4ed0e019f67b8e6..713ae9af7346dbcdffe38e3f38f9f93b1129984d 100644 (file)
@@ -9,6 +9,7 @@ using namespace std;
 
 #include "globaldata.hpp"
 #include "sparsematrix.hpp"
+#include "tree.h"
 #include "rabundvector.hpp"
 #include "sabundvector.hpp"
 #include "listvector.hpp"
@@ -79,8 +80,10 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                allLines = 1;
                commandName = commandString; //save command name to be used by other classes
                
-               //clears out data from previous read and sets format
-               setReadFormat(commandName);
+               //clears out data from previous read
+               if ((commandName == "read.dist") || (commandName == "read.otu") || (commandName == "read.tree")) { 
+                       clear();
+               }
                
                //saves help request
                if (commandName =="help") {
@@ -94,20 +97,23 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                                splitAtComma(value, optionText);
                                splitAtEquals(key, value);
                                
-                               if (key == "distfile" )         { distfile = value; inputFileName = value; fileroot = value;}
-                               if (key == "listfile" )         { listfile = value; inputFileName = value; fileroot = value;}
-                               if (key == "rabundfile" )       { rabundfile = value; inputFileName = value; fileroot = value;}
-                               if (key == "sabundfile" )       { sabundfile = value; inputFileName = value; fileroot = value;}
-                               if (key == "namefile" )         { namefile = value; }
-                               if (key == "orderfile" )        { orderfile = value; }
-                               if (key == "groupfile" )        { groupfile = value; }
-                               if (key == "cutoff" )           { cutoff = value; }
-                               if (key == "precision" )        { precision = value; }
-                               if (key == "iters" )            { iters = value; }
-                               if (key == "jumble" )           { jumble = value; }
-                               if (key == "freq" )                     { freq = value; }
-                               if (key == "method" )           { method = value; }
-                               if (key == "fileroot" )         { fileroot = value; }
+                               if (key == "phylip" )   { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip";       }
+                               if (key == "column" )   { columnfile = value; inputFileName = value; fileroot = value; format = "column";       }
+                               if (key == "list" )             { listfile = value; inputFileName = value; fileroot = value; format = "list";           }
+                               if (key == "rabund" )   { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund";       }
+                               if (key == "sabund" )   { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund";       } 
+                               if (key == "fasta" )    { fastafile = value; inputFileName = value; fileroot = value; format = "fasta";         } 
+                               if (key == "treefile" )         { treefile = value; inputFileName = value; fileroot = value; format = "tree";           }
+                               if (key == "name" )             { namefile = value;             }
+                               if (key == "order" )    { orderfile = value;    }
+                               if (key == "group" )    { groupfile = value;    }
+                               if (key == "cutoff" )           { cutoff = value;               }
+                               if (key == "precision" )        { precision = value;    }
+                               if (key == "iters" )            { iters = value;                }
+                               if (key == "jumble" )           { jumble = value;               }
+                               if (key == "freq" )                     { freq = value;                 }
+                               if (key == "method" )           { method = value;               }
+                               if (key == "fileroot" )         { fileroot = value;             }
                                
                                if (key == "single") {//stores estimators in a vector
                                        singleEstimators.clear(); //clears out old values
@@ -156,20 +162,23 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        //saves the last parameter
                        value = optionText;
                        splitAtEquals(key, value);
-                       if (key == "distfile" )         { distfile = value; inputFileName = value; fileroot = value; }
-                       if (key == "listfile" )         { listfile = value; inputFileName = value; fileroot = value; }
-                       if (key == "rabundfile" )       { rabundfile = value; inputFileName = value; fileroot = value; }
-                       if (key == "sabundfile" )       { sabundfile = value; inputFileName = value; fileroot = value; }
-                       if (key == "namefile" )         { namefile = value; }
-                       if (key == "orderfile" )        { orderfile = value; }
-                       if (key == "groupfile" )        { groupfile = value; }
-                       if (key == "cutoff" )           { cutoff = value; }
-                       if (key == "precision" )        { precision = value; }
-                       if (key == "iters" )            { iters = value; }
-                       if (key == "jumble" )           { jumble = value; }
-                       if (key == "freq" )                     { freq = value; }
-                       if (key == "method" )           { method = value; }
-                       if (key == "fileroot" )         { fileroot = value; }
+                       if (key == "phylip" )   { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip";       }
+                       if (key == "column" )   { columnfile = value; inputFileName = value; fileroot = value; format = "column";       }
+                       if (key == "list" )             { listfile = value; inputFileName = value; fileroot = value; format = "list";           }
+                       if (key == "rabund" )   { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund";       }
+                       if (key == "sabund" )   { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund";       }
+                       if (key == "fasta" )    { fastafile = value; inputFileName = value; fileroot = value; format = "fasta";         }
+                       if (key == "treefile" )         { treefile = value; inputFileName = value; fileroot = value; format = "tree";           }  
+                       if (key == "name" )             { namefile = value;             }
+                       if (key == "order" )    { orderfile = value;    }
+                       if (key == "group" )    { groupfile = value;    }
+                       if (key == "cutoff" )           { cutoff = value;               }
+                       if (key == "precision" )        { precision = value;    }
+                       if (key == "iters" )            { iters = value;                }
+                       if (key == "jumble" )           { jumble = value;               }
+                       if (key == "freq" )                     { freq = value;                 }
+                       if (key == "method" )           { method = value;               }
+                       if (key == "fileroot" )         { fileroot = value;             }
 
                        if (key == "single") {//stores estimators in a vector
                                singleEstimators.clear(); //clears out old values
@@ -216,27 +225,36 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        }
                }
                
+               //set format for shared
+               if ((listfile != "") && (groupfile != "")) { format = "shared"; }
                                
                //input defaults
-               if (commandString == "collect.single") {
-                       if (singleEstimators.size() == 0) { splitAtDash(single, singleEstimators); }    
+               if (commandName == "collect.single") {
+                       if (singleEstimators.size() == 0) { splitAtDash(single, singleEstimators); }
                }
-               if (commandString == "rarefaction.single") {
+               if (commandName == "rarefaction.single") {
                        if (rareEstimators.size() == 0) { splitAtDash(rarefaction, rareEstimators);  }  
                }
-               if (commandString == "collect.shared") {
+               if (commandName == "collect.shared") {
                        if (sharedEstimators.size() == 0) { splitAtDash(shared, sharedEstimators); }    
                }
-               if (commandString == "summary.single") {
+               if (commandName == "summary.single") {
                        if (summaryEstimators.size() == 0) { splitAtDash(summary, summaryEstimators); }
                }
-               if (commandString == "summary.shared") {
+               if (commandName == "summary.shared") {
                        if (sharedSummaryEstimators.size() == 0) { splitAtDash(sharedsummary, sharedSummaryEstimators); }
                }
-               if (commandString == "rarefaction.shared") {
+               if (commandName == "rarefaction.shared") {
                        if (sharedRareEstimators.size() == 0) { splitAtDash(sharedrarefaction, sharedRareEstimators); }
                }
 
+
+               //if you have done a read.otu with a groupfile but don't want to use it anymore because you want to do single commands
+               if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single")) {
+                       if (listfile != "") { format = "list"; }
+                       else if (sabundfile != "") { format = "sabund"; }
+                       else if (rabundfile != "") { format = "rabund"; }
+               }
                                
        }
        catch(exception& e) {
@@ -251,50 +269,18 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
 }
 /*******************************************************/
 
-/******************************************************/
-void GlobalData::setReadFormat(string command){
-       try {
-               if (command == "read.phylip") { 
-                       clear();
-                       format = "phylip";
-               }else if (command == "read.column") { 
-                       clear();
-                       format = "column";
-               }else if (command == "read.list") { 
-                       clear();
-                       format = "list";
-               }else if (command == "read.rabund") { 
-                       clear();
-                       format = "rabund";
-               }else if (command == "read.sabund") { 
-                       clear();
-                       format = "sabund";
-               }else if (command == "read.shared") { 
-                       clear();
-                       format = "shared";
-               }else if (command == "parselist") { format = "list"; }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function setReadFormat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the GlobalData class function setReadFormat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/*******************************************************/
-
 /******************************************************/
 // These functions give you the option parameters of the commands
-string GlobalData::getDistFile()               {       return distfile;        }
+string GlobalData::getPhylipFile()             {       return phylipfile;      }
+string GlobalData::getColumnFile()             {       return columnfile;      }
 string GlobalData::getListFile()               {       return listfile;        }
 string GlobalData::getRabundFile()             {       return rabundfile;      }
 string GlobalData::getSabundFile()             {       return sabundfile;      }
 string GlobalData::getNameFile()               {       return namefile;        }
 string GlobalData::getGroupFile()              {       return groupfile;       }
 string GlobalData::getOrderFile()              {       return orderfile;       }
+string GlobalData::getTreeFile()               {       return treefile;        }
+string GlobalData::getFastaFile()              {       return fastafile;       }
 string GlobalData::getCutOff()                 {       return cutoff;          }
 string GlobalData::getFormat()                 {       return format;          }
 string GlobalData::getPrecision()              {       return precision;       }
@@ -306,7 +292,9 @@ string GlobalData::getFreq()                        {       return freq;            }
 void GlobalData::setListFile(string file)      {       listfile = file;        inputFileName = file;}
 void GlobalData::setRabundFile(string file)    {       rabundfile = file;      inputFileName = file;}
 void GlobalData::setSabundFile(string file)    {       sabundfile = file;      inputFileName = file;}
-void GlobalData::setDistFile(string file)      {       distfile = file;    inputFileName = file;}
+void GlobalData::setPhylipFile(string file)    {       phylipfile = file;    inputFileName = file;}
+void GlobalData::setColumnFile(string file)    {       columnfile = file;    inputFileName = file;}
+//void GlobalData::setGroupFile(string file)   {       groupfile = file;       }
 void GlobalData::setNameFile(string file)      {       namefile = file;        }
 void GlobalData::setFormat(string Format)      {       format = Format;        }
 
@@ -326,27 +314,30 @@ GlobalData::GlobalData() {
 
 void GlobalData::clear() {
        //option definitions should go here...
-       distfile                =       "";
-       listfile                =       "";///users/westcott/desktop/s.list
+       phylipfile              =       "";
+       columnfile              =       "";
+       listfile                =       "";
        rabundfile              =       "";
        sabundfile              =       "";
        namefile                =       "";
-       groupfile               =       ""; ///users/westcott/desktop/s.names
+       groupfile               =       ""; 
        orderfile               =       "";
+       fastafile               =   "";
+       treefile                =       "";
        cutoff                  =       "10.00";
        format                  =       "";
        precision               =       "100";
        iters                   =       "1000"; 
        line                    =   "";
        label                   =       "";
-       jumble                  =       "0";
+       jumble                  =       "1";
        freq                    =       "100";
        method                  =       "furthest";
        fileroot                =       "";
        single                  =       "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction";
        rarefaction             =       "rarefaction";
-       shared                  =       "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
-       sharedsummary   =   "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
+       shared                  =       "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
+       sharedsummary   =   "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
        summary                 =       "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson";
        sharedrarefaction = "sharedobserved";
 }