File size: 613 Bytes
bb6d2aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from __future__ import annotations

from typing import Any

from staplebridge.chemistry.state import StapleState
from staplebridge.data.vocab import AMINO_ACIDS
from staplebridge.oracles.base import PeptidePriorBase


class MockPeptidePrior(PeptidePriorBase):
    def score_transition(self, old_state: StapleState, new_state: StapleState, context: dict[str, Any] | None = None) -> float:
        del old_state, context
        seq = new_state.sequence_tokens
        valid = sum(1 for t in seq if t in AMINO_ACIDS)
        length_pen = abs(len(seq) - 12) / 12
        return valid / max(len(seq), 1) - length_pen