utils

Attributes

ALL_CODONS

CODON_TABLE

CODON_TO_IDX

IDX_TO_CODON

N_CODONS

STOP_CODONS

codon_gc_counts

Functions

compute_cai(indices[, energies, loop_min])

Compute CAI using the CAICalculator.

compute_gc_content_vectorized(indices, codon_gc_counts)

Vectorized GC content calculation using precomputed codon GC counts

compute_mfe_energy(indices[, energies, loop_min])

Compute the minimum free energy (MFE) of an RNA sequence using Zucker Algorithm.

compute_reward(state, codon_gc_counts, weights)

Compute the total weighted reward and its components:

compute_reward_components(state, codon_gc_counts)

Compute GC content, MFE, and CAI for a given RNA tensor state.

decode_sequence(tensor_seq)

get_synonymous_indices(amino_acid)

Return the list of global codon indices that encode the given amino acid.

load_config(path)

plot_training_curves(loss_history, reward_components)

to_mRNA_string(rna_tensor)

tokenize_sequence_to_tensor(seq)

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)