Skip to content

Commit

Permalink
Remove stop token from predicted sequences
Browse files Browse the repository at this point in the history
Because the stop token is always predicted last, we don't need to take peptide order into account.
  • Loading branch information
bittremieux committed Dec 6, 2023
1 parent b2df0ef commit 38212f5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions casanovo/denovo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,7 @@ def _finish_beams(
continue
pred_tokens = tokens[i][: step + 1]
# Omit stop token.
if self.decoder.reverse and pred_tokens[0] == self.stop_token:
pred_tokens = pred_tokens[1:]
elif (
not self.decoder.reverse and pred_tokens[-1] == self.stop_token
):
if pred_tokens[-1] == self.stop_token:
pred_tokens = pred_tokens[:-1]
peptide_len = len(pred_tokens)
# Discard beams that were predicted to end but don't fit the minimum
Expand Down

0 comments on commit 38212f5

Please sign in to comment.