Skip to content

Commit

Permalink
scorecomplex DBSCAN impropvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Woosub-Kim committed Jan 8, 2024
1 parent 6816a64 commit 10289c6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/strucclustutils/scorecomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "TMaligner.h"
#include "Coordinate16.h"
#include "createcomplexreport.h"
#include "set"

#ifdef OPENMP
#include <omp.h>
Expand Down Expand Up @@ -302,9 +303,9 @@ class DBSCANCluster {
unsigned int getAlnClusters() {
if (searchResult.alnVec.size() <= idealClusterSize)
return checkClusteringNecessity();

// TO skip single chained complex
if (idealClusterSize==1)
if (idealClusterSize <= SINGLE_CHAINED_COMPLEX)
return UNCLUSTERED;

return runDBSCAN();
Expand All @@ -313,6 +314,7 @@ class DBSCANCluster {
private:
const double LEARNING_RATE = 0.1;
const double DEFAULT_EPS = 0.1;
unsigned int SINGLE_CHAINED_COMPLEX = 1;
SearchResult &searchResult;
double eps;
unsigned int cLabel;
Expand Down Expand Up @@ -361,23 +363,23 @@ class DBSCANCluster {
if (neighbors.size() < maxClusterSize)
continue;
else if (neighbors.size() == maxClusterSize)
currClusters.emplace_back(neighbors);
currClusters.insert(neighbors);
// new Biggest cluster
else if (neighbors.size() > maxClusterSize) {
maxClusterSize = neighbors.size();
currClusters.clear();
currClusters.emplace_back(neighbors);
currClusters.insert(neighbors);
}
}

if (maxClusterSize < prevMaxClusterSize)
return finishDBSCAN();

if (maxClusterSize == prevMaxClusterSize && currClusters.size() < bestClusters.size())
return finishDBSCAN();
if (maxClusterSize == prevMaxClusterSize)
bestClusters.insert(currClusters.begin(), currClusters.end());

bestClusters = currClusters;
prevMaxClusterSize = maxClusterSize;
bestClusters = maxClusterSize > prevMaxClusterSize ? currClusters : bestClusters;
prevMaxClusterSize = maxClusterSize > prevMaxClusterSize ? maxClusterSize : prevMaxClusterSize;
eps += LEARNING_RATE;
return runDBSCAN();
}
Expand Down Expand Up @@ -457,7 +459,7 @@ class DBSCANCluster {
runDBSCAN();

prevMaxClusterSize = neighbors.size();
bestClusters.emplace_back(neighbors);
bestClusters.insert(neighbors);
return finishDBSCAN();
}
};
Expand Down

0 comments on commit 10289c6

Please sign in to comment.