Skip to content

Commit

Permalink
skip single chained complex for scorecomplex
Browse files Browse the repository at this point in the history
  • Loading branch information
Woosub-Kim committed Jan 8, 2024
1 parent 2a18734 commit 6816a64
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions src/strucclustutils/scorecomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,38 @@ class DBSCANCluster {
fillDistMap();
}

unsigned int clusterAlns() {
unsigned int getAlnClusters() {
if (searchResult.alnVec.size() <= idealClusterSize)
return checkClusteringNecessity();

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

return runDBSCAN();
}

private:
const double LEARNING_RATE = 0.1;
const double DEFAULT_EPS = 0.1;
SearchResult &searchResult;
double eps;
unsigned int cLabel;
unsigned int prevMaxClusterSize;
unsigned int maxClusterSize;
unsigned int recursiveNum;
unsigned int idealClusterSize;
unsigned int minClusterSize;
std::vector<unsigned int> neighbors;
std::vector<unsigned int> neighborsOfCurrNeighbor;
std::vector<unsigned int> qFoundChainKeys;
std::vector<unsigned int> dbFoundChainKeys;
distMap_t distMap;
cluster_t currClusters;
cluster_t bestClusters;

unsigned int runDBSCAN() {
initializeAlnLabels();
if (recursiveNum==0 && searchResult.alnVec.size() <= idealClusterSize) {
checkClusteringNecessity();
}
if (++recursiveNum > MAX_RECURSIVE_NUM) return UNCLUSTERED;
for (size_t centerAlnIdx=0; centerAlnIdx < searchResult.alnVec.size(); centerAlnIdx++) {
ChainToChainAln &centerAln = searchResult.alnVec[centerAlnIdx];
Expand Down Expand Up @@ -335,7 +362,7 @@ class DBSCANCluster {
continue;
else if (neighbors.size() == maxClusterSize)
currClusters.emplace_back(neighbors);
// new Biggest cluster
// new Biggest cluster
else if (neighbors.size() > maxClusterSize) {
maxClusterSize = neighbors.size();
currClusters.clear();
Expand All @@ -352,28 +379,9 @@ class DBSCANCluster {
bestClusters = currClusters;
prevMaxClusterSize = maxClusterSize;
eps += LEARNING_RATE;
return clusterAlns();
return runDBSCAN();
}

private:
const double LEARNING_RATE = 0.1;
const double DEFAULT_EPS = 0.1;
SearchResult &searchResult;
double eps;
unsigned int cLabel;
unsigned int prevMaxClusterSize;
unsigned int maxClusterSize;
unsigned int recursiveNum;
unsigned int idealClusterSize;
unsigned int minClusterSize;
std::vector<unsigned int> neighbors;
std::vector<unsigned int> neighborsOfCurrNeighbor;
std::vector<unsigned int> qFoundChainKeys;
std::vector<unsigned int> dbFoundChainKeys;
distMap_t distMap;
cluster_t currClusters;
cluster_t bestClusters;

void fillDistMap() {
distMap.clear();
for (size_t i=0; i < searchResult.alnVec.size(); i++) {
Expand Down Expand Up @@ -441,8 +449,13 @@ class DBSCANCluster {
for (size_t alnIdx=0; alnIdx<searchResult.alnVec.size(); alnIdx++) {
neighbors.emplace_back(alnIdx);
}
if (bestClusters.empty() || checkChainRedundancy())

if (neighbors.empty())
return UNCLUSTERED;

if (checkChainRedundancy())
runDBSCAN();

prevMaxClusterSize = neighbors.size();
bestClusters.emplace_back(neighbors);
return finishDBSCAN();
Expand Down Expand Up @@ -524,7 +537,7 @@ class ComplexScorer {
alnsFromCurrentQuery.clear();
paredSearchResult.filterAlnVec(minAssignedChainsRatio);
paredSearchResult.standardize();
if (!paredSearchResult.alnVec.empty())
if (!paredSearchResult.alnVec.empty()) // && currDbChainKeys.size() > 1
searchResults.emplace_back(paredSearchResult);
paredSearchResult.alnVec.clear();
}
Expand All @@ -537,7 +550,7 @@ class ComplexScorer {
}
unsigned int currLabel;
DBSCANCluster dbscanCluster = DBSCANCluster(searchResult, minAssignedChainsRatio);
currLabel = dbscanCluster.clusterAlns();
currLabel = dbscanCluster.getAlnClusters();
if (currLabel == UNCLUSTERED) return;
assignment = Assignment(searchResult.qResidueLen, searchResult.dbResidueLen);
for (auto &currAln: searchResult.alnVec) {
Expand Down Expand Up @@ -700,6 +713,7 @@ int scorecomplex(int argc, const char **argv, const Command &command) {
for (size_t qCompIdx = 0; qCompIdx < qComplexIndices.size(); qCompIdx++) {
unsigned int qComplexId = qComplexIndices[qCompIdx];
std::vector<unsigned int> &qChainKeys = qComplexIdToChainKeysMap.at(qComplexId);
// if (qChainKeys.size()==1) continue;
complexScorer.getSearchResults(qComplexId, qChainKeys, dbChainKeyToComplexIdMap, dbComplexIdToChainKeysMap, searchResults);
// for each db complex
for (size_t dbId = 0; dbId < searchResults.size(); dbId++) {
Expand Down

0 comments on commit 6816a64

Please sign in to comment.