]> git.donarmstrong.com Git - mothur.git/blob - globaldata.cpp
removed line option
[mothur.git] / globaldata.cpp
1
2
3 #include "globaldata.hpp"
4 #include "sharedlistvector.h"
5 #include "inputdata.h"
6 #include "fullmatrix.h"
7
8 /*******************************************************/
9
10 /******************************************************/
11 GlobalData* GlobalData::getInstance() {
12         if( _uniqueInstance == 0) {
13                 _uniqueInstance = new GlobalData();
14         }
15         return _uniqueInstance;
16 }
17 /*******************************************************/
18
19 /******************************************************/
20 // These functions give you the option parameters of the commands
21 string GlobalData::getPhylipFile()              {       return phylipfile;              }
22 string GlobalData::getColumnFile()              {       return columnfile;              }
23 string GlobalData::getListFile()                {       return listfile;                }
24 string GlobalData::getRabundFile()              {       return rabundfile;              }
25 string GlobalData::getSabundFile()              {       return sabundfile;              }
26 string GlobalData::getNameFile()                {       return namefile;                }
27 string GlobalData::getGroupFile()               {       return groupfile;               }
28 string GlobalData::getOrderFile()               {       return orderfile;               }
29 string GlobalData::getTreeFile()                {       return treefile;                }
30 string GlobalData::getSharedFile()              {       return sharedfile;              }
31 //string GlobalData::getFastaFile()             {       return fastafile;               }       
32 string GlobalData::getFormat()                  {       return format;                  }
33
34 void GlobalData::setListFile(string file)               {       listfile = file;        inputFileName = file;                                   }
35 //void GlobalData::setFastaFile(string file)            {       fastafile = file;       inputFileName = file;                                   }
36 void GlobalData::setTreeFile(string file)               {       treefile = file;        inputFileName = 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         ginput = NULL;
57         gorder = NULL;
58         glist = NULL;
59         gSharedList = NULL;
60         sabund = NULL;
61         rabund = NULL;
62         gGroupmap = NULL;
63         gMatrix = NULL;
64         gTreemap = NULL;
65         gSequenceDB = NULL;
66 }
67 /*******************************************************/
68
69 /******************************************************/
70 void GlobalData::clear() {
71         //option definitions should go here...
72         phylipfile              =       ""; //do we need this?
73         columnfile              =       ""; //do we need this?
74         listfile                =       "";
75         rabundfile              =       "";
76         sabundfile              =       "";
77         namefile                =       ""; //do we need this?
78         groupfile               =       ""; //do we need this?
79         orderfile               =       "";
80 //      fastafile               =   ""; //do we need this?
81         treefile                =       "";
82         sharedfile              =       "";
83 }
84
85
86 /*******************************************************/
87
88 /******************************************************/
89 void GlobalData::newRead() {
90         try{    
91                         //remove old file names
92                         clear();
93                         
94                         //free memory
95                         if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
96
97                         if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
98
99                         if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
100
101                         if (ginput != NULL) { delete ginput; ginput = NULL;}
102
103                         if (gorder != NULL) { delete gorder; gorder = NULL; }
104
105                         if (glist != NULL) { delete glist; glist = NULL;}
106
107                         if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
108
109                         if (sabund != NULL) { delete sabund; sabund = NULL;}
110
111                         if (rabund != NULL) { delete rabund; rabund = NULL; }
112
113                         if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
114
115                         if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
116
117                         if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
118
119
120                         gTree.clear();
121                         Treenames.clear();
122                         labels.clear(); Groups.clear();
123                         allLines = 1;
124                         runParse = true;
125         }
126         catch(exception& e) {
127                 errorOut(e, "GlobalData", "newRead");
128                 exit(1);
129         }
130 }
131
132 //******************************************************/
133
134 /******************************************************/
135 GlobalData::~GlobalData() {
136         _uniqueInstance = 0;
137         try {
138                 if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
139                 if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
140                 if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
141                 if (ginput != NULL) { delete ginput; ginput = NULL;}
142                 if (gorder != NULL) { delete gorder; gorder = NULL; }
143                 if (glist != NULL) { delete glist; glist = NULL;}
144                 if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
145                 if (sabund != NULL) { delete sabund; sabund = NULL;}
146                 if (rabund != NULL) { delete rabund; rabund = NULL; }
147                 if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
148                 if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
149                 if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
150         }
151         catch(exception& e) {
152                 errorOut(e, "GlobalData", "~GlobalData");
153                 exit(1);
154         }
155 }
156 /*******************************************************/
157
158 /*******************************************************/
159
160