Skip to content

Commit

Permalink
Merge pull request #348 from haddocking/clustfcc_threshold
Browse files Browse the repository at this point in the history
Remove hardcoded `top_n` value in `clustfcc`
  • Loading branch information
amjjbonvin committed Mar 2, 2022
2 parents 1ca2343 + e5f9ac9 commit 528d7b6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/haddock/modules/analysis/clustfcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ def _run(self):
clt_dic[cluster_id].append(model_pdb)

# Rank the clusters
# they are sorted by the top4 models in each cluster
top_n = 4
# they are sorted by the topX (threshold) models in each cluster
score_dic = {}
for clt_id in clt_dic:
score_l = [p.score for p in clt_dic[clt_id]]
score_l.sort()
top4_score = sum(score_l[:top_n]) / float(top_n)
top4_score = sum(score_l[:threshold]) / float(threshold)
score_dic[clt_id] = top4_score

sorted_score_dic = sorted(score_dic.items(), key=lambda k: k[1])
Expand Down Expand Up @@ -206,15 +205,15 @@ def _run(self):
model_score_l = [(e.score, e) for e in clt_dic[cluster_id]]
model_score_l.sort()
top_score = sum(
[e[0] for e in model_score_l][:top_n]
) / top_n
[e[0] for e in model_score_l][:threshold]
) / threshold
output_str += (
f"{os.linesep}"
"-----------------------------------------------"
f"{os.linesep}"
f"Cluster {cluster_rank} (#{cluster_id}, "
f"n={len(model_score_l)}, "
f"top{top_n}_avg_score = {top_score:.2f})"
f"top{threshold}_avg_score = {top_score:.2f})"
f"{os.linesep}")
output_str += os.linesep
output_str += f'clt_rank\tmodel_name\tscore{os.linesep}'
Expand Down

0 comments on commit 528d7b6

Please sign in to comment.