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"
14 ReadDistCommand::ReadDistCommand(){
16 globaldata = GlobalData::getInstance();
18 filename = globaldata->inputFileName;
19 format = globaldata->getFormat();
21 if (format == "column") { read = new ReadColumnMatrix(filename); }
22 else if (format == "phylip") { read = new ReadPhylipMatrix(filename); }
23 else if (format == "matrix") {
24 groupMap = new GroupMap(globaldata->getGroupFile());
26 //if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; }
27 globaldata->gGroupmap = groupMap;
30 if (format != "matrix" ) {
31 if(globaldata->getPrecision() != ""){
32 convert(globaldata->getPrecision(), precision);
35 if(globaldata->getCutOff() != ""){
36 convert(globaldata->getCutOff(), cutoff);
37 cutoff += (5 / (precision * 10.0));
39 read->setCutoff(cutoff);
41 if(globaldata->getNameFile() != ""){
42 nameMap = new NameAssignment(globaldata->getNameFile());
43 nameMap->readMap(1,2);
52 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
56 cout << "An unknown error has occurred in the ReadDistCommand class function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
61 //**********************************************************************************************************************
62 ReadDistCommand::~ReadDistCommand(){
67 //**********************************************************************************************************************
68 int ReadDistCommand::execute(){
71 if (format == "matrix") {
73 openInputFile(filename, in);
74 matrix = new FullMatrix(in); //reads the matrix file
75 //memory leak prevention
76 //if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix; }
77 globaldata->gMatrix = matrix; //save matrix for coverage commands
80 globaldata->gListVector = read->getListVector();
81 globaldata->gSparseMatrix = read->getMatrix();
86 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
90 cout << "An unknown error has occurred in the ReadDistCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";