]> git.donarmstrong.com Git - mothur.git/blob - readtreecommand.cpp
63c62265455ad6b2348d5496a278245f75fe5f71
[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                 globaldata->gTreemap = treeMap;
22
23                 read = new ReadNewickTree(filename);
24                 
25         }
26         catch(exception& e) {
27                 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
28                 exit(1);
29         }
30         catch(...) {
31                 cout << "An unknown error has occurred in the ReadTreeCommand class function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
32                 exit(1);
33         }
34 }
35
36 //**********************************************************************************************************************
37
38 ReadTreeCommand::~ReadTreeCommand(){
39         delete read;
40 }
41
42 //**********************************************************************************************************************
43
44 int ReadTreeCommand::execute(){
45         try {
46         
47                 read->read(); 
48                 
49                 vector<Tree*> T = globaldata->gTree;
50                 
51                 //assemble users trees
52                 for (int i = 0; i < T.size(); i++) {
53                         T[i]->assembleTree();
54                 }
55                 return 0;
56         }
57         catch(exception& e) {
58                 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
59                 exit(1);
60         }
61         catch(...) {
62                 cout << "An unknown error has occurred in the ReadTreeCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
63                 exit(1);
64         }
65 }
66
67 //**********************************************************************************************************************