]> git.donarmstrong.com Git - mothur.git/blob - readtreecommand.cpp
working on readtree
[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 T[0]->createNewickFile("treeout");              
56                 return 0;
57         }
58         catch(exception& e) {
59                 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
60                 exit(1);
61         }
62         catch(...) {
63                 cout << "An unknown error has occurred in the ReadTreeCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
64                 exit(1);
65         }
66 }
67
68 //**********************************************************************************************************************