From ed6258311165a128118fe2a7325c36bc66fa0287 Mon Sep 17 00:00:00 2001 From: VarunAnanth2003 Date: Fri, 1 Mar 2024 00:25:59 -0800 Subject: [PATCH] geometric scoring added (no tests yet) --- casanovo/denovo/model.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/casanovo/denovo/model.py b/casanovo/denovo/model.py index 1c033484..155f0661 100644 --- a/casanovo/denovo/model.py +++ b/casanovo/denovo/model.py @@ -1075,7 +1075,14 @@ def calc_match_score( score_mask = truth_aa_indicies != 0 masked_per_aa_scores = per_aa_scores * score_mask - all_scores = masked_per_aa_scores.sum(dim=1) / score_mask.sum(dim=1) + # all_scores = masked_per_aa_scores.sum(dim=1) / score_mask.sum(dim=1) # Calculated arithmetic score + all_scores = torch.where( + torch.log(masked_per_aa_scores) == float("-inf"), + torch.tensor(0.0), + torch.log(masked_per_aa_scores), + ).sum(dim=1) / score_mask.sum( + dim=1 + ) # Calculates geometric score return all_scores, masked_per_aa_scores