]> git.donarmstrong.com Git - mothur.git/blob - readdistphylipfilecommand.cpp
Initial revision
[mothur.git] / readdistphylipfilecommand.cpp
1 /*
2  *  readdistphylipfilecommand.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/2/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "readdistphylipfilecommand.h"
11
12 //**********************************************************************************************************************
13
14 ReadDistPhylipFileCommand::ReadDistPhylipFileCommand(){
15         try {
16                 globaldata = GlobalData::getInstance();
17                 
18                 filename = globaldata->inputFileName;
19                                 
20                 format = globaldata->getFormat();       
21                 read = new ReadPhylipMatrix(filename);  
22                 
23                 if(globaldata->getPrecision() != ""){
24                         convert(globaldata->getPrecision(), precision); 
25                 }
26                 
27                 if(globaldata->getCutOff() != ""){
28                         convert(globaldata->getCutOff(), cutoff);       
29                         cutoff += (5 / (precision * 10.0));
30                 }
31                 read->setCutoff(cutoff);
32         
33                 if(globaldata->getNameFile() != ""){    
34                         nameMap = new NameAssignment(globaldata->getNameFile());
35                         nameMap->readMap(1,2);
36                 }
37                 else{
38                         nameMap = NULL;
39                 }
40         }
41         catch(exception& e) {
42                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistPhylipFileCommand class Function ReadDistPhylipFileCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
43                 exit(1);
44         }
45         catch(...) {
46                 cout << "An unknown error has occurred in the ReadDistPhylipFileCommand class function ReadDistPhylipFileCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
47                 exit(1);
48         }
49 }
50
51 //**********************************************************************************************************************
52
53 ReadDistPhylipFileCommand::~ReadDistPhylipFileCommand(){
54         delete read;
55         delete nameMap;
56 }
57
58 //**********************************************************************************************************************
59
60 int ReadDistPhylipFileCommand::execute(){
61         try {
62                 read->read(nameMap);
63                 globaldata->setListVector(read->getListVector());
64                 globaldata->setSparseMatrix(read->getMatrix());
65                 return 0;
66         }
67         catch(exception& e) {
68                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistPhylipFileCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
69                 exit(1);
70         }
71         catch(...) {
72                 cout << "An unknown error has occurred in the ReadDistPhylipFileCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
73                 exit(1);
74         }
75 }