]> git.donarmstrong.com Git - mothur.git/blob - globaldata.cpp
changed how we break up the files on parallelized commands to avoid scanning file.
[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 }
71 /*******************************************************/
72
73 /******************************************************/
74 void GlobalData::clear() {
75         //option definitions should go here...
76         phylipfile              =       ""; //do we need this?
77         columnfile              =       ""; //do we need this?
78         listfile                =       "";
79         rabundfile              =       "";
80         sabundfile              =       "";
81         namefile                =       ""; //do we need this?
82         groupfile               =       ""; //do we need this?
83         orderfile               =       "";
84         ordergroup              =       "";
85 //      fastafile               =   ""; //do we need this?
86         treefile                =       "";
87         sharedfile              =       "";
88         relAbundfile    =       "";
89         format = "";
90 }
91
92
93 /*******************************************************/
94
95 /******************************************************/
96 void GlobalData::newRead() {
97         try{    
98                         //remove old file names
99                         clear();
100                         
101                         //free memory
102                         if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
103
104                         if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
105
106                         if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
107
108                         if (ginput != NULL) { delete ginput; ginput = NULL;}
109
110                         if (gorder != NULL) { delete gorder; gorder = NULL; }
111
112                         if (glist != NULL) { delete glist; glist = NULL;}
113
114                         if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
115
116                         if (sabund != NULL) { delete sabund; sabund = NULL;}
117
118                         if (rabund != NULL) { delete rabund; rabund = NULL; }
119
120                         if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
121
122                         if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
123
124                         if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
125                         
126                         if (nameMap != NULL) { delete nameMap; nameMap = NULL; }
127
128
129                         gTree.clear();
130                         Treenames.clear();
131                         labels.clear(); Groups.clear();
132                         allLines = 1;
133                         runParse = true;
134                         names.clear();
135         }
136         catch(exception& e) {
137                 m->errorOut(e, "GlobalData", "newRead");
138                 exit(1);
139         }
140 }
141
142 //******************************************************/
143
144 /******************************************************/
145 GlobalData::~GlobalData() {
146         _uniqueInstance = 0;
147         try {
148                 if (gGroupmap != NULL) { delete gGroupmap; gGroupmap = NULL; }
149                 if (gListVector != NULL) { delete gListVector; gListVector = NULL;}
150                 if (gSparseMatrix != NULL) { delete gSparseMatrix; gSparseMatrix = NULL; }
151                 if (ginput != NULL) { delete ginput; ginput = NULL;}
152                 if (gorder != NULL) { delete gorder; gorder = NULL; }
153                 if (glist != NULL) { delete glist; glist = NULL;}
154                 if (gSharedList != NULL) { delete gSharedList; gSharedList = NULL; }
155                 if (sabund != NULL) { delete sabund; sabund = NULL;}
156                 if (rabund != NULL) { delete rabund; rabund = NULL; }
157                 if (gMatrix != NULL) { delete gMatrix; gMatrix = NULL;}
158                 if (gTreemap != NULL) { delete gTreemap; gTreemap = NULL; }
159                 if (gSequenceDB != NULL) { delete gSequenceDB; gSequenceDB = NULL;}
160                 if (nameMap != NULL) { delete nameMap; nameMap = NULL; }
161         }
162         catch(exception& e) {
163                 m->errorOut(e, "GlobalData", "~GlobalData");
164                 exit(1);
165         }
166 }
167 /*******************************************************/
168
169 /*******************************************************/
170
171