5 * Created by Pat Schloss on 8/14/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
10 #include "cluster.hpp"
11 #include "rabundvector.hpp"
12 #include "listvector.hpp"
13 #include "sparsematrix.hpp"
15 /***********************************************************************/
17 Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
18 rabund(rav), list(lv), dMatrix(dm)
22 /***********************************************************************/
24 void Cluster::getRowColCells(){
26 PCell* smallCell = dMatrix->getSmallestCell(); //find the smallest cell - this routine should probably not be in the SpMat class
28 smallRow = smallCell->row; //get its row
29 smallCol = smallCell->column; //get its column
30 smallDist = smallCell->dist; //get the smallest distance
35 for(MatData currentCell=dMatrix->begin();currentCell!=dMatrix->end();currentCell++){
37 if(&*currentCell == smallCell){ //put the smallest cell first
38 rowCells.insert(rowCells.begin(), currentCell);
39 colCells.insert(colCells.begin(), currentCell);
41 else if(currentCell->row == smallRow){
42 rowCells.push_back(currentCell);
44 else if(currentCell->column == smallRow){
45 rowCells.push_back(currentCell);
47 else if(currentCell->row == smallCol){
48 colCells.push_back(currentCell);
50 else if(currentCell->column == smallCol){
51 colCells.push_back(currentCell);
55 nRowCells = rowCells.size();
56 nColCells = colCells.size();
59 errorOut(e, "Cluster", "getRowColCells");
64 /***********************************************************************/
66 void Cluster::clusterBins(){
69 rabund->set(smallCol, rabund->get(smallRow)+rabund->get(smallCol));
70 rabund->set(smallRow, 0);
71 rabund->setLabel(toString(smallDist));
75 errorOut(e, "Cluster", "clusterBins");
80 /***********************************************************************/
82 void Cluster::clusterNames(){
85 list->set(smallCol, list->get(smallRow)+','+list->get(smallCol));
86 list->set(smallRow, "");
87 list->setLabel(toString(smallDist));
91 errorOut(e, "Cluster", "clusterNames");
96 /***********************************************************************/