TreeGroupCommand::~TreeGroupCommand(){
if (abort == false) {
if (format == "sharedfile") { delete input; }
- else { delete readMatrix; delete matrix; delete list; }
+ else { delete list; }
delete tmap;
}
}else{
//read in dist file
filename = inputfile;
-
+
+ ReadMatrix* readMatrix;
if (format == "column") { readMatrix = new ReadColumnMatrix(filename); }
else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(filename); }
readMatrix->read(nameMap);
list = readMatrix->getListVector();
- matrix = readMatrix->getMatrix();
+ SparseDistanceMatrix* dMatrix = readMatrix->getDMatrix();
//make treemap
tmap = new TreeMap();
if (m->control_pressed) { return 0; }
- vector< vector<double> > matrix = makeSimsDist();
+ vector< vector<double> > matrix = makeSimsDist(dMatrix);
+ delete readMatrix;
+ delete dMatrix;
if (m->control_pressed) { return 0; }
}
}
/***********************************************************/
-vector< vector<double> > TreeGroupCommand::makeSimsDist() {
+vector< vector<double> > TreeGroupCommand::makeSimsDist(SparseDistanceMatrix* matrix) {
try {
numGroups = list->size();
//go through sparse matrix and fill sims
//go through each cell in the sparsematrix
- for(MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++){
- //similairity = -(distance-1)
- simMatrix[currentCell->row][currentCell->column] = -(currentCell->dist -1.0);
- simMatrix[currentCell->column][currentCell->row] = -(currentCell->dist -1.0);
-
- if (m->control_pressed) { return simMatrix; }
+ for (int i = 0; i < matrix->seqVec.size(); i++) {
+ for (int j = 0; j < matrix->seqVec[i].size(); j++) {
+
+ //already checked everyone else in row
+ if (i < matrix->seqVec[i][j].index) {
+ simMatrix[i][matrix->seqVec[i][j].index] = -(matrix->seqVec[i][j].dist -1.0);
+ simMatrix[matrix->seqVec[i][j].index][i] = -(matrix->seqVec[i][j].dist -1.0);
+ if (m->control_pressed) { return simMatrix; }
+ }
+ }
}
return simMatrix;