]> git.donarmstrong.com Git - mothur.git/blob - readtreecommand.cpp
put back no command and worked on libshuff
[mothur.git] / readtreecommand.cpp
1 /*
2  *  readtreecommand.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/23/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "readtreecommand.h"
11
12 //**********************************************************************************************************************
13 ReadTreeCommand::ReadTreeCommand(){
14         try {
15                 globaldata = GlobalData::getInstance();
16                 filename = globaldata->inputFileName;
17                 
18                 //read in group map info.
19                 treeMap = new TreeMap(globaldata->getGroupFile());
20                 treeMap->readMap();
21                 
22                 //memory leak prevention
23                 //if (globaldata->gTreemap != NULL) { delete globaldata->gTreemap;  }
24                 globaldata->gTreemap = treeMap;
25
26                 read = new ReadNewickTree(filename);
27                 
28         }
29         catch(exception& e) {
30                 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
31                 exit(1);
32         }
33         catch(...) {
34                 cout << "An unknown error has occurred in the ReadTreeCommand class function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
35                 exit(1);
36         }
37 }
38
39 //**********************************************************************************************************************
40
41 ReadTreeCommand::~ReadTreeCommand(){
42         delete read;
43 }
44
45 //**********************************************************************************************************************
46
47 int ReadTreeCommand::execute(){
48         try {
49                 int readOk;
50                 
51                 readOk = read->read(); 
52                 
53                 if (readOk != 0) { cout << "Read Terminated." << endl; globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
54                 
55                 vector<Tree*> T = globaldata->gTree;
56                 
57                 //assemble users trees
58                 for (int i = 0; i < T.size(); i++) {
59                         T[i]->assembleTree();
60                 }
61
62                 return 0;
63         }
64         catch(exception& e) {
65                 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
66                 exit(1);
67         }
68         catch(...) {
69                 cout << "An unknown error has occurred in the ReadTreeCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
70                 exit(1);
71         }
72 }
73
74 //**********************************************************************************************************************