]> git.donarmstrong.com Git - mothur.git/blob - globaldata.cpp
68f7fc389bb70948c1a22255af0cec275ba0ca5a
[mothur.git] / globaldata.cpp
1 #include "globaldata.hpp"
2 #include "tree.h"
3 #include "sparsematrix.hpp"
4
5 /*******************************************************/
6
7 /******************************************************/
8 GlobalData* GlobalData::getInstance() {
9         if( _uniqueInstance == 0) {
10                 _uniqueInstance = new GlobalData();
11         }
12         return _uniqueInstance;
13 }
14 /*******************************************************/
15
16 /******************************************************/
17 // These functions give you the option parameters of the commands
18 string GlobalData::getPhylipFile()              {       return phylipfile;              }
19 string GlobalData::getColumnFile()              {       return columnfile;              }
20 string GlobalData::getListFile()                {       return listfile;                }
21 string GlobalData::getRabundFile()              {       return rabundfile;              }
22 string GlobalData::getSabundFile()              {       return sabundfile;              }
23 string GlobalData::getNameFile()                {       return namefile;                }
24 string GlobalData::getGroupFile()               {       return groupfile;               }
25 string GlobalData::getOrderFile()               {       return orderfile;               }
26 string GlobalData::getTreeFile()                {       return treefile;                }
27 string GlobalData::getSharedFile()              {       return sharedfile;              }
28 string GlobalData::getFastaFile()               {       return fastafile;               }       
29 string GlobalData::getFormat()                  {       return format;                  }
30 string GlobalData::getCandidateFile()   {       return candidatefile;   }
31
32
33 void GlobalData::setListFile(string file)               {       listfile = file;        inputFileName = file;                                   }
34 void GlobalData::setFastaFile(string file)              {       fastafile = file;       inputFileName = file;                                   }
35 void GlobalData::setTreeFile(string file)               {       treefile = file;        inputFileName = file;                                   }
36 void GlobalData::setCandidateFile(string file)  {       candidatefile = file;                                                                           }
37 void GlobalData::setRabundFile(string file)             {       rabundfile = file;      inputFileName = file;                                   }
38 void GlobalData::setSabundFile(string file)             {       sabundfile = file;      inputFileName = file;                                   }
39 void GlobalData::setPhylipFile(string file)             {       phylipfile = file;    inputFileName = file;                                     }
40 void GlobalData::setColumnFile(string file)             {       columnfile = file;    inputFileName = file;                                     }
41 void GlobalData::setGroupFile(string file)              {       groupfile = file;                                                                                       }
42 void GlobalData::setSharedFile(string file)             {       sharedfile = file;      inputFileName = file;                                   }
43 void GlobalData::setNameFile(string file)               {       namefile = file;                }
44 void GlobalData::setOrderFile(string file)              {       orderfile = file;               }
45 void GlobalData::setFormat(string Format)               {       format = Format;                }
46
47
48 /*******************************************************/
49
50 /******************************************************/
51 GlobalData::GlobalData() {
52         //option definitions should go here...
53         clear();
54         gListVector = NULL;             
55         gSparseMatrix = NULL;   
56 }
57 /*******************************************************/
58
59 /******************************************************/
60 void GlobalData::clear() {
61         //option definitions should go here...
62         phylipfile              =       "";
63         columnfile              =       "";
64         listfile                =       "";
65         rabundfile              =       "";
66         sabundfile              =       "";
67         namefile                =       "";
68         groupfile               =       ""; 
69         orderfile               =       "";
70         fastafile               =   "";
71         treefile                =       "";
72         sharedfile              =       "";
73         candidatefile   =       "";
74 }
75 /*******************************************************/
76
77 /******************************************************/
78 void GlobalData::newRead() {
79         try{
80                         clear();
81                         gGroupmap = NULL;
82                         gListVector = NULL;
83                         gSparseMatrix = NULL;
84                         gTree.clear();
85                         Treenames.clear();
86                         labels.clear(); lines.clear(); Groups.clear();
87                         allLines = 1;
88                         runParse = true;
89         }
90         catch(exception& e) {
91                 cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
92                 exit(1);
93         }
94         catch(...) {
95                 cout << "An unknown error has occurred in the GlobalData class function newRead. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
96                 exit(1);
97         }
98 }
99
100 //******************************************************/
101
102 /******************************************************/
103 GlobalData::~GlobalData() {
104         _uniqueInstance = 0;
105         if(gListVector != NULL)         {       delete gListVector;             }
106         if(gSparseMatrix != NULL)       {       delete gSparseMatrix;   }
107         if(gorder != NULL)                      {       delete gorder;          }
108 }
109 /*******************************************************/
110
111 /*******************************************************/
112
113