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