5 * Created by Sarah Westcott on 1/20/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "readdistcommand.h"
11 #include "readphylip.h"
12 #include "readcolumn.h"
13 #include "readmatrix.hpp"
15 ReadDistCommand::ReadDistCommand(){
17 globaldata = GlobalData::getInstance();
19 filename = globaldata->inputFileName;
20 format = globaldata->getFormat();
22 if (format == "column") { read = new ReadColumnMatrix(filename); }
23 else if (format == "phylip") { read = new ReadPhylipMatrix(filename); }
24 else if (format == "matrix") {
25 groupMap = new GroupMap(globaldata->getGroupFile());
27 //if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; }
28 globaldata->gGroupmap = groupMap;
31 if (format != "matrix" ) {
32 if(globaldata->getPrecision() != ""){
33 convert(globaldata->getPrecision(), precision);
36 if(globaldata->getCutOff() != ""){
37 convert(globaldata->getCutOff(), cutoff);
38 cutoff += (5 / (precision * 10.0));
40 read->setCutoff(cutoff);
42 if(globaldata->getNameFile() != ""){
43 nameMap = new NameAssignment(globaldata->getNameFile());
44 nameMap->readMap(1,2);
53 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
57 cout << "An unknown error has occurred in the ReadDistCommand class function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
62 //**********************************************************************************************************************
63 ReadDistCommand::~ReadDistCommand(){
68 //**********************************************************************************************************************
69 int ReadDistCommand::execute(){
72 if (format == "matrix") {
74 openInputFile(filename, in);
75 matrix = new FullMatrix(in); //reads the matrix file
76 //memory leak prevention
77 //if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix; }
78 globaldata->gMatrix = matrix; //save matrix for coverage commands
81 //to prevent memory leak
82 if (globaldata->gListVector != NULL) { delete globaldata->gListVector; }
83 globaldata->gListVector = read->getListVector();
84 if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix; }
85 globaldata->gSparseMatrix = read->getMatrix();
90 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
94 cout << "An unknown error has occurred in the ReadDistCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";