]> git.donarmstrong.com Git - mothur.git/blobdiff - sparsedistancematrix.cpp
changing command name classify.shared to classifyrf.shared
[mothur.git] / sparsedistancematrix.cpp
index 03e9fa8e5b77905d4a4416a6c592d3b3756a02e4..417e24ae94e4242db9a56db14fd2987714ab1712 100644 (file)
@@ -89,6 +89,30 @@ void SparseDistanceMatrix::addCell(ull row, PDistCell cell){
                exit(1);
        }
 }
+/***********************************************************************/
+int SparseDistanceMatrix::addCellSorted(ull row, PDistCell cell){
+       try {
+               numNodes+=2;
+               if(cell.dist < smallDist){ smallDist = cell.dist; }
+        
+        seqVec[row].push_back(cell);
+        PDistCell temp(row, cell.dist);
+        seqVec[cell.index].push_back(temp);
+        
+        sortSeqVec(row);
+        sortSeqVec(cell.index);
+        
+        int location = -1; //find location of new cell when sorted
+        for (int i = 0; i < seqVec[row].size(); i++) {  if (seqVec[row][i].index == cell.index) { location = i; break; } }
+        
+        return location;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SparseDistanceMatrix", "addCellSorted");
+               exit(1);
+       }
+}
+
 /***********************************************************************/
 
 ull SparseDistanceMatrix::getSmallestCell(ull& row){
@@ -151,3 +175,18 @@ int SparseDistanceMatrix::sortSeqVec(){
 }
 /***********************************************************************/
 
+int SparseDistanceMatrix::sortSeqVec(int index){
+       try {
+        
+        //saves time in getSmallestCell, by making it so you dont search the repeats
+        sort(seqVec[index].begin(), seqVec[index].end(), compareIndexes);
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "SparseDistanceMatrix", "sortSeqVec");
+               exit(1);
+       }
+}
+/***********************************************************************/
+