utils¶
Attributes¶
Functions¶
|
Compute CAI using the CAICalculator. |
|
Vectorized GC content calculation using precomputed codon GC counts |
|
Compute the minimum free energy (MFE) of an RNA sequence using Zucker Algorithm. |
|
Compute the total weighted reward and its components: |
|
Compute GC content, MFE, and CAI for a given RNA tensor state. |
|
|
|
Return the list of global codon indices that encode the given amino acid. |
|
|
|
|
|
|
Module Contents¶
- utils.ALL_CODONS: List[str]¶
- utils.CODON_TABLE: Dict[str, List[str]]¶
- utils.CODON_TO_IDX: Dict[str, int]¶
- utils.IDX_TO_CODON: Dict[int, str]¶
- utils.N_CODONS: int¶
- utils.STOP_CODONS: List[str] = ['UAA', 'UAG', 'UGA']¶
- utils.codon_gc_counts¶
- utils.compute_cai(indices, energies=None, loop_min=4)¶
Compute CAI using the CAICalculator.
- Parameters:
indices (torch.Tensor)
- Return type:
torch.Tensor
- utils.compute_gc_content_vectorized(indices, codon_gc_counts)¶
Vectorized GC content calculation using precomputed codon GC counts
- Parameters:
indices (torch.Tensor)
codon_gc_counts (torch.Tensor)
- Return type:
torch.Tensor
- utils.compute_mfe_energy(indices, energies=None, loop_min=4)¶
Compute the minimum free energy (MFE) of an RNA sequence using Zucker Algorithm.
- Parameters:
indices (torch.Tensor)
- Return type:
torch.Tensor
- utils.compute_reward(state, codon_gc_counts, weights)¶
Compute the total weighted reward and its components: reward = w1 * GC + w2 * (-MFE) + w3 * CAI
- utils.compute_reward_components(state, codon_gc_counts)¶
Compute GC content, MFE, and CAI for a given RNA tensor state.
- utils.decode_sequence(tensor_seq)¶
- utils.get_synonymous_indices(amino_acid)¶
Return the list of global codon indices that encode the given amino acid. Handles standard amino acids and ‘*’.
- Parameters:
amino_acid (str)
- Return type:
List[int]
- utils.load_config(path)¶
- Parameters:
path (str)
- Return type:
types.SimpleNamespace
- utils.plot_training_curves(loss_history, reward_components, out_path='training_curves.png')¶
- utils.to_mRNA_string(rna_tensor)¶
- Parameters:
rna_tensor (torch.Tensor)
- utils.tokenize_sequence_to_tensor(seq)¶