5 * Created by Sarah Westcott on 1/23/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "readtreecommand.h"
12 //**********************************************************************************************************************
13 ReadTreeCommand::ReadTreeCommand(){
15 globaldata = GlobalData::getInstance();
16 filename = globaldata->inputFileName;
18 //read in group map info.
19 treeMap = new TreeMap(globaldata->getGroupFile());
22 //memory leak prevention
23 //if (globaldata->gTreemap != NULL) { delete globaldata->gTreemap; }
24 globaldata->gTreemap = treeMap;
27 globaldata->parseTreeFile();
29 read = new ReadNewickTree(filename);
33 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
37 cout << "An unknown error has occurred in the ReadTreeCommand class function ReadTreeCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
42 //**********************************************************************************************************************
44 ReadTreeCommand::~ReadTreeCommand(){
48 //**********************************************************************************************************************
50 int ReadTreeCommand::execute(){
54 readOk = read->read();
56 if (readOk != 0) { cout << "Read Terminated." << endl; globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
58 vector<Tree*> T = globaldata->gTree;
60 //assemble users trees
61 for (int i = 0; i < T.size(); i++) {
65 //output any names that are in names file but not in tree
66 if (globaldata->Treenames.size() < treeMap->getNumSeqs()) {
67 for (int i = 0; i < treeMap->namesOfSeqs.size(); i++) {
68 //is that name in the tree?
70 for (int j = 0; j < globaldata->Treenames.size(); j++) {
71 if (treeMap->namesOfSeqs[i] == globaldata->Treenames[j]) { break; } //found it
75 //then you did not find it so report it
76 if (count == globaldata->Treenames.size()) {
77 cout << treeMap->namesOfSeqs[i] << " is in your namefile and not in your tree. It will be disregarded." << endl;
85 cout << "Standard Error: " << e.what() << " has occurred in the ReadTreeCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
89 cout << "An unknown error has occurred in the ReadTreeCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
94 //**********************************************************************************************************************