]> git.donarmstrong.com Git - mothur.git/blob - globaldata.cpp
1.18.0 - fixed make.shared abort issue
[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::getOrderGroupFile()  {       return ordergroup;              }
30 string GlobalData::getTreeFile()                {       return treefile;                }
31 string GlobalData::getSharedFile()              {       return sharedfile;              }       
32 string GlobalData::getRelAbundFile()    {       return relAbundfile;    }       
33 string GlobalData::getFormat()                  {       return format;                  }
34
35 void GlobalData::setListFile(string file)               {       listfile = 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::setRelAbundFile(string file)   {       relAbundfile = file;    inputFileName = file;                           }
44 void GlobalData::setNameFile(string file)               {       namefile = file;                }
45 void GlobalData::setOrderFile(string file)              {       orderfile = file;               }
46 void GlobalData::setOrderGroupFile(string file) {       ordergroup = file;              }
47 void GlobalData::setFormat(string Format)               {       format = Format;                }
48
49
50 /*******************************************************/
51
52 /******************************************************
53 GlobalData::GlobalData() {
54         m = MothurOut::getInstance();
55         //option definitions should go here...
56         clear();
57         gListVector = NULL;             
58         gSparseMatrix = NULL;   
59         ginput = NULL;
60         gorder = NULL;
61         glist = NULL;
62         gSharedList = NULL;
63         sabund = NULL;
64         rabund = NULL;
65         gGroupmap = NULL;
66         gMatrix = NULL;
67         gTreemap = NULL;
68         gSequenceDB = NULL;
69         nameMap = NULL;
70         saveNextLabel = "";
71 }
72 /*******************************************************/
73
74 /******************************************************
75 void GlobalData::clear() {
76         //option definitions should go here...
77         phylipfile              =       ""; //do we need this?
78         columnfile              =       ""; //do we need this?
79         listfile                =       "";
80         rabundfile              =       "";
81         sabundfile              =       "";
82         namefile                =       ""; //do we need this?
83         groupfile               =       ""; //do we need this?
84         orderfile               =       "";
85         ordergroup              =       "";
86 //      fastafile               =   ""; //do we need this?
87         treefile                =       "";
88         sharedfile              =       "";
89         relAbundfile    =       "";
90         format = "";
91         saveNextLabel = "";
92 }
93
94
95 /*******************************************************/
96
97 /******************************************************
98 void GlobalData::newRead() {
99         try{    
100                         //remove old file names
101                         clear();
102                         
103                         //free memory
104                         if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
105
106                         if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
107
108                         if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
109
110                         if (ginput != NULL) { delete ginput; ginput = NULL;}
111
112                         if (gorder != NULL) { delete gorder; gorder = NULL; }
113
114                         if (glist != NULL) { delete glist; glist = NULL;}
115
116                         if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
117
118                         if (sabund != NULL) { delete sabund; sabund = NULL;}
119
120                         if (rabund != NULL) { delete rabund; rabund = NULL; }
121
122                         if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
123
124                         if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
125
126                         if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
127                         
128                         if (nameMap != NULL) { delete nameMap; nameMap = NULL; }
129
130
131                         gTree.clear();
132                         Treenames.clear();
133                         labels.clear(); Groups.clear();
134                         allLines = 1;
135                         runParse = true;
136                         names.clear();
137         }
138         catch(exception& e) {
139                 m->errorOut(e, "GlobalData", "newRead");
140                 exit(1);
141         }
142 }
143
144 //******************************************************/
145
146 /*****************************************************
147 GlobalData::~GlobalData() {
148         _uniqueInstance = 0;
149         try {
150                 if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
151                 if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
152                 if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
153                 if (ginput != NULL) { delete ginput; ginput = NULL;}
154                 if (gorder != NULL) { delete gorder; gorder = NULL; }
155                 if (glist != NULL) { delete glist; glist = NULL;}
156                 if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
157                 if (sabund != NULL) { delete sabund; sabund = NULL;}
158                 if (rabund != NULL) { delete rabund; rabund = NULL; }
159                 if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
160                 if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
161                 if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
162                 if (nameMap != NULL) { delete nameMap; nameMap = NULL; }
163         }
164         catch(exception& e) {
165                 m->errorOut(e, "GlobalData", "~GlobalData");
166                 exit(1);
167         }
168 }
169 /*******************************************************/
170
171 /*******************************************************/
172
173